Fix wording & co

main
Jordi Boggiano 12 years ago
parent a5c2c6c07e
commit 51447074c2

@ -41,7 +41,7 @@ class Application extends BaseApplication
public function __construct()
{
ErrorHandler::set();
ErrorHandler::register();
parent::__construct('Composer', Composer::VERSION);
}

@ -13,7 +13,7 @@
namespace Composer\Util;
/**
* Convert PHP E_NOTICE, E_WARNING into exceptions
* Convert PHP errors into exceptions
*
* @author Artem Lopata <biozshock@gmail.com>
*/
@ -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'));
}

@ -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');
}

Loading…
Cancel
Save