34 public function validate( $name, $value, array $settings, array $options ) {
35 if ( is_float( $value ) ) {
37 } elseif ( is_int( $value ) ) {
39 } elseif ( $options[ self::OPT_ENFORCE_JSON_TYPES ] ??
false ) {
42 ->params( gettype( $value ) ),
43 $name, $value, $settings, $options
46 if ( !preg_match(
'/^[+-]?(?:\d*\.)?\d+(?:[eE][+-]?\d+)?$/D', $value ) ) {
48 $this->
fatal(
'badfloat', $name, $value, $settings, $options );
54 if ( !is_finite( $ret ) ) {
55 $this->
fatal(
'badfloat-notfinite', $name, $value, $settings, $options );
58 return $this->
checkRange( $ret, $name, $value, $settings, $options );
61 public function stringifyValue( $name, $value, array $settings, array $options ) {
63 $digits = PHP_FLOAT_DIG;
64 return sprintf(
"%.{$digits}g", $value );
67 public function getHelpInfo( $name, array $settings, array $options ) {
68 $info = parent::getHelpInfo( $name, $settings, $options );