Merge "Document return of void in Maintenance::execute"
[lhc/web/wiklou.git] / includes / htmlform / HTMLFormField.php
index 5066f28..83fe65a 100644 (file)
@@ -81,12 +81,9 @@ abstract class HTMLFormField {
                $args = func_get_args();
 
                if ( $this->mParent ) {
-                       $callback = [ $this->mParent, 'msg' ];
-               } else {
-                       $callback = 'wfMessage';
+                       return $this->mParent->msg( ...$args );
                }
-
-               return call_user_func_array( $callback, $args );
+               return wfMessage( ...$args );
        }
 
        /**
@@ -315,7 +312,7 @@ abstract class HTMLFormField {
                }
 
                if ( isset( $this->mValidationCallback ) ) {
-                       return call_user_func( $this->mValidationCallback, $value, $alldata, $this->mParent );
+                       return ( $this->mValidationCallback )( $value, $alldata, $this->mParent );
                }
 
                return true;
@@ -323,7 +320,7 @@ abstract class HTMLFormField {
 
        public function filter( $value, $alldata ) {
                if ( isset( $this->mFilterCallback ) ) {
-                       $value = call_user_func( $this->mFilterCallback, $value, $alldata, $this->mParent );
+                       $value = ( $this->mFilterCallback )( $value, $alldata, $this->mParent );
                }
 
                return $value;
@@ -400,9 +397,9 @@ abstract class HTMLFormField {
                if ( isset( $params['label-message'] ) ) {
                        $this->mLabel = $this->getMessage( $params['label-message'] )->parse();
                } elseif ( isset( $params['label'] ) ) {
-                       if ( $params['label'] === ' ' ) {
+                       if ( $params['label'] === ' ' || $params['label'] === "\u{00A0}" ) {
                                // Apparently some things set &nbsp directly and in an odd format
-                               $this->mLabel = ' ';
+                               $this->mLabel = "\u{00A0}";
                        } else {
                                $this->mLabel = htmlspecialchars( $params['label'] );
                        }
@@ -546,11 +543,10 @@ abstract class HTMLFormField {
                        'mw-htmlform-nolabel' => ( $label === '' )
                ];
 
-               $horizontalLabel = isset( $this->mParams['horizontal-label'] )
-                       ? $this->mParams['horizontal-label'] : false;
+               $horizontalLabel = $this->mParams['horizontal-label'] ?? false;
 
                if ( $horizontalLabel ) {
-                       $field = ' ' . $inputHtml . "\n$errors";
+                       $field = "\u{00A0}" . $inputHtml . "\n$errors";
                } else {
                        $field = Html::rawElement(
                                'div',
@@ -634,7 +630,7 @@ abstract class HTMLFormField {
 
                // the element could specify, that the label doesn't need to be added
                $label = $this->getLabel();
-               if ( $label && $label !== ' ' ) {
+               if ( $label && $label !== "\u{00A0}" && $label !== ' ' ) {
                        $config['label'] = new OOUI\HtmlSnippet( $label );
                }
 
@@ -749,7 +745,7 @@ abstract class HTMLFormField {
                $label = $this->getLabelHtml( $cellAttributes );
 
                $html = "\n" . $errors .
-                       $label . ' ' .
+                       $label . "\u{00A0}" .
                        $inputHtml .
                        $helptext;
 
@@ -930,7 +926,7 @@ abstract class HTMLFormField {
         * @return string HTML
         */
        public function getLabel() {
-               return is_null( $this->mLabel ) ? '' : $this->mLabel;
+               return $this->mLabel ?? '';
        }
 
        public function getLabelHtml( $cellAttributes = [] ) {
@@ -944,14 +940,13 @@ abstract class HTMLFormField {
 
                $labelValue = trim( $this->getLabel() );
                $hasLabel = false;
-               if ( $labelValue !== ' ' && $labelValue !== '' ) {
+               if ( $labelValue !== "\u{00A0}" && $labelValue !== ' ' && $labelValue !== '' ) {
                        $hasLabel = true;
                }
 
                $displayFormat = $this->mParent->getDisplayFormat();
                $html = '';
-               $horizontalLabel = isset( $this->mParams['horizontal-label'] )
-                       ? $this->mParams['horizontal-label'] : false;
+               $horizontalLabel = $this->mParams['horizontal-label'] ?? false;
 
                if ( $displayFormat === 'table' ) {
                        $html =