2

Seems i found some bug in to php7.0.3 but i'm not sure probably issue is at my side so i decided to write here first

i have recently updated my server php version to to php7.0.3, and of course there was errors about deprecated method etc i was fixing them one by one till i come to this one

Uncaught TypeError: Argument 1 passed to Debug::_exceptionHandler() must be an instance of Exception, instance of Error given in SomePath\Debug.php:518 Stack trace: #0 [internal function]: Debug::_exceptionHandler(Object(Error)) #1 {main} thrown

i checked Debug class and found there set_exception_handler and set_error_handler calls in function enable()

public static function enable( ..some params.. ){
    ...
    set_exception_handler(array(__CLASS__, '_exceptionHandler'));
    set_error_handler(array(__CLASS__, '_errorHandler'));
}

// where _exceptionHandler function defined as
public static function _exceptionHandler(Exception $exception)
{ ... }

// and _errorHandler defined as
public static function _errorHandler($severity, $message, $file, $line, $context)
{ ... }

Actually error is clear for me it tells that it can't pass Error type object to _exceptionHandler as it excepts Exception type, but the Question is Why it trying to pass it to _exceptionHandler instead _errorHandler as it also defined ? is it bug or i'm missing something in definition of error and exception handlers ?

Note: i tried to play with set_error_handler pass it as second argument E_ALL etc but noting helps...

I also got error which was thrown and should be handled by _errorHandler but instead handled by _exceptionHandler was

Uncaught Error: Call to undefined function set_magic_quotes_runtime() in SomePath...

Can someone help me with this ?

Thanks

1 Answer 1

4

The exception hierarchy in PHP 7 has changed, if you take a look at the manual page for set_exception_handler you will notice:

Since PHP 7, most errors are reported by throwing Error exceptions, which will be caught by the handler as well. Both Error and Exception implements the Throwable interface. This is the handler signature since PHP 7:

void handler ( Throwable $ex );

Details of the changes to exception hierarchy in PHP 7 can be found here.

Sign up to request clarification or add additional context in comments.

1 Comment

Actually i checked set_exception_handler page and did noticed that message, now i got it and understand the reason thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.