|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-09-01 13:24 UTC] mlocati at gmail dot com
-Summary: abstract class with static methods: valid or not?
+Summary: abstract class with abstract static methods: valid or
not?
[2016-09-01 13:24 UTC] mlocati at gmail dot com
[2016-09-01 22:27 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2016-09-01 22:27 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
Description: ------------ Consider this code: abstract class AbstractClass { abstract public static function Method(); } class ReadClass extends AbstractClass { public static function Method() { } } is this valid? See for instance https://3v4l.org/nSsLg - from PHP 5.0 to PHP 5.1: it was valid - from PHP 5.2 to PHP 5.6: we have this warning: Strict Standards: Static function AbstractClass::Method() should not be abstract - from PHP 7.0: it is again valid So... is this a wanted change? Or is it a bug in the 7.x series? PS: I'm not saying that it shouldn't be valid (indeed I'd prefer it's a legal approach) Related bugs: - https://bugs.php.net/bug.php?id=65809 There we just say that "The strict standards notice no longer exists in PHP 7", but does not say anything about the validity of abstract static methods in abstract classes - https://bugs.php.net/bug.php?id=66688 There the reporter suggests to remove static methods from abstract classes (why PHP should force this? It's a philosophy approach, subject to developers mind, and the language shouldn't force developers to not do something - people who think it's wrong can simply avoid that approach)