note 118540 rejected from exception.gettrace by cmb

From: Date: Wed, 23 Dec 2015 17:04:01 +0000
Subject: note 118540 rejected from exception.gettrace by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-204528@lists.php.net to get a copy of this message
Note Submitter: jurchiks101 at gmail dot com ---- 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 // } // } // } ?>

« previous php.notes (#204528) next »