Skip to content

Instantly share code, notes, and snippets.

@haruair
Last active June 27, 2017 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haruair/e64956c0ad4142355a7458f8f9126d1a to your computer and use it in GitHub Desktop.
Save haruair/e64956c0ad4142355a7458f8f9126d1a to your computer and use it in GitHub Desktop.
<?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
Copy link
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