我假设这只是由于SPL_Types扩展的相对较新的状态。你会认为这会产生可预测的反应。
$integer = new \SplInt( 5 );
if( false === filter_var( $integer, FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1, 'max_range' => 9 ) ) ) )
{
throw new \InvalidArgumentException( sprintf( 'An integer value of 1 through 9 is required, %s "%s" given.', gettype( $integer ), $integer ) );
}
结果:
PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'An integer value of 1 through 9 is required, object "5" given.'