note 84436 deleted from language.oop5.typehinting by nikic
| From: | nikic@php.net | Date: | Sun, 01 Nov 2020 21:50:53 +0000 |
| Subject: | note 84436 deleted from language.oop5.typehinting by nikic | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215690@lists.php.net to get a copy of this message | ||
Note Submitter: marcus at ignorethis netweblogic dot com
----
Love the typehint object Daniel. Great effort!
However, it still throws catchable fatal errors, which is not what I want, so I added one line to
handleTypehint() so it throws an Exception.
<?php
public static function handleTypehint($ErrLevel, $ErrMessage) {
if ($ErrLevel == E_RECOVERABLE_ERROR) {
if (preg_match ( TYPEHINT_PCRE, $ErrMessage, $ErrMatches )) {
list ( $ErrMatch, $ThArgIndex, $ThClass, $ThFunction, $ThHint, $ThType ) = $ErrMatches;
if (isset ( self::$Typehints [$ThHint] )) {
$ThBacktrace = debug_backtrace ();
$ThArgValue = NULL;
if (self::getTypehintedArgument ( $ThBacktrace, $ThFunction, $ThArgIndex, $ThArgValue )) {
if (call_user_func ( self::$Typehints [$ThHint], $ThArgValue )) {
return TRUE;
}
}
}
throw new Exception($ErrMessage);
}
}
return FALSE;
}
?>