php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #34390 Redefinition of static methods in subclasses
Submitted: 2005-09-06 13:49 UTC Modified: 2005-09-17 16:53 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: cbelin at free dot fr Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.0.4 OS: Windows XP SP2
Private report: No CVE-ID: None
 [2005-09-06 13:49 UTC] cbelin at free dot fr
Description:
------------
Manual says that static members and methods cannot be redefined in subclasses.

It seems that it's not completely true (at least with PHP 5.0.4 under Windows XP), as redefining static methods in subclasses is allowed, and works fine (i.e. without triggering errors even if error level includes E_STRICT).


Reproduce code:
---------------
class Base
{
   public static function foo()
   {
      return 'Foo...';
   }
}

class Extended extends Base
{
   public static function foo()
   {
      return 'Bar !!!';
   }
}

echo Extended::foo();

Expected result:
----------------
An error, or the output of Base::foo()

Actual result:
--------------
It works, and prints 'Bar !!!'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-07 11:54 UTC] sniper@php.net
Dmitry, shouldn't this procude an error..?

 [2005-09-12 11:37 UTC] dmitry@php.net
This is documentation bug.
 [2005-09-12 13:38 UTC] sniper@php.net
Reclassified as docu bug.
 [2005-09-17 16:53 UTC] nforbes@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:11 UTC] phpdocbot@php.net
Automatic comment on behalf of nforbes
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=e0fe293930e6a74f1d9c8ef46d3ae7f48df600a1
Log: Fixed bug #34390 (static members and methods really can be redefined in subclasses)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 22 17:00:02 2025 UTC