* 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' );
}
/* @{ */
/**
* Whether the option exists.
+ * @param string $name
* @return bool
*/
public function offsetExists( $name ) {
/**
* Retrieve an option value.
+ * @param string $name
* @return mixed
*/
public function offsetGet( $name ) {
/**
* Set an option to given value.
+ * @param string $name
+ * @param mixed $value
*/
public function offsetSet( $name, $value ) {
$this->setValue( $name, $value );
/**
* Delete the option.
+ * @param string $name
*/
public function offsetUnset( $name ) {
$this->delete( $name );