note 118540 added to exception.gettrace
| From: | jurchiks101 at gmail dot com | Date: | Wed, 23 Dec 2015 16:53:52 +0000 |
| Subject: | note 118540 added to exception.gettrace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204527@lists.php.net to get a copy of this message | ||
The trace data does not include file and line when an exception is thrown from a method invoked via
reflection.
test.php:
<?php
class Example
{
public static function test()
{
throw new Exception('foo');
}
}
$reflectionClass = new ReflectionClass('Example');
$reflectionMethod = $reflectionClass->getMethod('test');
try
{
$reflectionMethod->invoke(null);
}
catch (Exception $e)
{
var_dump($e->getMessage());
var_dump($e->getTrace());
}
// Output (formatted for brevity and readability):
// string(3) "foo"
// array(2) {
// [0] => array(4) {
// ["function"] => string(4) "test"
// ["class"] => string(7) "Example"
// ["type"] => string(2) "::"
// ["args"] => array(0) {}
// }
// [1] => array(6) {
// ["file"] => string(24) "/path/to/test.php"
// ["line"] => int(15)
// ["function"] => string(6) "invoke"
// ["class"] => string(16) "ReflectionMethod"
// ["type"] => string(2) "->"
// ["args"] => array(1) {
// [0]=> NULL
// }
// }
// }
?>
----
Server IP: 72.52.91.14
Probable Submitter: 91.90.249.76
----
Manual Page -- http://php.net/manual/en/exception.gettrace.php
Edit -- https://master.php.net/note/edit/118540
Del: integrated -- https://master.php.net/note/delete/118540/integrated
Del: useless -- https://master.php.net/note/delete/118540/useless
Del: bad code -- https://master.php.net/note/delete/118540/bad+code
Del: spam -- https://master.php.net/note/delete/118540/spam
Del: non-english -- https://master.php.net/note/delete/118540/non-english
Del: in docs -- https://master.php.net/note/delete/118540/in+docs
Del: other reasons-- https://master.php.net/note/delete/118540
Reject -- https://master.php.net/note/reject/118540
Search -- https://master.php.net/manage/user-notes.php