Bug #72993 [NEW]: abstract class with static methods: valid or not?
| From: | mlocati at gmail dot com | Date: | Thu, 01 Sep 2016 13:17:47 +0000 |
| Subject: | Bug #72993 [NEW]: abstract class with static methods: valid or not? | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-203726@lists.php.net to get a copy of this message | ||
From: mlocati at gmail dot com
Operating system:
PHP version: 7.0.10
Package: Class/Object related
Bug Type: Bug
Bug description:abstract class with static methods: valid or not?
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)
--
Edit bug report at https://bugs.php.net/bug.php?id=72993&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72993&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72993&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72993&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72993&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72993&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72993&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72993&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72993&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72993&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72993&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72993&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72993&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72993&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72993&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72993&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72993&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72993&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72993&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72993&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72993&r=mysqlcfg