Replace call_user_func_array(), part 2
[lhc/web/wiklou.git] / includes / skins / BaseTemplate.php
index e1f2969..6838774 100644 (file)
@@ -18,6 +18,9 @@
  * @file
  */
 
+use Wikimedia\WrappedString;
+use Wikimedia\WrappedStringList;
+
 /**
  * New base template for a skin's template extended from QuickTemplate
  * this class features helper methods that provide common ways of interacting
@@ -33,7 +36,7 @@ abstract class BaseTemplate extends QuickTemplate {
         * @return Message
         */
        public function getMsg( $name /* ... */ ) {
-               return call_user_func_array( [ $this->getSkin(), 'msg' ], func_get_args() );
+               return $this->getSkin()->msg( ...func_get_args() );
        }
 
        function msg( $str ) {
@@ -363,7 +366,7 @@ abstract class BaseTemplate extends QuickTemplate {
                if ( isset( $item['text'] ) ) {
                        $text = $item['text'];
                } else {
-                       $text = wfMessage( isset( $item['msg'] ) ? $item['msg'] : $key )->text();
+                       $text = wfMessage( $item['msg'] ?? $key )->text();
                }
 
                $html = htmlspecialchars( $text );
@@ -375,9 +378,7 @@ abstract class BaseTemplate extends QuickTemplate {
                        }
                        while ( count( $wrapper ) > 0 ) {
                                $element = array_pop( $wrapper );
-                               $html = Html::rawElement( $element['tag'], isset( $element['attributes'] )
-                                       ? $element['attributes']
-                                       : null, $html );
+                               $html = Html::rawElement( $element['tag'], $element['attributes'] ?? null, $html );
                        }
                }
 
@@ -514,7 +515,7 @@ abstract class BaseTemplate extends QuickTemplate {
                if ( isset( $item['itemtitle'] ) ) {
                        $attrs['title'] = $item['itemtitle'];
                }
-               return Html::rawElement( isset( $options['tag'] ) ? $options['tag'] : 'li', $attrs, $html );
+               return Html::rawElement( $options['tag'] ?? 'li', $attrs, $html );
        }
 
        function makeSearchInput( $attrs = [] ) {
@@ -558,11 +559,9 @@ abstract class BaseTemplate extends QuickTemplate {
                                unset( $buttonAttrs['height'] );
                                $imgAttrs = [
                                        'src' => $attrs['src'],
-                                       'alt' => isset( $attrs['alt'] )
-                                               ? $attrs['alt']
-                                               : wfMessage( 'searchbutton' )->text(),
-                                       'width' => isset( $attrs['width'] ) ? $attrs['width'] : null,
-                                       'height' => isset( $attrs['height'] ) ? $attrs['height'] : null,
+                                       'alt' => $attrs['alt'] ?? wfMessage( 'searchbutton' )->text(),
+                                       'width' => $attrs['width'] ?? null,
+                                       'height' => $attrs['height'] ?? null,
                                ];
                                return Html::rawElement( 'button', $buttonAttrs, Html::element( 'img', $imgAttrs ) );
                        default:
@@ -754,14 +753,14 @@ abstract class BaseTemplate extends QuickTemplate {
         * debug stuff. This should be called right before outputting the closing
         * body and html tags.
         *
-        * @return string
+        * @return string|WrappedStringList HTML
         * @since 1.29
         */
-       function getTrail() {
-               $html = MWDebug::getDebugHTML( $this->getSkin()->getContext() );
-               $html .= $this->get( 'bottomscripts' );
-               $html .= $this->get( 'reporttime' );
-
-               return $html;
+       public function getTrail() {
+               return WrappedString::join( "\n", [
+                       MWDebug::getDebugHTML( $this->getSkin()->getContext() ),
+                       $this->get( 'bottomscripts' ),
+                       $this->get( 'reporttime' )
+               ] );
        }
 }