64 protected function checkRange( $value, $name, $origValue, array $settings, array $options ) {
70 if ( $min !==
null && $value < $min ) {
73 } elseif ( $max1 !==
null && $value > $max1 ) {
74 if ( $max2 > $max1 && $this->callbacks->useHighLimits( $options ) ) {
75 if ( $value > $max2 ) {
86 if ( $min !==
null ) {
89 if ( $max1 !==
null ) {
92 $max = $max2 !==
null && $max2 > $max1 && $this->callbacks->useHighLimits( $options )
100 ], $what )->numParams( $min ??
'', $max ??
'' ),
101 $name, $origValue, $settings, $options,
102 empty( $settings[self::PARAM_IGNORE_RANGE] )
114 if ( !isset( $settings[self::PARAM_MAX] ) ) {
115 unset( $settings[self::PARAM_MAX2] );
118 if ( isset( $settings[self::PARAM_MAX2] ) && isset( $settings[self::PARAM_MAX] ) &&
119 $settings[self::PARAM_MAX2] < $settings[self::PARAM_MAX]
124 return parent::normalizeSettings( $settings );
131 public function checkSettings(
string $name, $settings, array $options, array $ret ): array {
132 $ret = parent::
checkSettings( $name, $settings, $options, $ret );
134 $ret[
'allowedKeys'] = array_merge( $ret[
'allowedKeys'], [
135 self::PARAM_IGNORE_RANGE, self::PARAM_MIN, self::PARAM_MAX, self::PARAM_MAX2,
138 if ( !is_bool( $settings[self::PARAM_IGNORE_RANGE] ??
false ) ) {
140 . gettype( $settings[self::PARAM_IGNORE_RANGE] );
146 if ( $min !==
null && gettype( $min ) !== $this->valueType ) {
147 $ret[
'issues'][
self::PARAM_MIN] =
"PARAM_MIN must be $this->valueType, got " . gettype( $min );
149 if ( $max !==
null && gettype( $max ) !== $this->valueType ) {
150 $ret[
'issues'][
self::PARAM_MAX] =
"PARAM_MAX must be $this->valueType, got " . gettype( $max );
152 if ( $max2 !==
null && gettype( $max2 ) !== $this->valueType ) {
153 $ret[
'issues'][
self::PARAM_MAX2] =
"PARAM_MAX2 must be $this->valueType, got "
157 if ( $min !==
null && $max !==
null && $min > $max ) {
158 $ret[
'issues'][] =
"PARAM_MIN must be less than or equal to PARAM_MAX, but $min > $max";
160 if ( $max2 !==
null ) {
161 if ( $max ===
null ) {
162 $ret[
'issues'][] =
'PARAM_MAX2 cannot be used without PARAM_MAX';
163 } elseif ( $max2 < $max ) {
164 $ret[
'issues'][] =
"PARAM_MAX2 must be greater than or equal to PARAM_MAX, but $max2 < $max";
175 public function getParamInfo( $name, array $settings, array $options ) {
176 $info = parent::getParamInfo( $name, $settings, $options );
178 $info[
'min'] = $settings[self::PARAM_MIN] ??
null;
179 $info[
'max'] = $settings[self::PARAM_MAX] ??
null;
180 $info[
'highmax'] = $settings[self::PARAM_MAX2] ?? $info[
'max'];
181 if ( $info[
'max'] ===
null || $info[
'highmax'] <= $info[
'max'] ) {
182 unset( $info[
'highmax'] );
192 public function getHelpInfo( $name, array $settings, array $options ) {
193 $info = parent::getHelpInfo( $name, $settings, $options );
198 if ( isset( $settings[self::PARAM_MIN] ) ) {
202 if ( isset( $settings[self::PARAM_MAX] ) ) {
204 $max = $settings[self::PARAM_MAX];
205 if ( isset( $settings[self::PARAM_MAX2] ) && $settings[self::PARAM_MAX2] > $max &&
206 $this->callbacks->useHighLimits( $options )
208 $max = $settings[self::PARAM_MAX2];
217 $info[self::PARAM_MIN] = MessageValue::new(
"paramvalidator-help-type-number-$msg" )
218 ->params( $isMulti ? 2 : 1, $min, $max );