widget: Improve properties documentation
authorDaimona Eaytoy <daimona.wiki@gmail.com>
Tue, 10 Sep 2019 12:05:14 +0000 (14:05 +0200)
committerDaimona Eaytoy <daimona.wiki@gmail.com>
Tue, 10 Sep 2019 12:05:14 +0000 (14:05 +0200)
Explicitly declare all dynamic properties. Add docblocks for several
props. Remove the defaults when they're already set in the constructor.
Make TagMultiselectWidget use ?? like other widgets.

Change-Id: I889bf6f9e1bbe381f5bffb8ce1370c9e2e863520

includes/widget/CheckMatrixWidget.php
includes/widget/ComplexTitleInputWidget.php
includes/widget/NamespaceInputWidget.php
includes/widget/SelectWithInputWidget.php
includes/widget/SizeFilterWidget.php
includes/widget/TagMultiselectWidget.php

index 06d8095..3ae00ea 100644 (file)
@@ -9,14 +9,22 @@ namespace MediaWiki\Widget;
  * @license MIT
  */
 class CheckMatrixWidget extends \OOUI\Widget {
-
-       protected $name = '';
-       protected $columns = [];
-       protected $rows = [];
-       protected $tooltips = [];
-       protected $values = [];
-       protected $forcedOn = [];
-       protected $forcedOff = [];
+       /** @var string|null */
+       protected $name;
+       /** @var string|null */
+       protected $id;
+       /** @var array */
+       protected $columns;
+       /** @var array */
+       protected $rows;
+       /** @var array */
+       protected $tooltips;
+       /** @var array */
+       protected $values;
+       /** @var array */
+       protected $forcedOn;
+       /** @var array */
+       protected $forcedOff;
 
        /**
         * Operates similarly to MultiSelectWidget, but instead of using an array of
index 7737067..913816c 100644 (file)
@@ -9,7 +9,8 @@ namespace MediaWiki\Widget;
  * @license MIT
  */
 class ComplexTitleInputWidget extends \OOUI\Widget {
-
+       /** @var array */
+       protected $config;
        protected $namespace = null;
        protected $title = null;
 
index 7802a2a..a360fb8 100644 (file)
@@ -9,8 +9,10 @@ namespace MediaWiki\Widget;
  * @license MIT
  */
 class NamespaceInputWidget extends \OOUI\DropdownInputWidget {
-
-       protected $includeAllValue = null;
+       /** @var string */
+       protected $includeAllValue;
+       /** @var int[] */
+       protected $exclude;
 
        /**
         * @param array $config Configuration options
index a946653..a792172 100644 (file)
@@ -12,9 +12,12 @@ use OOUI\TextInputWidget;
  * @license MIT
  */
 class SelectWithInputWidget extends \OOUI\Widget {
-
-       protected $textinput = null;
-       protected $dropdowninput = null;
+       /** @var array */
+       protected $config;
+       /** @var TextInputWidget */
+       protected $textinput;
+       /** @var DropdownInputWidget */
+       protected $dropdowninput;
 
        /**
         * A version of the SelectWithInputWidget, with `or` set to true.
index 18c05bf..26935b1 100644 (file)
@@ -13,9 +13,14 @@ use \OOUI\LabelWidget;
  * @license MIT
  */
 class SizeFilterWidget extends \OOUI\Widget {
-
-       protected $radioselectinput = null;
-       protected $textinput = null;
+       /** @var array */
+       protected $config;
+       /** @var LabelWidget */
+       protected $label;
+       /** @var RadioSelectInputWidget */
+       protected $radioselectinput;
+       /** @var TextInputWidget */
+       protected $textinput;
 
        /**
         * RadioSelectInputWidget and a TextInputWidget to set minimum or maximum byte size
index 43e184c..e96160c 100644 (file)
@@ -12,41 +12,34 @@ use OOUI\MultilineTextInputWidget;
  * @license MIT
  */
 abstract class TagMultiselectWidget extends \OOUI\Widget {
-
-       protected $selectedArray = [];
-       protected $inputName = null;
-       protected $inputPlaceholder = null;
-       protected $tagLimit = null;
+       /** @var array */
+       protected $selectedArray;
+       /** @var string|null */
+       protected $inputName;
+       /** @var string|null */
+       protected $inputPlaceholder;
+       /** @var array */
+       protected $input;
+       /** @var int|null */
+       protected $tagLimit;
 
        /**
         * @param array $config Configuration options
         *   - array $config['default'] Array of items to use as preset data
-        *   - array $config['name'] Name attribute (used in forms)
-        *   - array $config['placeholder'] Placeholder message for input
+        *   - string $config['name'] Name attribute (used in forms)
+        *   - string $config['placeholder'] Placeholder message for input
         *   - array $config['input'] Config options for the input widget
-        *   - number $config['tagLimit'] Maximum number of selected items
+        *   - int $config['tagLimit'] Maximum number of selected items
         */
        public function __construct( array $config = [] ) {
                parent::__construct( $config );
 
                // Properties
-               if ( isset( $config['default'] ) ) {
-                       $this->selectedArray = $config['default'];
-               }
-               if ( isset( $config['name'] ) ) {
-                       $this->inputName = $config['name'];
-               }
-               if ( isset( $config['placeholder'] ) ) {
-                       $this->inputPlaceholder = $config['placeholder'];
-               }
-               if ( isset( $config['input'] ) ) {
-                       $this->input = $config['input'];
-               } else {
-                       $this->input = [];
-               }
-               if ( isset( $config['tagLimit'] ) ) {
-                       $this->tagLimit = $config['tagLimit'];
-               }
+               $this->selectedArray = $config['default'] ?? [];
+               $this->inputName = $config['name'] ?? null;
+               $this->inputPlaceholder = $config['placeholder'] ?? null;
+               $this->input = $config['input'] ?? [];
+               $this->tagLimit = $config['tagLimit'] ?? null;
 
                $textarea = new MultilineTextInputWidget( array_merge( [
                        'name' => $this->inputName,