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 );
139 if ( !is_bool( $settings[self::PARAM_IGNORE_RANGE] ??
false ) ) {
141 . gettype( $settings[self::PARAM_IGNORE_RANGE] );
147 if ( $min !==
null && gettype( $min ) !== $this->valueType ) {
148 $ret[
'issues'][
self::PARAM_MIN] =
"PARAM_MIN must be $this->valueType, got " . gettype( $min );
150 if ( $max !==
null && gettype( $max ) !== $this->valueType ) {
151 $ret[
'issues'][
self::PARAM_MAX] =
"PARAM_MAX must be $this->valueType, got " . gettype( $max );
153 if ( $max2 !==
null && gettype( $max2 ) !== $this->valueType ) {
154 $ret[
'issues'][
self::PARAM_MAX2] =
"PARAM_MAX2 must be $this->valueType, got "
158 if ( $min !==
null && $max !==
null && $min > $max ) {
159 $ret[
'issues'][] =
"PARAM_MIN must be less than or equal to PARAM_MAX, but $min > $max";
161 if ( $max2 !==
null ) {
162 if ( $max ===
null ) {
163 $ret[
'issues'][] =
'PARAM_MAX2 cannot be used without PARAM_MAX';
164 } elseif ( $max2 < $max ) {
165 $ret[
'issues'][] =
"PARAM_MAX2 must be greater than or equal to PARAM_MAX, but $max2 < $max";
176 public function getParamInfo( $name, array $settings, array $options ) {
177 $info = parent::getParamInfo( $name, $settings, $options );
179 $info[
'min'] = $settings[self::PARAM_MIN] ??
null;
180 $info[
'max'] = $settings[self::PARAM_MAX] ??
null;
181 $info[
'highmax'] = $settings[self::PARAM_MAX2] ?? $info[
'max'];
182 if ( $info[
'max'] ===
null || $info[
'highmax'] <= $info[
'max'] ) {
183 unset( $info[
'highmax'] );
193 public function getHelpInfo( $name, array $settings, array $options ) {
194 $info = parent::getHelpInfo( $name, $settings, $options );
199 if ( isset( $settings[self::PARAM_MIN] ) ) {
201 $min =
new ScalarParam( ParamType::NUM, $settings[self::PARAM_MIN] );
203 if ( isset( $settings[self::PARAM_MAX] ) ) {
205 $max = $settings[self::PARAM_MAX];
206 if ( isset( $settings[self::PARAM_MAX2] ) && $settings[self::PARAM_MAX2] > $max &&
207 $this->callbacks->useHighLimits( $options )
209 $max = $settings[self::PARAM_MAX2];
218 $info[self::PARAM_MIN] = MessageValue::new(
"paramvalidator-help-type-number-$msg" )
219 ->params( $isMulti ? 2 : 1, $min, $max );