* This is useful for the namespace selector.
*/
const INTNULL = 3;
+ /** Array type, maps guessType() to WebRequest::getArray()
+ * @since 1.29 */
+ const ARR = 5;
/* @} */
/**
* consumeValue() or consumeValues()
* - 'type' - one of the type constants (but never AUTO)
*/
- protected $options = array();
+ protected $options = [];
# Setting up
* @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;
return self::FLOAT;
} elseif ( is_string( $data ) ) {
return self::STRING;
+ } elseif ( is_array( $data ) ) {
+ return self::ARR;
} else {
throw new MWException( 'Unsupported datatype' );
}
* @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 );
* @return array
*/
public function getUnconsumedValues( $all = false ) {
- $values = array();
+ $values = [];
foreach ( $this->options as $name => $data ) {
if ( !$data['consumed'] ) {
* @return array
*/
public function getChangedValues() {
- $values = array();
+ $values = [];
foreach ( $this->options as $name => $data ) {
if ( $data['value'] !== null ) {
* @return array
*/
public function getAllValues() {
- $values = array();
+ $values = [];
foreach ( $this->options as $name => $data ) {
$values[$name] = $this->getValueReal( $data );
case self::INTNULL:
$value = $r->getIntOrNull( $name );
break;
+ case self::ARR:
+ $value = $r->getArray( $name );
+ break;
default:
throw new MWException( 'Unsupported datatype' );
}
/** @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
*/
/* @{ */
/**