Doc #63053 [Opn->Nab]: static keyword wrong!!

From: Date: Mon, 10 Sep 2012 08:52:52 +0000
Subject: Doc #63053 [Opn->Nab]: static keyword wrong!!
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8848@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63053&edit=1

 ID:                 63053
 Updated by:         aharvey@php.net
 Reported by:        yyb8 at vip dot qq dot com
 Summary:            static keyword wrong!!
-Status:             Open
+Status:             Not a bug
 Type:               Documentation Problem
 Package:            Documentation problem
 Operating System:   win2003
 PHP Version:        5.4.6
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2012-09-10 08:47:39] 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!
 


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63053&edit=1


Thread (3 messages)

« previous php.doc.bugs (#8848) next »