From 51447074c2e1fb16e5d7bd60900850fcf4db825d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 18 Mar 2012 21:16:36 +0100 Subject: [PATCH] Fix wording & co --- src/Composer/Console/Application.php | 2 +- src/Composer/Util/ErrorHandler.php | 20 +++++++++---------- tests/Composer/Test/Util/ErrorHandlerTest.php | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 57c659519..06a8fb5d0 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -41,7 +41,7 @@ class Application extends BaseApplication public function __construct() { - ErrorHandler::set(); + ErrorHandler::register(); parent::__construct('Composer', Composer::VERSION); } diff --git a/src/Composer/Util/ErrorHandler.php b/src/Composer/Util/ErrorHandler.php index cb620e52f..708d2976f 100644 --- a/src/Composer/Util/ErrorHandler.php +++ b/src/Composer/Util/ErrorHandler.php @@ -13,7 +13,7 @@ namespace Composer\Util; /** - * Convert PHP E_NOTICE, E_WARNING into exceptions + * Convert PHP errors into exceptions * * @author Artem Lopata */ @@ -22,30 +22,30 @@ class ErrorHandler /** * Error handler * - * @param int $errorNo Level of the error raised - * @param string $errorString Error message - * @param string $errorFile Filename that the error was raised in - * @param int $errorLine Line number the error was raised at + * @param int $level Level of the error raised + * @param string $message Error message + * @param string $file Filename that the error was raised in + * @param int $line Line number the error was raised at * * @static * @throws \ErrorException */ - public static function handle($errorNo, $errorString, $errorFile, $errorLine) + public static function handle($level, $message, $file, $line) { - //this allows error suppression in 3rd party code to work + // respect error_reporting being disabled if (!error_reporting()) { return; } - throw new \ErrorException(sprintf('%s in %s:%d', $errorString, $errorFile, $errorLine), $errorNo); + throw new \ErrorException($message, 0, $level, $file, $line); } /** - * Set error handler + * Register error handler * * @static */ - public static function set() + public static function register() { set_error_handler(array(__CLASS__, 'handle')); } diff --git a/tests/Composer/Test/Util/ErrorHandlerTest.php b/tests/Composer/Test/Util/ErrorHandlerTest.php index 6aebc5c15..015997191 100644 --- a/tests/Composer/Test/Util/ErrorHandlerTest.php +++ b/tests/Composer/Test/Util/ErrorHandlerTest.php @@ -27,9 +27,9 @@ class ErrorHandlerTest extends TestCase */ public function testErrorHandlerCaptureNotice() { - $this->setExpectedException('\ErrorException', 'Undefined index: baz in ' . __FILE__); + $this->setExpectedException('\ErrorException', 'Undefined index: baz'); - ErrorHandler::set(); + ErrorHandler::register(); $array = array('foo' => 'bar'); $array['baz']; @@ -40,9 +40,9 @@ class ErrorHandlerTest extends TestCase */ public function testErrorHandlerCaptureWarning() { - $this->setExpectedException('\ErrorException', 'array_merge(): Argument #2 is not an array in ' . __FILE__); + $this->setExpectedException('\ErrorException', 'array_merge(): Argument #2 is not an array'); - ErrorHandler::set(); + ErrorHandler::register(); array_merge(array(), 'string'); }