Originally coded without strict warnings, a project now triggers numerous warnings after enabling them. Among these is a warning about an abstract static function in the abstract parent class Program. According to documentation, abstract static functions were unintentionally allowed in PHP 5.0.x and 5.1.x and are no longer permitted.
PHP 5.2 lacked late static bindings, which became available in PHP 5.3. This feature enables parent class methods to call static methods of their child classes. Without it, abstract static methods in PHP 5.2 were ineffective since parent classes could not call child class static methods.
Upon the introduction of late static bindings, abstract static methods regained relevance. Despite this, the warning persists. While it can be argued that abstract static methods may lead to exposing broken public methods in abstract classes, this argument is considered weak.
PHP bug report 53081 requested the removal of the warning. Initially dismissed as bogus, the report was later closed as bogus due to a misunderstanding by Rasmus Lerdorf, the creator of PHP.
The warning will be removed in PHP 7 thanks to Nikita Popov's PHP RFC: Reclassify E_STRICT notices. This move towards sanity will allow developers to utilize abstract static methods without encountering the erroneous warning encountered in PHP 5.2 .
The above is the detailed content of Why Are Abstract Static Class Methods Not Allowed in PHP 5.2 ?. For more information, please follow other related articles on the PHP Chinese website!