Bug #65809 [Opn->Csd]: interface, abstract static function
| From: | nikic@php.net | Date: | Wed, 06 May 2015 17:09:04 +0000 |
| Subject: | Bug #65809 [Opn->Csd]: interface, abstract static function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192527@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
Updated by: nikic@php.net
Reported by: spam at krol dot me
Summary: interface, abstract static function
-Status: Open
+Status: Closed
Type: Bug
Package: Class/Object related
PHP Version: 5.3.15
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
The strict standards notice no longer exists in PHP 7.
Previous Comments:
------------------------------------------------------------------------
[2013-10-03 06:49:24] phpmpan at mpan dot pl
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
------------------------------------------------------------------------
[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