|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-10-02 10:58 UTC] 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"; }
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
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"; } }