Используйте ключевое слово final
(как в Java и т. Д.):
class fooBase{
final public function something(){
}
}
class foo extends fooBase{
public function __construct(){
echo $this->something(); // <- should be the parent class method
}
public function something(){
// this method should not be allowed to be created
}
}
См. Финальное ключевое слово PHP . Обратите внимание, что foo
будет по-прежнему иметь метод something
, но something
будет поступать только от fooBase
и foo
не сможет его переопределить.