가능한 중복 : 전화 정적 메서드 상속 인터페이스
Referring to a static member of a subclass
<?php
Interface IDoesSomething
{
public static function returnSomething();
}
abstract class MiddleManClass implements IDoesSomething
{
public static function doSomething()
{
return 1337 * self::returnSomething();
}
}
class SomeClass extends MiddleManClass
{
public static function returnSomething()
{
return 999;
}
}
// and now, the vicious call
$foo = SomeClass::doSomething();
/**
* results in a
* PHP Fatal error: Cannot call abstract method IDoesSomething::returnSomething()
*/
?>
추상적 인 "중개인"클래스에 정의 된 함수의 함수를 호출 할 수있는 가능성을 유지하면서 returnSomething()
의 추상화를 강제 할 수있는 방법이 있나요? 나에게 PHP의 병목 현상처럼 보입니다.
내 질문은 근본적으로 다르다. – Daniel
구체적인 문제는 다소 (근본적으로는 아니지만) 다르지만 추상 문제 (LSB)는 동일합니다. – Gordon