$max ) { if ( $max2 !== null && $this->callbacks->useHighLimits( $options ) ) { if ( $ret > $max2 ) { $err = 'abovehighmaximum'; $ret = $max2; } } else { $err = 'abovemaximum'; $ret = $max; } } if ( $err !== null ) { $ex = new ValidationException( $name, $value, $settings, $err, [ 'min' => $min === null ? '' : $min, 'max' => $max === null ? '' : $max, 'max2' => $max2 === null ? '' : $max2, ] ); if ( empty( $settings[self::PARAM_IGNORE_RANGE] ) ) { throw $ex; } $this->callbacks->recordCondition( $ex, $options ); } return $ret; } public function normalizeSettings( array $settings ) { if ( !isset( $settings[self::PARAM_MAX] ) ) { unset( $settings[self::PARAM_MAX2] ); } if ( isset( $settings[self::PARAM_MAX2] ) && isset( $settings[self::PARAM_MAX] ) && $settings[self::PARAM_MAX2] < $settings[self::PARAM_MAX] ) { $settings[self::PARAM_MAX2] = $settings[self::PARAM_MAX]; } return parent::normalizeSettings( $settings ); } public function describeSettings( $name, array $settings, array $options ) { $info = parent::describeSettings( $name, $settings, $options ); $min = $settings[self::PARAM_MIN] ?? ''; $max = $settings[self::PARAM_MAX] ?? ''; $max2 = $settings[self::PARAM_MAX2] ?? ''; if ( $max === '' || $max2 !== '' && $max2 <= $max ) { $max2 = ''; } if ( empty( $options['compact'] ) ) { if ( $min !== '' ) { $info['min'] = $min; } if ( $max !== '' ) { $info['max'] = $max; } if ( $max2 !== '' ) { $info['max2'] = $max2; } } else { $key = ''; if ( $min !== '' ) { $key = 'min'; } if ( $max2 !== '' ) { $key .= 'max2'; } elseif ( $max !== '' ) { $key .= 'max'; } if ( $key !== '' ) { $info[$key] = [ 'min' => $min, 'max' => $max, 'max2' => $max2 ]; } } return $info; } }