@@ -349,20 +349,18 @@ private function reRegister($prev)
349349 /**
350350 * Handles errors by filtering then logging them according to the configured bit fields.
351351 *
352- * @param int $type One of the E_* constants
352+ * @param int $type One of the E_* constants
353353 * @param string $message
354354 * @param string $file
355355 * @param int $line
356- * @param array $context
357- * @param array $backtrace
358356 *
359357 * @return bool Returns false when no handling happens so that the PHP engine can handle the error itself
360358 *
361359 * @throws \ErrorException When $this->thrownErrors requests so
362360 *
363361 * @internal
364362 */
365- public function handleError ($ type , $ message , $ file , $ line, array $ context , array $ backtrace = null )
363+ public function handleError ($ type , $ message , $ file , $ line )
366364 {
367365 $ level = error_reporting () | E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED ;
368366 $ log = $ this ->loggedErrors & $ type ;
@@ -372,8 +370,17 @@ public function handleError($type, $message, $file, $line, array $context, array
372370 if (!$ type || (!$ log && !$ throw )) {
373371 return $ type && $ log ;
374372 }
373+ $ scope = $ this ->scopedErrors & $ type ;
375374
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 ; // defined on HHVM
378+ } else {
379+ $ context = array ();
380+ $ backtrace = null ;
381+ }
382+
383+ if (isset ($ context ['GLOBALS ' ]) && $ scope ) {
377384 $ e = $ context ; // Whatever the signature of the method,
378385 unset($ e ['GLOBALS ' ], $ context ); // $context is always a reference in 5.3
379386 $ context = $ e ;
@@ -389,7 +396,7 @@ public function handleError($type, $message, $file, $line, array $context, array
389396 }
390397
391398 if ($ throw ) {
392- if (( $ this -> scopedErrors & $ type ) && class_exists ('Symfony\Component\Debug\Exception\ContextErrorException ' )) {
399+ if ($ scope && class_exists ('Symfony\Component\Debug\Exception\ContextErrorException ' )) {
393400 // Checking for class existence is a work around for https://bugs.php.net/42098
394401 $ throw = new ContextErrorException ($ this ->levels [$ type ].': ' .$ message , 0 , $ type , $ file , $ line , $ context );
395402 } else {
@@ -420,7 +427,7 @@ public function handleError($type, $message, $file, $line, array $context, array
420427 $ e = compact ('type ' , 'file ' , 'line ' , 'level ' );
421428
422429 if ($ type & $ level ) {
423- if ($ this -> scopedErrors & $ type ) {
430+ if ($ scope ) {
424431 $ e ['scope_vars ' ] = $ context ;
425432 if ($ trace ) {
426433 $ e ['stack ' ] = $ backtrace ?: debug_backtrace (DEBUG_BACKTRACE_PROVIDE_OBJECT );
0 commit comments