From 1f17cc238afbb30de39dc735d3cbe02f001386f4 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Tue, 10 Sep 2019 14:05:14 +0200 Subject: [PATCH] widget: Improve properties documentation 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 | 24 ++++++++---- includes/widget/ComplexTitleInputWidget.php | 3 +- includes/widget/NamespaceInputWidget.php | 6 ++- includes/widget/SelectWithInputWidget.php | 9 +++-- includes/widget/SizeFilterWidget.php | 11 ++++-- includes/widget/TagMultiselectWidget.php | 43 +++++++++------------ 6 files changed, 54 insertions(+), 42 deletions(-) diff --git a/includes/widget/CheckMatrixWidget.php b/includes/widget/CheckMatrixWidget.php index 06d8095ed4..3ae00ea6a9 100644 --- a/includes/widget/CheckMatrixWidget.php +++ b/includes/widget/CheckMatrixWidget.php @@ -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 diff --git a/includes/widget/ComplexTitleInputWidget.php b/includes/widget/ComplexTitleInputWidget.php index 77370674f5..913816cc52 100644 --- a/includes/widget/ComplexTitleInputWidget.php +++ b/includes/widget/ComplexTitleInputWidget.php @@ -9,7 +9,8 @@ namespace MediaWiki\Widget; * @license MIT */ class ComplexTitleInputWidget extends \OOUI\Widget { - + /** @var array */ + protected $config; protected $namespace = null; protected $title = null; diff --git a/includes/widget/NamespaceInputWidget.php b/includes/widget/NamespaceInputWidget.php index 7802a2a017..a360fb8e91 100644 --- a/includes/widget/NamespaceInputWidget.php +++ b/includes/widget/NamespaceInputWidget.php @@ -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 diff --git a/includes/widget/SelectWithInputWidget.php b/includes/widget/SelectWithInputWidget.php index a946653e6e..a792172b23 100644 --- a/includes/widget/SelectWithInputWidget.php +++ b/includes/widget/SelectWithInputWidget.php @@ -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. diff --git a/includes/widget/SizeFilterWidget.php b/includes/widget/SizeFilterWidget.php index 18c05bf6bc..26935b1214 100644 --- a/includes/widget/SizeFilterWidget.php +++ b/includes/widget/SizeFilterWidget.php @@ -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 diff --git a/includes/widget/TagMultiselectWidget.php b/includes/widget/TagMultiselectWidget.php index 43e184cab2..e96160c715 100644 --- a/includes/widget/TagMultiselectWidget.php +++ b/includes/widget/TagMultiselectWidget.php @@ -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, -- 2.20.1