Skip to content

Instantly share code, notes, and snippets.

@code-poel
Last active December 19, 2015 12:49
Show Gist options
  • Save code-poel/5957719 to your computer and use it in GitHub Desktop.
Save code-poel/5957719 to your computer and use it in GitHub Desktop.
Annoying PHP quirk.
<?php
$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 ) );
}
// Result:
// PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message
// 'An integer value of 1 through 9 is required, object "5" given.' in /SplInt.php:7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment