#47316 [Bgs]: static get_class() problem with parent/child
ID: 47316
User updated by: john dot oconnor at totemic dot co dot uk
Reported By: john dot oconnor at totemic dot co dot uk
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 5.2.8
New Comment:
I don't understand how its not a bug? A 'workaround' would be using
"Late static binding", but that still doesn't solve this bug (And its
only available in the alpha release of 5.3.0, not the stable 5.2.8)
Calling a function in Bar from the child Foo:
self should return Foo.
parent should retun Bar.
Whereas if I'm calling Bar directly:
self returns Bar
Previous Comments:
------------------------------------------------------------------------
[2009-02-05 21:09:59] jani@php.net
It's still defined in Bar. No bug here.
------------------------------------------------------------------------
[2009-02-05 15:11:17] john dot oconnor at totemic dot co dot uk
Description:
------------
When calling a function in a static context, it appears that get_class
reports its class incorrectly.
Reproduce code:
---------------
class Foo extends Bar
{
}
class Bar
{
function test()
{
return get_class(new self);
}
}
print "Should report 'Foo': " . Foo::test();
print "Should report 'Bar': " . Bar::test();
Expected result:
----------------
Should report 'Foo': Foo
Should report 'Bar': Bar
Actual result:
--------------
Should report 'Foo': Bar
Should report 'Bar': Bar
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47316&edit=1
Thread (3 messages)