@@ -349,20 +349,18 @@ private function reRegister($prev)
349
349
/**
350
350
* Handles errors by filtering then logging them according to the configured bit fields.
351
351
*
352
- * @param int $type One of the E_* constants
352
+ * @param int $type One of the E_* constants
353
353
* @param string $message
354
354
* @param string $file
355
355
* @param int $line
356
- * @param array $context
357
- * @param array $backtrace
358
356
*
359
357
* @return bool Returns false when no handling happens so that the PHP engine can handle the error itself
360
358
*
361
359
* @throws \ErrorException When $this->thrownErrors requests so
362
360
*
363
361
* @internal
364
362
*/
365
- public function handleError ($ type , $ message , $ file , $ line, array $ context , array $ backtrace = null )
363
+ public function handleError ($ type , $ message , $ file , $ line )
366
364
{
367
365
$ level = error_reporting () | E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED ;
368
366
$ log = $ this ->loggedErrors & $ type ;
@@ -372,8 +370,17 @@ public function handleError($type, $message, $file, $line, array $context, array
372
370
if (!$ type || (!$ log && !$ throw )) {
373
371
return $ type && $ log ;
374
372
}
373
+ $ scope = $ this ->scopedErrors & $ type ;
375
374
376
- if (isset ($ context ['GLOBALS ' ]) && ($ this ->scopedErrors & $ type )) {
375
+ if (4 < $ numArgs = func_num_args ()) {
376
+ $ context = $ scope ? func_get_arg (4 ) : array ();
377
+ $ backtrace = 5 < $ numArgs ? func_get_arg (5 ) : null ;
378
+ } else {
379
+ $ context = array ();
380
+ $ backtrace = null ;
381
+ }
382
+
383
+ if (isset ($ context ['GLOBALS ' ]) && $ scope ) {
377
384
$ e = $ context ; // Whatever the signature of the method,
378
385
unset($ e ['GLOBALS ' ], $ context ); // $context is always a reference in 5.3
379
386
$ context = $ e ;
@@ -389,7 +396,7 @@ public function handleError($type, $message, $file, $line, array $context, array
389
396
}
390
397
391
398
if ($ throw ) {
392
- if (( $ this -> scopedErrors & $ type ) && class_exists ('Symfony\Component\Debug\Exception\ContextErrorException ' )) {
399
+ if ($ scope && class_exists ('Symfony\Component\Debug\Exception\ContextErrorException ' )) {
393
400
// Checking for class existence is a work around for https://bugs.php.net/42098
394
401
$ throw = new ContextErrorException ($ this ->levels [$ type ].': ' .$ message , 0 , $ type , $ file , $ line , $ context );
395
402
} else {
@@ -420,7 +427,7 @@ public function handleError($type, $message, $file, $line, array $context, array
420
427
$ e = compact ('type ' , 'file ' , 'line ' , 'level ' );
421
428
422
429
if ($ type & $ level ) {
423
- if ($ this -> scopedErrors & $ type ) {
430
+ if ($ scope ) {
424
431
$ e ['scope_vars ' ] = $ context ;
425
432
if ($ trace ) {
426
433
$ e ['stack ' ] = $ backtrace ?: debug_backtrace (DEBUG_BACKTRACE_PROVIDE_OBJECT );
0 commit comments