directly invoke callables instead of call_user_func.

eases debugging, because of simpler stacktraces.
This commit is contained in:
Markus Staab
2015-01-22 10:35:56 +01:00
parent 37ba42c184
commit 8d15a7357e
2 changed files with 24 additions and 1 deletions
+4 -1
View File
@@ -43,7 +43,10 @@ class CallbackHandler extends Handler
$exception = $this->getException();
$inspector = $this->getInspector();
$run = $this->getRun();
$callable = $this->callable;
return call_user_func($this->callable, $exception, $inspector, $run);
// invoke the callable directly, to get simpler stacktraces (in comparison to call_user_func).
// this assumes that $callable is a properly typed php-callable, which we check in __construct().
return $callable($exception, $inspector, $run);
}
}
@@ -0,0 +1,20 @@
<?php
namespace Whoops\Handler;
use Whoops\TestCase;
use Whoops\Handler\CallbackHandler;
class CallbackHandlerTest extends TestCase
{
public function testSimplifiedBacktrace() {
$handler = new CallbackHandler(function($exception, $inspector, $run) {
return debug_backtrace();
});
$backtrace = $handler->handle();
foreach($backtrace as $frame) {
$this->assertNotContains('call_user_func', $frame['function']);
}
}
}