Doc #62446 [Opn]: static call of non-static function breaks context of late static binding
| From: | picht at eventit dot ag | Date: | Fri, 29 Jun 2012 08:03:11 +0000 |
| Subject: | Doc #62446 [Opn]: static call of non-static function breaks context of late static binding | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-8512@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62446&edit=1
ID: 62446
User updated by: picht at eventit dot ag
Reported by: picht at eventit dot ag
Summary: static call of non-static function breaks context of
late static binding
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: ubuntu 2.6.32-41-server
PHP Version: 5.3.14
Block user comment: N
Private report: N
New Comment:
I mixed up "Expected result" and "Actual result".
They should be the other way around. Sorry for that!
Previous Comments:
------------------------------------------------------------------------
[2012-06-29 08:00:28] picht at eventit dot ag
Description:
------------
When calling a non-static function statically the late static binding context
still points to the calling class context. This should be documented on the static
keyword page.
Test script:
---------------
<?php
class a {
public static function foo()
{
echo 'foo a';
}
public function bar()
{
// expecting to call a::foo or b::foo
// calls c::foo instead
static::foo();
}
}
class b extends a {
public static function foo()
{
echo 'foo b';
}
}
class c {
public function test()
{
b::bar();
}
public static function foo()
{
echo 'foo c';
}
}
$c = new c();
$c->test();
Expected result:
----------------
Documentation suggest b::foo will be called
Actual result:
--------------
Documentation warns about c::foo getting called
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62446&edit=1