Basically what you need to do here is to make sure that we continue to correctly process php engine recoverable errors. Typical example of such error is passing an argument to the function that has different type than typehint. Example
function myfunc(stdClass $a) {}
|
myfunc('iamnotaclass');
|
https://3v4l.org/BWIsO
https://3v4l.org/MOJuD
In PHP5 this is an error, that is caught by our default_error_handler() and converted to coding_exception.
In PHP7 it is NOT an error and never gets to the default_error_handler(), it is a special engine exception that goes straight to our default_exception_handler(). However it does not have type Exception, it has type TypeError which extends Throwable.
You need to manually insert the bad code (both normal exception and typeerror) in some places and make sure we process them correctly in the following cases:
- unittests (it correctly reports failure)
- behat (it correctly reports failure)
- delegated transaction (that has to be rolled back on error/exception)
- install/upgrade code - error/exception terminates the upgrade process and adds an entry to the error log
Bonus here is that the errors that were fatal in PHP5 (for example, trying to initiate an instance of non-existing class) become Throwable's in PHP7 and they are caught by the default_exception_handler(). This resolves MDL-46514 for example