#28167 [Opn->Bgs]: Stack trace and a static method
| From: | derick@php.net | Date: | Wed, 13 Oct 2004 07:20:52 +0000 |
| Subject: | #28167 [Opn->Bgs]: Stack trace and a static method | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-67518@lists.php.net to get a copy of this message | ||
ID: 28167
Updated by: derick@php.net
Reported By: jaguargordon at free dot fr
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Windows XP SP1
PHP Version: 5CVS-2004-04-26 (dev)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Correct analysis, no bug here.
Previous Comments:
------------------------------------------------------------------------
[2004-10-13 02:05:28] php at bobsilva dot com
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.
------------------------------------------------------------------------
[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