X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FFormOptions.php;h=725a512980937c3b51c1c400711165e797526ce6;hp=c91c336762f645330fa0180d9b5297262982441e;hb=7874fc4bec845ad92960b07e969c65f3c3fe74f2;hpb=92e31275a4f7117a4465b8886dfeca6dcb37351e diff --git a/includes/FormOptions.php b/includes/FormOptions.php index c91c336762..725a512980 100644 --- a/includes/FormOptions.php +++ b/includes/FormOptions.php @@ -52,6 +52,9 @@ class FormOptions implements ArrayAccess { * This is useful for the namespace selector. */ const INTNULL = 3; + /** Array type, maps guessType() to WebRequest::getArray() + * @since 1.29 */ + const ARR = 5; /* @} */ /** @@ -64,7 +67,7 @@ class FormOptions implements ArrayAccess { * consumeValue() or consumeValues() * - 'type' - one of the type constants (but never AUTO) */ - protected $options = array(); + protected $options = []; # Setting up @@ -76,7 +79,7 @@ class FormOptions implements ArrayAccess { * @param int $type One of the type constants (optional, defaults to AUTO) */ public function add( $name, $default, $type = self::AUTO ) { - $option = array(); + $option = []; $option['default'] = $default; $option['value'] = null; $option['consumed'] = false; @@ -120,6 +123,8 @@ class FormOptions implements ArrayAccess { return self::FLOAT; } elseif ( is_string( $data ) ) { return self::STRING; + } elseif ( is_array( $data ) ) { + return self::ARR; } else { throw new MWException( 'Unsupported datatype' ); } @@ -228,7 +233,7 @@ class FormOptions implements ArrayAccess { * @return array Array of option values, or the default values if they are null */ public function consumeValues( $names ) { - $out = array(); + $out = []; foreach ( $names as $name ) { $this->validateName( $name, true ); @@ -278,7 +283,7 @@ class FormOptions implements ArrayAccess { * @return array */ public function getUnconsumedValues( $all = false ) { - $values = array(); + $values = []; foreach ( $this->options as $name => $data ) { if ( !$data['consumed'] ) { @@ -296,7 +301,7 @@ class FormOptions implements ArrayAccess { * @return array */ public function getChangedValues() { - $values = array(); + $values = []; foreach ( $this->options as $name => $data ) { if ( $data['value'] !== null ) { @@ -312,7 +317,7 @@ class FormOptions implements ArrayAccess { * @return array */ public function getAllValues() { - $values = array(); + $values = []; foreach ( $this->options as $name => $data ) { $values[$name] = $this->getValueReal( $data ); @@ -358,6 +363,9 @@ class FormOptions implements ArrayAccess { case self::INTNULL: $value = $r->getIntOrNull( $name ); break; + case self::ARR: + $value = $r->getArray( $name ); + break; default: throw new MWException( 'Unsupported datatype' ); } @@ -370,7 +378,7 @@ class FormOptions implements ArrayAccess { /** @name ArrayAccess functions * These functions implement the ArrayAccess PHP interface. - * @see http://php.net/manual/en/class.arrayaccess.php + * @see https://secure.php.net/manual/en/class.arrayaccess.php */ /* @{ */ /**