note 84436 modified in language.oop5.typehinting by felipe
| From: | felipe@php.net | Date: | Fri, 18 Jul 2008 00:41:28 +0000 |
| Subject: | note 84436 modified in language.oop5.typehinting by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141645@lists.php.net to get a copy of this message | ||
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;
}
?>
--was--
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.
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;
}
http://php.net/manual/en/language.oop5.typehinting.php