Merge "Move up devunt's name to Developers"
[lhc/web/wiklou.git] / includes / api / ApiOptions.php
index 7a90527..8bfe447 100644 (file)
@@ -45,7 +45,7 @@ class ApiOptions extends ApiBase {
                $changed = false;
 
                if ( isset( $params['optionvalue'] ) && !isset( $params['optionname'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'optionname' ) );
+                       $this->dieUsageMsg( [ 'missingparam', 'optionname' ] );
                }
 
                // Load the user from the master to reduce CAS errors on double post (T95839)
@@ -59,7 +59,7 @@ class ApiOptions extends ApiBase {
                        $changed = true;
                }
 
-               $changes = array();
+               $changes = [];
                if ( count( $params['change'] ) ) {
                        foreach ( $params['change'] as $entry ) {
                                $array = explode( '=', $entry, 2 );
@@ -84,10 +84,9 @@ class ApiOptions extends ApiBase {
                                        // Regular option.
                                        if ( $htmlForm === null ) {
                                                // We need a dummy HTMLForm for the validate callback...
-                                               $htmlForm = new HTMLForm( array(), $this );
+                                               $htmlForm = new HTMLForm( [], $this );
                                        }
-                                       $field = HTMLForm::loadInputFromParameters( $key, $prefs[$key] );
-                                       $field->mParent = $htmlForm;
+                                       $field = HTMLForm::loadInputFromParameters( $key, $prefs[$key], $htmlForm );
                                        $validation = $field->validate( $value, $user->getOptions() );
                                        break;
                                case 'registered-multiselect':
@@ -99,19 +98,19 @@ class ApiOptions extends ApiBase {
                                case 'userjs':
                                        // Allow non-default preferences prefixed with 'userjs-', to be set by user scripts
                                        if ( strlen( $key ) > 255 ) {
-                                               $validation = "key too long (no more than 255 bytes allowed)";
-                                       } elseif ( preg_match( "/[^a-zA-Z0-9_-]/", $key ) !== 0 ) {
-                                               $validation = "invalid key (only a-z, A-Z, 0-9, _, - allowed)";
+                                               $validation = 'key too long (no more than 255 bytes allowed)';
+                                       } elseif ( preg_match( '/[^a-zA-Z0-9_-]/', $key ) !== 0 ) {
+                                               $validation = 'invalid key (only a-z, A-Z, 0-9, _, - allowed)';
                                        } else {
                                                $validation = true;
                                        }
                                        break;
                                case 'special':
-                                       $validation = "cannot be set by this module";
+                                       $validation = 'cannot be set by this module';
                                        break;
                                case 'unused':
                                default:
-                                       $validation = "not a valid preference";
+                                       $validation = 'not a valid preference';
                                        break;
                        }
                        if ( $validation === true ) {
@@ -142,23 +141,23 @@ class ApiOptions extends ApiBase {
                $optionKinds = User::listOptionKinds();
                $optionKinds[] = 'all';
 
-               return array(
+               return [
                        'reset' => false,
-                       'resetkinds' => array(
+                       'resetkinds' => [
                                ApiBase::PARAM_TYPE => $optionKinds,
                                ApiBase::PARAM_DFLT => 'all',
                                ApiBase::PARAM_ISMULTI => true
-                       ),
-                       'change' => array(
+                       ],
+                       'change' => [
                                ApiBase::PARAM_ISMULTI => true,
-                       ),
-                       'optionname' => array(
+                       ],
+                       'optionname' => [
                                ApiBase::PARAM_TYPE => 'string',
-                       ),
-                       'optionvalue' => array(
+                       ],
+                       'optionvalue' => [
                                ApiBase::PARAM_TYPE => 'string',
-                       ),
-               );
+                       ],
+               ];
        }
 
        public function needsToken() {
@@ -170,7 +169,7 @@ class ApiOptions extends ApiBase {
        }
 
        protected function getExamplesMessages() {
-               return array(
+               return [
                        'action=options&reset=&token=123ABC'
                                => 'apihelp-options-example-reset',
                        'action=options&change=skin=vector|hideminor=1&token=123ABC'
@@ -178,6 +177,6 @@ class ApiOptions extends ApiBase {
                        'action=options&reset=&change=skin=monobook&optionname=nickname&' .
                                'optionvalue=[[User:Beau|Beau]]%20([[User_talk:Beau|talk]])&token=123ABC'
                                => 'apihelp-options-example-complex',
-               );
+               ];
        }
 }