ID:               28167
 Comment by:       php at bobsilva dot com
 Reported By:      jaguargordon at free dot fr
 Status:           Open
 Bug Type:         Class/Object related
 Operating System: Windows XP SP1
 PHP Version:      5CVS-2004-04-26 (dev)
 New Comment:

Not sure this is a bug.
The Relection API is dependent on the class definition not the usage of
the class. Therefore, since the raise() method is only called statically
and not defined as static, it properly indicates this in the stack
trace. In PHP5, calling non-static methods statically is only a BC
option and therefore should not be used.


Previous Comments:
------------------------------------------------------------------------

[2004-04-26 20:41:59] jaguargordon at free dot fr

title ...

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

[2004-04-26 20:37:27] jaguargordon at free dot fr

Description:
------------
The stack trace feature seams to mishandle static methods when a
exception is raised.

Reproduce code:
---------------
<pre><?php

class MyException extends Exception {
function raise() {
throw new MyException;
}

static function raiseStatic() {
throw new MyException;
}
}

function dontwork() { return false; }

class Foo {
function bar() {
$v = @dontwork() or MyException::raise();
}

function barStatic() {
$v = @dontwork() or MyException::raiseStatic();
}
}

$foo = new Foo;

try { $foo->bar(); }
catch( Exception $e ) { echo $e; echo "\n\n"; }

try { $foo->barStatic(); }
catch( Exception $e ) { echo $e; echo "\n\n"; }

?></pre>

Expected result:
----------------
exception 'MyException' in C:\www\static.php:6
Stack trace:
#0 C:\www\static.php(19): MyException::raise()
#1 C:\www\static.php(29): Foo->bar()
#2 {main}

exception 'MyException' in C:\www\static.php:10
Stack trace:
#0 C:\www\static.php(23): MyException::raiseStatic()
#1 C:\www\static.php(32): Foo->barStatic()
#2 {main}


Actual result:
--------------
exception 'MyException' in C:\www\static.php:6
Stack trace:
#0 C:\www\static.php(19): Foo->raise()
#1 C:\www\static.php(29): Foo->bar()
#2 {main}

exception 'MyException' in C:\www\static.php:10
Stack trace:
#0 C:\www\static.php(23): MyException::raiseStatic()
#1 C:\www\static.php(32): Foo->barStatic()
#2 {main}



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


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

Reply via email to