[Tiki-devel] Is this why Exceptions are mostly dead in tiki? And they must be changed with Trowable?
aris002 via TikiWiki-devel <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi again,
Is this why Exceptions are mostly dead in tiki? And they must be changed with Trowable?
Writing Code to Support PHP 5.x and 7 Exceptions
To catch any exception in PHP 5.x and 7 with the same code, multiple catch blocks can be used, catching Throwable first, then Exception. Once PHP 5.x support is no longer needed, the block catching Exception can be removed.
try {
// Code that may throw an Exception or Error.
} catch (Throwable $t) {
// Executed only in PHP 7, will not match in PHP 5.x
} catch (Exception $e) {
// Executed only in PHP 5.x, will not be reached in PHP 7
}Writing catch-all block compatible with both PHP 5.x and 7
Unfortunately, type declarations on functions that handle exceptions are not as easy to fix. If Exception is used as a type declaration on a function parameter, the type declaration will need to be removed if the function could be called with an instance of Error. When PHP 5.x support is not required, the type declaration can be restored as Throwable.
Thanks,Aris
_______________________________________________
TikiWiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel