diff --git a/src/Util/ErrorHandler.php b/src/Util/ErrorHandler.php index cd36fe7..cf63cad 100644 --- a/src/Util/ErrorHandler.php +++ b/src/Util/ErrorHandler.php @@ -89,12 +89,12 @@ public function execute($file, $line) }); try { - return call_user_func_array($this->method, $this->arguments); + $value = call_user_func_array($this->method, $this->arguments); + restore_error_handler(); + return $value; } catch (ErrorException $exception) { restore_error_handler(); throw $exception; } - - restore_error_handler(); } } diff --git a/tests/src/Util/ErrorHandlerTest.php b/tests/src/Util/ErrorHandlerTest.php index 63ad0e8..438b731 100644 --- a/tests/src/Util/ErrorHandlerTest.php +++ b/tests/src/Util/ErrorHandlerTest.php @@ -57,6 +57,16 @@ public function testExecute() } } + /** + * @covers ::__construct + * @covers ::execute + */ + public function testExecuteSuccess() + { + $object = new ErrorHandler('trim', ' test'); + $this->assertSame('test', $object->execute('0', 1)); + } + /** * @covers ::__construct * @expectedException \Fabiang\Xmpp\Exception\InvalidArgumentException