I have registered an own errorhandler looking like that:
namespace framework;
class Error {
static $arHintsShorts = array('integer'=>'int', 'double'=>'float');
public static function execHandler( $iErrno, $sErrstr, $sErrfile, $iErrline ) {
if ( preg_match('/Argument (\d)+ passed to (.+) must be an instance of (?<hint>.+), (?<given>.+) given/i',
$sErrstr, $arMatches ) )
{
$sGiven = $arMatches[ 'given' ] ;
$arHints = explode( '\\', $arMatches[ 'hint' ] );
$sHint = strtolower( end($arHints) );
if (isset(self::$arHintsShorts[$sGiven])) {
$sGiven = self::$arHintsShorts[$sGiven];
}
if ( $sHint == strtolower($sGiven) || $sHint == 'mixed' || ($sHint == 'float' && $sGiven == 'int')) {
return TRUE;
} else {
if (self::$oLog != null) {
self::$oLog->error($sErrstr . '(' . $iErrno . ', ' . $sErrfile . ', ' . $iErrline . ')');
}
throw new \UnexpectedValueException($sErrstr, $iErrno);
}
}
}
}
set_error_handler(array('framework\error', 'execHandler'), error_reporting());
It handles all primitive types although in namespaced classes.