class ParentClass {
public static function create(): static {
return new static(); // Late Static Binding
}
public static function createSelf(): self {
return new self(); // всегда ParentClass
}
}
class ChildClass extends ParentClass {}
$obj = ChildClass::create(); // ChildClass
$obj = ChildClass::createSelf(); // ParentClass!self ссылается на класс, в котором написан код (compile-time). static ссылается на класс, который вызвал метод (runtime). $this - ссылка на текущий объект (только в нестатическом контексте).