cakephp: 2.7 - ongoing list of incompatibilities w/ PHP 7

Per tangent in #5602, here is a list of (possible) ongoing incompatibilities between PHP 7 and the 2.7 branch. It would be great if 2.x could handle PHP 7. Feel free to pick one and create a separate issue (?)

Parse error are no longer reported correctly

Per PHP: Backward incompatible changes - Manual, “Many fatal and recoverable fatal errors have been converted to exceptions in PHP 7. These error exceptions inherit from the Error class, which itself implements the Throwable interface (the new base interface all exceptions inherit). […] Parser errors now throw a ParseError object”.

So as soon as a syntax error is encountered, the following happens, which isn’t quite useful:

Uncaught TypeError: Argument 1 passed to ErrorHandler::handleException() must be an instance of Exception, instance of ParseError given in lib\Cake\Error\ErrorHandler.php:116 Stack trace: #0 [internal function]: ErrorHandler::handleException(Object(ParseError)) #1 {main} thrown
File: lib\Cake\Error\ErrorHandler.php
Line: 116

My gut feeling here is set_exception_handler routes both the Exception and Error classes that implements the new Throwable, but since the signature of handleException only accepts an Exception, it breaks. Updating the signature to accept Throwable would work, but this is new to PHP 7. Looking at handleException in 3.0, I see the signature is still the same, so how did you guy solve it?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 21 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Making 2.8 compatible with PHP7 would be indeed great. My gut feeling is that it should be done sooner rather than later, if only to remain competitive with other frameworks that are already compatible with PHP7. I can’t predict the future but the hype around PHP7 performance is real, and I would not be surprised if it was adopted quickly. Whereas I had seen minor improvements switching from 5.5 to 5.6, then 5.6 to 5.7 (say, in the order of 10% faster), the boost provided by PHP7 is at a whole different level. I’ve measured our codebase running almost twice as fast in the vast majority of our test cases. This is nothing to sneeze at.