Doc #63053 [Com]: static keyword wrong!!
Edit report at https://bugs.php.net/bug.php?id=63053&edit=1
ID: 63053
Comment by: me at salimane dot com
Reported by: yyb8 at vip dot qq dot com
Summary: static keyword wrong!!
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:
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
Previous Comments:
------------------------------------------------------------------------
[2012-09-10 08:52:52] 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
------------------------------------------------------------------------
[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)