Bug #65809 [Com]: interface, abstract static function
| From: | phpmpan at mpan dot pl | Date: | Thu, 03 Oct 2013 06:49:25 +0000 |
| Subject: | Bug #65809 [Com]: interface, abstract static function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181990@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65809&edit=1
ID: 65809
Comment by: phpmpan at mpan dot pl
Reported by: spam at krol dot me
Summary: interface, abstract static function
Status: Open
Type: Bug
Package: Class/Object related
PHP Version: 5.3.15
Block user comment: N
Private report: N
New Comment:
I haven't noticed this, as the case doesn't produce an error, but only a E_STRICT level
message. Ok, hence the report is now valid.
However, be aware that the issue was already discussed and I believe this message is the source of
the patch that removed "abstract static" 7 years ago: http://marc.info/?l=php-internals&m=114120699223033&w=2
Previous Comments:
------------------------------------------------------------------------
[2013-10-03 05:21:40] spam at krol dot me
And use this test case. It don't make use of constructor
Test script:
---------------
abstract class A { abstract static function aa(); } //invalid
//Strict Standards: Static function A::aa() should not be abstract in php shell code on line 1
interface I { static function ii(); } //valid
abstract class B implements I {} //valid
//class C extends B{} // invalid
//Fatal error: Class C contains 1 abstract method and must therefore be declared abstract or
implement the remaining methods (I::i) in php shell code on line 1
class D extends B{
static function ii(){echo "I have to be implemented"; }
}
------------------------------------------------------------------------
[2013-10-03 05:10:24] spam at krol dot me
I changed PHP version as it IS revelant
According to this
http://php.net/manual/en/migration52.incompatible.php
Dropped abstract static class functions. Due to an oversight, PHP 5.0.x and 5.1.x allowed abstract
static functions in classes. As of PHP 5.2.x, only interfaces can have them.
------------------------------------------------------------------------
[2013-10-02 23:43:36] phpmpan at mpan dot pl
Abstract static methods are allowed. Abstract static *constructors* aren't.
------------------------------------------------------------------------
[2013-10-02 10:58:34] spam at krol dot me
Description:
------------
abstract static function in class isn't allowed,
but you can define static function in interface
This leads to funny inconsistency where you can create abstract static function using interfaces
Test script:
---------------
//abstract class A { abstract static function a(); } //invalid
interface I { static function i(); } //valid
abstract class B implements I {} //valid
//class C extends B{} // invalid
//Fatal error: Class C contains 1 abstract method and must therefore be declared abstract or
implement the remaining methods (I::i) in php shell code on line 1
class D extends B{
static function i(){echo "I have to be implemented"; }
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65809&edit=1