Adjust type hints in htmlform related classes
authorUmherirrender <umherirrender_de.wp@web.de>
Tue, 18 Jun 2019 20:16:31 +0000 (22:16 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Fri, 5 Jul 2019 18:11:53 +0000 (18:11 +0000)
The return type of HTMLFormField::loadDataFromRequest to mixed
Some sub classes returning arrays or bools, not everytime strings

HTMLCheckField is working with arrays, so also allow array on getTableRow

Change-Id: I076feea76d8e296f27c8a9fb4cbd9368584ba187

includes/htmlform/HTMLForm.php
includes/htmlform/HTMLFormField.php
includes/htmlform/fields/HTMLCheckMatrix.php
includes/htmlform/fields/HTMLFormFieldWithButton.php

index d071478..86f9dba 100644 (file)
@@ -185,6 +185,7 @@ class HTMLForm extends ContextSource {
        protected $mFieldTree;
        protected $mShowReset = false;
        protected $mShowSubmit = true;
+       /** @var string[] */
        protected $mSubmitFlags = [ 'primary', 'progressive' ];
        protected $mShowCancel = false;
        protected $mCancelTarget;
index ff805d8..590b9e7 100644 (file)
@@ -367,7 +367,7 @@ abstract class HTMLFormField {
         * or the input's default value if it has not been set.
         *
         * @param WebRequest $request
-        * @return string The value
+        * @return mixed The value
         */
        public function loadDataFromRequest( $request ) {
                if ( $request->getCheck( $this->mName ) ) {
@@ -653,7 +653,7 @@ abstract class HTMLFormField {
 
        /**
         * Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output.
-        * @param string $inputField
+        * @param OOUI\Widget $inputField
         * @param array $config
         * @return OOUI\FieldLayout|OOUI\ActionFieldLayout
         */
@@ -1032,7 +1032,7 @@ abstract class HTMLFormField {
         * Recursively forces values in an array to strings, because issues arise
         * with integer 0 as a value.
         *
-        * @param array $array
+        * @param array|string $array
         * @return array|string
         */
        public static function forceToStringRecursive( $array ) {
index 8ce3c83..8e51858 100644 (file)
@@ -196,7 +196,7 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
         * line above the options in the case of a checkbox matrix, i.e. it's always
         * a "vertical-label".
         *
-        * @param string $value The value to set the input to
+        * @param string|array $value The value to set the input to
         *
         * @return string Complete HTML table row
         */
index be8f7d8..4372cd1 100644 (file)
@@ -18,7 +18,7 @@ class HTMLFormFieldWithButton extends HTMLFormField {
        /** @var string $mButtonType Value for the button in this field */
        protected $mButtonValue;
 
-       /** @var string $mButtonType Value for the button in this field */
+       /** @var string[] $mButtonType Value for the button in this field */
        protected $mButtonFlags = [ 'progressive' ];
 
        public function __construct( $info ) {