What is the difference between self:: and static:: when calling a method or property in an inherited class?
Last updated
self::resolves at compile time to the class where the code is written, ignoring child overrides.static::uses late static binding (PHP 5.3+) to resolve to the class actually called at runtime, so child overrides are honored.Factory methods use
new static()so subclasses return instances of their own type.