Re: Throwable and Error exceptions break existing PHP 5.x code
| From: | Umberto Salsi | Date: | Tue, 12 Jan 2016 10:59:35 +0000 |
| Subject: | Re: Throwable and Error exceptions break existing PHP 5.x code | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-90540@lists.php.net to get a copy of this message | ||
giovanni@giacobbi.net (Giovanni Giacobbi) wrote:
> Also think about the possible upcoming changes to the Throwable definition,
> I saw in another thread that you are thinking about dropping
> Throwable::getCode(), which would make things even worse, in case of
> something as simple as:
> set_exception_handler(function($e) { print $e->getCode(); });
Don't be afraid, Giovanni, it was only my proposal to avoid another
function returning "mixed", because just this was the issue: while in
PHP 5 that method is expected to return a number, under PHP 7 it may now
return anything, possibly something that you cannot pass to the "print"
function whitout causing another error (printing an array generates a
E_NOTICE an then only displays a bare "Array"); this means that you code
above not only is useless (you are printing the "code" of what?) but it is
also unsafe (it may generate another error, which is not a good thing).
Regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it