rfc:catchable-call-to-member-of-non-object
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:catchable-call-to-member-of-non-object [2014/04/27 12:04] – Add link to php.internals announcement thekid | rfc:catchable-call-to-member-of-non-object [2014/04/28 01:02] – thekid | ||
---|---|---|---|
Line 42: | Line 42: | ||
This behavior is consistent with how type hints work. Framework authors can turn this into exceptions if they wish. | This behavior is consistent with how type hints work. Framework authors can turn this into exceptions if they wish. | ||
- | ==== Example ==== | + | ==== Example: Exceptions |
The following error handler could be embedded into frameworks: | The following error handler could be embedded into frameworks: | ||
Line 65: | Line 65: | ||
</ | </ | ||
+ | ==== Example: Without exceptions ==== | ||
+ | This could be a way for people preferring not to use exceptions and instead to exit the script directly, but get a clean stacktrace instead of just the fatal error message: | ||
+ | |||
+ | <PHP> | ||
+ | set_error_handler(function($code, | ||
+ | echo "*** Error #$code: $message\n"; | ||
+ | debug_print_backtrace(); | ||
+ | exit(0xFF); | ||
+ | }, E_RECOVERABLE_ERROR); | ||
+ | |||
+ | $m= new some_db_model(); | ||
+ | $row= $m-> | ||
+ | $row-> | ||
+ | </ | ||
==== Differences from Past RFCs ==== | ==== Differences from Past RFCs ==== |
rfc/catchable-call-to-member-of-non-object.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1