php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63053 static keyword wrong!!
Submitted: 2012-09-10 08:47 UTC Modified: 2012-09-10 08:52 UTC
From: yyb8 at vip dot qq dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.4.6 OS: win2003
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yyb8 at vip dot qq dot com
New email:
PHP Version: OS:

 

 [2012-09-10 08:47 UTC] yyb8 at vip dot qq dot com
Description:
------------
in this page http://cn2.php.net/manual/en/language.oop5.static.php

write:
"
Calling non-static methods statically generates an E_STRICT level warning. "

Bug it is not always right!

e.g. 

Test script:
---------------
<?php
class A {
    public function foo() {
        echo "success!\n";
    }
    public function test() {
     
	    A::foo(); //no E_STRICT level warning
		 
    }
}

class B extends A {
   
public function test() {
       
	   A::foo();//no E_STRICT level warning

	   B::foo();//no E_STRICT level warning

    }

}

 

$b = new B();
$b->test();
 

$a = new A();
$a->test();
?>

will print 
success!
success!
success!


 with no error.

Expected result:
----------------


Strict Standards: Non-static method A::foo() should not be called statically, assuming $this from incompatible context in E:\Inetpub\wwwroot\php\Noname15.php on line 20
success!

 

Actual result:
--------------
success!
success!
success!
 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-10 08:52 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2012-09-10 08:52 UTC] aharvey@php.net
Those calls aren't static: they're instance method calls using the scope resolution operator (::) to disambiguate which class's method should be invoked.

Documentation: http://php.net/%3A%3A
 [2013-03-19 03:13 UTC] me at salimane dot com
This is a bug. It generates E_STRICT level warning on 5.3.10 but not on 5.4.6.
So this is a BUG
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 03:00:02 2026 UTC