26 public function validate( $name, $value, array $settings, array $options ) {
27 if ( is_int( $value ) ) {
29 } elseif ( is_float( $value ) ) {
34 $ret = intval( $value );
35 if ( $ret - $value !== 0.0 ) {
38 ->params( gettype( $value ) ),
39 $name, $value, $settings, $options
42 } elseif ( $options[ self::OPT_ENFORCE_JSON_TYPES ] ??
false ) {
45 ->params( gettype( $value ) ),
46 $name, $value, $settings, $options
49 if ( is_array( $value ) || !preg_match(
'/^[+-]?\d+$/D', $value ) ) {
50 $this->
fatal(
'badinteger', $name, $value, $settings, $options );
52 $ret = intval( $value, 10 );
57 if ( $ret === PHP_INT_MAX || $ret === PHP_INT_MIN ) {
58 $tmp = ( $ret < 0 ?
'-' :
'' ) . ltrim( $value,
'-0' );
59 if ( $tmp !== (
string)$ret ) {
60 $this->
failure(
'badinteger', $name, $value, $settings, $options );
64 return $this->
checkRange( $ret, $name, $value, $settings, $options );
68 public function getHelpInfo( $name, array $settings, array $options ) {
69 $info = parent::getHelpInfo( $name, $settings, $options );
78 public function stringifyValue( $name, $value, array $settings, array $options ) {
79 if ( !is_array( $value ) ) {
80 return parent::stringifyValue( $name, $value, $settings, $options );