Last active
June 27, 2017 11:08
-
-
Save haruair/e64956c0ad4142355a7458f8f9126d1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
코드 자체는 php에서 실행 가능하지만 정적 분석에서 인터페이스에 선언되지 않은 메소드인 것을 보여줍니다. 아래 예는 phpstorm입니다.