Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

PHP 7 exceptions not supported #288

Closed
penegiryk opened this issue Jan 26, 2016 · 6 comments
Closed

PHP 7 exceptions not supported #288

penegiryk opened this issue Jan 26, 2016 · 6 comments
Labels

Comments

@penegiryk
Copy link
Contributor

In PHP 7 some errors that were previously fatal are now catchable exceptions (e.g. parse error).
Expressive doesn't support this new type of exceptions because it typehints exceptions to \Exception.

As a result, when using Whoops (which is now in stable 2.0 version and support php 7) and \Error exception is raised, the result is blank page.

I think changes in Stratigility are also necessary to fix this.

@Ocramius Ocramius added the bug label Jan 26, 2016
@weierophinney
Copy link
Member

We don't actually want to catch engine errors; those should be handled entirely separately. We're only interested in catching userland errors.

@penegiryk
Copy link
Contributor Author

This also affects exceptions like TypeError which is thrown quite often when developing php 7 application. Whoops handles this exception but result is not rendered and blank page is shown. Because whoops registers exception handler, error handler and shutdown handler, there is no indication to what happened (blank page). It makes Whoops unusable because on every blank page you have to switch to different error handler to see what's wrong.

@Ocramius
Copy link
Member

Agree with @penegiryk here. Worked a bit with strict types and return types, and a misplaced type currently causes the entire thing to blow up with no output (actually seems to still run till the FinalHandler, instead of crashing). This makes it a major pain-point when working with a PHP7+expressive app...

@weierophinney
Copy link
Member

Thanks for the feedback and use cases, @penegiryk and @Ocramius ! This is indeed something that needs to be handled in Stratigility; the try/catch block is in the Dispatch class of that library. Please open an issue / patch on that project.

@penegiryk
Copy link
Contributor Author

I see there is already a waiting pull request on Stratigility side:
zendframework/zend-stratigility#37

Changes in Expressive are also needed to fix this, currently TemplatedErrorHandler passes \Error exceptions to handleError method instead of handleException.

@penegiryk
Copy link
Contributor Author

@weierophinney I created a pull request which fixes this on Expressive side, but the above pull request to Stratigility is also needed to be merged for this to work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants