32 $this->nsInfo = $nsInfo;
36 public function validate( $name, $value, array $settings, array $options ) {
37 if ( !is_int( $value ) && preg_match(
'/^[+-]?\d+$/D', $value ) ) {
42 return parent::validate( $name, $value, $settings, $options );
46 public function getEnumValues( $name, array $settings, array $options ) {
47 $namespaces = $this->nsInfo->getValidNamespaces();
49 if ( is_array( $extra ) && $extra !== [] ) {
50 $namespaces = array_merge( $namespaces, $extra );
59 if ( !empty( $settings[ParamValidator::PARAM_ISMULTI] ) ) {
60 $settings[ParamValidator::PARAM_ALL] =
true;
62 return parent::normalizeSettings( $settings );
66 public function checkSettings(
string $name, $settings, array $options, array $ret ): array {
67 $ret = parent::
checkSettings( $name, $settings, $options, $ret );
71 if ( !empty( $settings[ParamValidator::PARAM_ISMULTI] ) &&
72 ( $settings[ParamValidator::PARAM_ALL] ??
true ) !==
true &&
73 !isset( $ret[
'issues'][ParamValidator::PARAM_ALL] )
75 $ret[
'issues'][ParamValidator::PARAM_ALL] =
76 'PARAM_ALL cannot be false or a string for namespace-type parameters';
80 if ( !is_array( $ns ) ) {
81 $type = gettype( $ns );
82 } elseif ( $ns === [] ) {
85 $types = array_unique( array_map(
'gettype', $ns ) );
86 $type = implode(
'|', $types );
87 $type = count( $types ) > 1 ?
"($type)[]" :
"{$type}[]";
89 if ( $type !==
'integer[]' ) {
91 "PARAM_EXTRA_NAMESPACES must be an integer[], got $type";
98 public function getParamInfo( $name, array $settings, array $options ) {
99 $info = parent::getParamInfo( $name, $settings, $options );
101 $info[
'type'] =
'namespace';
102 $extra = $settings[self::PARAM_EXTRA_NAMESPACES] ?? [];
103 if ( is_array( $extra ) && $extra !== [] ) {
104 $info[
'extranamespaces'] = array_values( $extra );
105 if ( isset( $options[
'module'] ) ) {
107 ApiResult::setIndexedTagName( $info[
'extranamespaces'],
'ns' );