Skip to content

Instantly share code, notes, and snippets.

@haruair haruair/chicken.php
Last active Jun 27, 2017

Embed
What would you like to do?
<?php
interface FoodInterface
{
}
class FriedChicken implements FoodInterface
{
public function getName()
{
return self::class;
}
}
class Human
{
public function eat(FoodInterface $food)
{
echo $food->getName();
}
}
$chicken = new FriedChicken;
$me = new Human;
$me->eat($chicken);
// FriedChicken
@haruair

This comment has been minimized.

Copy link
Owner Author

haruair commented Jun 27, 2017

코드 자체는 php에서 실행 가능하지만 정적 분석에서 인터페이스에 선언되지 않은 메소드인 것을 보여줍니다. 아래 예는 phpstorm입니다.

screen shot 2017-06-27 at 9 05 41 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.