ID: 45620
Comment by: coen at bluedogtraining dot com dot au
Reported By: kelvin at netbasic dot co dot uk
Status: Open
Bug Type: Scripting Engine problem
Operating System: CentOS 5
PHP Version: 5.2.6
New Comment:
This is not just a stacktrace problem. If you were to attempt use
'$this' in funcB you would find that '$this' is actually available and
is an instance of class testA.
I stumbled on this accidentally.
<?php
class testA
{
public function funcA()
{
testB::funcB();
}
}
class testB
{
public function funcB()
{
echo get_class($this);
}
}
$obj = new testA();
$obj->funcA();
?>
Expected result:
----------------
nothing
Actual result:
--------------
testA
It appears as though the static method is being executed in the context
of the calling object. Strange behaviour.
Previous Comments:
------------------------------------------------------------------------
[2008-07-25 02:45:45] kelvin at netbasic dot co dot uk
Description:
------------
When calling a static function from inside of a class the backtrace /
stacktrace reports the call as a normal object call, i.e. its showing
->, where it really should show ::
Reproduce code:
---------------
<?php
class testA
{
public function funcA()
{
testB::funcB();
}
}
class testB
{
public function funcB()
{
echo "<pre>";
debug_print_backtrace();
echo "</pre>";
}
}
$obj = new testA();
$obj->funcA();
?>
Expected result:
----------------
#0 testB::funcB() called at [/home/site3/public_html/t1.php:7]
#1 testA->funcA() called at [/home/site3/public_html/t1.php:23]
Actual result:
--------------
#0 testB->funcB() called at [/home/site3/public_html/t1.php:7]
#1 testA->funcA() called at [/home/site3/public_html/t1.php:23]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45620&edit=1