Fix trivial PHPCS violations in */skins/* directories
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 2 Mar 2016 19:57:35 +0000 (20:57 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 2 Mar 2016 20:02:15 +0000 (21:02 +0100)
Due to T127238, files in various */skins/* directories are not checked
by PHPCS. Temporarily removed the exclude rule from phpcs.xml and ran:

  composer fix includes/skins/* tests/phpunit/includes/skins/* tests/phpunit/skins/*

Change-Id: I9240c1cee825920b6634903282be6252cce55686

includes/skins/BaseTemplate.php
includes/skins/MediaWikiI18N.php
includes/skins/QuickTemplate.php
includes/skins/Skin.php
includes/skins/SkinApi.php
includes/skins/SkinApiTemplate.php
includes/skins/SkinFactory.php
includes/skins/SkinFallbackTemplate.php
includes/skins/SkinTemplate.php
tests/phpunit/includes/skins/SkinTemplateTest.php
tests/phpunit/skins/SideBarTest.php

index 85b17f9..3408db3 100644 (file)
@@ -56,7 +56,7 @@ abstract class BaseTemplate extends QuickTemplate {
         */
        function getToolbox() {
 
-               $toolbox = array();
+               $toolbox = [];
                if ( isset( $this->data['nav_urls']['whatlinkshere'] )
                        && $this->data['nav_urls']['whatlinkshere']
                ) {
@@ -72,7 +72,7 @@ abstract class BaseTemplate extends QuickTemplate {
                }
                if ( isset( $this->data['feeds'] ) && $this->data['feeds'] ) {
                        $toolbox['feeds']['id'] = 'feedlinks';
-                       $toolbox['feeds']['links'] = array();
+                       $toolbox['feeds']['links'] = [];
                        foreach ( $this->data['feeds'] as $key => $feed ) {
                                $toolbox['feeds']['links'][$key] = $feed;
                                $toolbox['feeds']['links'][$key]['id'] = "feed-$key";
@@ -81,8 +81,8 @@ abstract class BaseTemplate extends QuickTemplate {
                                $toolbox['feeds']['links'][$key]['class'] = 'feedlink';
                        }
                }
-               foreach ( array( 'contributions', 'log', 'blockip', 'emailuser',
-                       'userrights', 'upload', 'specialpages' ) as $special
+               foreach ( [ 'contributions', 'log', 'blockip', 'emailuser',
+                       'userrights', 'upload', 'specialpages' ] as $special
                ) {
                        if ( isset( $this->data['nav_urls'][$special] ) && $this->data['nav_urls'][$special] ) {
                                $toolbox[$special] = $this->data['nav_urls'][$special];
@@ -111,7 +111,7 @@ abstract class BaseTemplate extends QuickTemplate {
                        $toolbox['info']['id'] = 't-info';
                }
 
-               Hooks::run( 'BaseTemplateToolbox', array( &$this, &$toolbox ) );
+               Hooks::run( 'BaseTemplateToolbox', [ &$this, &$toolbox ] );
                return $toolbox;
        }
 
@@ -126,21 +126,21 @@ abstract class BaseTemplate extends QuickTemplate {
         * @return array
         */
        function getPersonalTools() {
-               $personal_tools = array();
+               $personal_tools = [];
                foreach ( $this->get( 'personal_urls' ) as $key => $plink ) {
                        # The class on a personal_urls item is meant to go on the <a> instead
                        # of the <li> so we have to use a single item "links" array instead
                        # of using most of the personal_url's keys directly.
-                       $ptool = array(
-                               'links' => array(
-                                       array( 'single-id' => "pt-$key" ),
-                               ),
+                       $ptool = [
+                               'links' => [
+                                       [ 'single-id' => "pt-$key" ],
+                               ],
                                'id' => "pt-$key",
-                       );
+                       ];
                        if ( isset( $plink['active'] ) ) {
                                $ptool['active'] = $plink['active'];
                        }
-                       foreach ( array( 'href', 'class', 'text', 'dir' ) as $k ) {
+                       foreach ( [ 'href', 'class', 'text', 'dir' ] as $k ) {
                                if ( isset( $plink[$k] ) ) {
                                        $ptool['links'][0][$k] = $plink[$k];
                                }
@@ -150,7 +150,7 @@ abstract class BaseTemplate extends QuickTemplate {
                return $personal_tools;
        }
 
-       function getSidebar( $options = array() ) {
+       function getSidebar( $options = [] ) {
                // Force the rendering of the following portals
                $sidebar = $this->data['sidebar'];
                if ( !isset( $sidebar['SEARCH'] ) ) {
@@ -173,7 +173,7 @@ abstract class BaseTemplate extends QuickTemplate {
                        unset( $sidebar['LANGUAGES'] );
                }
 
-               $boxes = array();
+               $boxes = [];
                foreach ( $sidebar as $boxName => $content ) {
                        if ( $content === false ) {
                                continue;
@@ -181,41 +181,41 @@ abstract class BaseTemplate extends QuickTemplate {
                        switch ( $boxName ) {
                        case 'SEARCH':
                                // Search is a special case, skins should custom implement this
-                               $boxes[$boxName] = array(
+                               $boxes[$boxName] = [
                                        'id' => 'p-search',
                                        'header' => $this->getMsg( 'search' )->text(),
                                        'generated' => false,
                                        'content' => true,
-                               );
+                               ];
                                break;
                        case 'TOOLBOX':
                                $msgObj = $this->getMsg( 'toolbox' );
-                               $boxes[$boxName] = array(
+                               $boxes[$boxName] = [
                                        'id' => 'p-tb',
                                        'header' => $msgObj->exists() ? $msgObj->text() : 'toolbox',
                                        'generated' => false,
                                        'content' => $this->getToolbox(),
-                               );
+                               ];
                                break;
                        case 'LANGUAGES':
                                if ( $this->data['language_urls'] ) {
                                        $msgObj = $this->getMsg( 'otherlanguages' );
-                                       $boxes[$boxName] = array(
+                                       $boxes[$boxName] = [
                                                'id' => 'p-lang',
                                                'header' => $msgObj->exists() ? $msgObj->text() : 'otherlanguages',
                                                'generated' => false,
                                                'content' => $this->data['language_urls'],
-                                       );
+                                       ];
                                }
                                break;
                        default:
                                $msgObj = $this->getMsg( $boxName );
-                               $boxes[$boxName] = array(
+                               $boxes[$boxName] = [
                                        'id' => "p-$boxName",
                                        'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
                                        'generated' => true,
                                        'content' => $content,
-                               );
+                               ];
                                break;
                        }
                }
@@ -226,7 +226,7 @@ abstract class BaseTemplate extends QuickTemplate {
                        ob_start();
                        // We pass an extra 'true' at the end so extensions using BaseTemplateToolbox
                        // can abort and avoid outputting double toolbox links
-                       Hooks::run( 'SkinTemplateToolboxEnd', array( &$this, true ) );
+                       Hooks::run( 'SkinTemplateToolboxEnd', [ &$this, true ] );
                        $hookContents = ob_get_contents();
                        ob_end_clean();
                        if ( !trim( $hookContents ) ) {
@@ -253,14 +253,14 @@ abstract class BaseTemplate extends QuickTemplate {
                        }
                } else {
                        if ( $hookContents ) {
-                               $boxes['TOOLBOXEND'] = array(
+                               $boxes['TOOLBOXEND'] = [
                                        'id' => 'p-toolboxend',
                                        'header' => $boxes['TOOLBOX']['header'],
                                        'generated' => false,
                                        'content' => "<ul>{$hookContents}</ul>",
-                               );
+                               ];
                                // HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
-                               $boxes2 = array();
+                               $boxes2 = [];
                                foreach ( $boxes as $key => $box ) {
                                        if ( $key === 'TOOLBOXEND' ) {
                                                continue;
@@ -283,7 +283,7 @@ abstract class BaseTemplate extends QuickTemplate {
         */
        protected function renderAfterPortlet( $name ) {
                $content = '';
-               Hooks::run( 'BaseTemplateAfterPortlet', array( $this, $name, &$content ) );
+               Hooks::run( 'BaseTemplateAfterPortlet', [ $this, $name, &$content ] );
 
                if ( $content !== '' ) {
                        echo "<div class='after-portlet after-portlet-$name'>$content</div>";
@@ -334,7 +334,7 @@ abstract class BaseTemplate extends QuickTemplate {
         *
         * @return string
         */
-       function makeLink( $key, $item, $options = array() ) {
+       function makeLink( $key, $item, $options = [] ) {
                if ( isset( $item['text'] ) ) {
                        $text = $item['text'];
                } else {
@@ -346,7 +346,7 @@ abstract class BaseTemplate extends QuickTemplate {
                if ( isset( $options['text-wrapper'] ) ) {
                        $wrapper = $options['text-wrapper'];
                        if ( isset( $wrapper['tag'] ) ) {
-                               $wrapper = array( $wrapper );
+                               $wrapper = [ $wrapper ];
                        }
                        while ( count( $wrapper ) > 0 ) {
                                $element = array_pop( $wrapper );
@@ -358,8 +358,8 @@ abstract class BaseTemplate extends QuickTemplate {
 
                if ( isset( $item['href'] ) || isset( $options['link-fallback'] ) ) {
                        $attrs = $item;
-                       foreach ( array( 'single-id', 'text', 'msg', 'tooltiponly', 'context', 'primary',
-                               'tooltip-params' ) as $k ) {
+                       foreach ( [ 'single-id', 'text', 'msg', 'tooltiponly', 'context', 'primary',
+                               'tooltip-params' ] as $k ) {
                                unset( $attrs[$k] );
                        }
 
@@ -367,7 +367,7 @@ abstract class BaseTemplate extends QuickTemplate {
                                $item['single-id'] = $item['id'];
                        }
 
-                       $tooltipParams = array();
+                       $tooltipParams = [];
                        if ( isset( $item['tooltip-params'] ) ) {
                                $tooltipParams = $item['tooltip-params'];
                        }
@@ -431,9 +431,9 @@ abstract class BaseTemplate extends QuickTemplate {
         *
         * @return string
         */
-       function makeListItem( $key, $item, $options = array() ) {
+       function makeListItem( $key, $item, $options = [] ) {
                if ( isset( $item['links'] ) ) {
-                       $links = array();
+                       $links = [];
                        foreach ( $item['links'] as $linkKey => $link ) {
                                $links[] = $this->makeLink( $linkKey, $link, $options );
                        }
@@ -441,7 +441,7 @@ abstract class BaseTemplate extends QuickTemplate {
                } else {
                        $link = $item;
                        // These keys are used by makeListItem and shouldn't be passed on to the link
-                       foreach ( array( 'id', 'class', 'active', 'tag', 'itemtitle' ) as $k ) {
+                       foreach ( [ 'id', 'class', 'active', 'tag', 'itemtitle' ] as $k ) {
                                unset( $link[$k] );
                        }
                        if ( isset( $item['id'] ) && !isset( $item['single-id'] ) ) {
@@ -453,8 +453,8 @@ abstract class BaseTemplate extends QuickTemplate {
                        $html = $this->makeLink( $key, $link, $options );
                }
 
-               $attrs = array();
-               foreach ( array( 'id', 'class' ) as $attr ) {
+               $attrs = [];
+               foreach ( [ 'id', 'class' ] as $attr ) {
                        if ( isset( $item[$attr] ) ) {
                                $attrs[$attr] = $item[$attr];
                        }
@@ -472,27 +472,27 @@ abstract class BaseTemplate extends QuickTemplate {
                return Html::rawElement( isset( $options['tag'] ) ? $options['tag'] : 'li', $attrs, $html );
        }
 
-       function makeSearchInput( $attrs = array() ) {
-               $realAttrs = array(
+       function makeSearchInput( $attrs = [] ) {
+               $realAttrs = [
                        'type' => 'search',
                        'name' => 'search',
                        'placeholder' => wfMessage( 'searchsuggest-search' )->text(),
                        'value' => $this->get( 'search', '' ),
-               );
+               ];
                $realAttrs = array_merge( $realAttrs, Linker::tooltipAndAccesskeyAttribs( 'search' ), $attrs );
                return Html::element( 'input', $realAttrs );
        }
 
-       function makeSearchButton( $mode, $attrs = array() ) {
+       function makeSearchButton( $mode, $attrs = [] ) {
                switch ( $mode ) {
                        case 'go':
                        case 'fulltext':
-                               $realAttrs = array(
+                               $realAttrs = [
                                        'type' => 'submit',
                                        'name' => $mode,
                                        'value' => $this->translator->translate(
                                                $mode == 'go' ? 'searcharticle' : 'searchbutton' ),
-                               );
+                               ];
                                $realAttrs = array_merge(
                                        $realAttrs,
                                        Linker::tooltipAndAccesskeyAttribs( "search-$mode" ),
@@ -500,10 +500,10 @@ abstract class BaseTemplate extends QuickTemplate {
                                );
                                return Html::element( 'input', $realAttrs );
                        case 'image':
-                               $buttonAttrs = array(
+                               $buttonAttrs = [
                                        'type' => 'submit',
                                        'name' => 'button',
-                               );
+                               ];
                                $buttonAttrs = array_merge(
                                        $buttonAttrs,
                                        Linker::tooltipAndAccesskeyAttribs( 'search-fulltext' ),
@@ -513,14 +513,14 @@ abstract class BaseTemplate extends QuickTemplate {
                                unset( $buttonAttrs['alt'] );
                                unset( $buttonAttrs['width'] );
                                unset( $buttonAttrs['height'] );
-                               $imgAttrs = array(
+                               $imgAttrs = [
                                        'src' => $attrs['src'],
                                        'alt' => isset( $attrs['alt'] )
                                                ? $attrs['alt']
                                                : $this->translator->translate( 'searchbutton' ),
                                        'width' => isset( $attrs['width'] ) ? $attrs['width'] : null,
                                        'height' => isset( $attrs['height'] ) ? $attrs['height'] : null,
-                               );
+                               ];
                                return Html::rawElement( 'button', $buttonAttrs, Html::element( 'img', $imgAttrs ) );
                        default:
                                throw new MWException( 'Unknown mode passed to BaseTemplate::makeSearchButton' );
@@ -540,9 +540,9 @@ abstract class BaseTemplate extends QuickTemplate {
                $footerlinks = $this->get( 'footerlinks' );
 
                // Reduce footer links down to only those which are being used
-               $validFooterLinks = array();
+               $validFooterLinks = [];
                foreach ( $footerlinks as $category => $links ) {
-                       $validFooterLinks[$category] = array();
+                       $validFooterLinks[$category] = [];
                        foreach ( $links as $link ) {
                                if ( isset( $this->data[$link] ) && $this->data[$link] ) {
                                        $validFooterLinks[$category][] = $link;
@@ -625,10 +625,10 @@ abstract class BaseTemplate extends QuickTemplate {
                foreach ( $this->data['indicators'] as $id => $content ) {
                        $out .= Html::rawElement(
                                'div',
-                               array(
+                               [
                                        'id' => Sanitizer::escapeId( "mw-indicator-$id" ),
                                        'class' => 'mw-indicator',
-                               ),
+                               ],
                                $content
                        ) . "\n";
                }
index 20cceda..02e8391 100644 (file)
@@ -26,7 +26,7 @@
  * @ingroup Skins
  */
 class MediaWikiI18N {
-       private $context = array();
+       private $context = [];
 
        function set( $varName, $value ) {
                $this->context[$varName] = $value;
@@ -39,7 +39,7 @@ class MediaWikiI18N {
 
                $value = wfMessage( $value )->text();
                // interpolate variables
-               $m = array();
+               $m = [];
                while ( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
                        list( $src, $var ) = $m;
                        MediaWiki\suppressWarnings();
index 905e537..af2d5da 100644 (file)
@@ -32,7 +32,7 @@ abstract class QuickTemplate {
         * @param Config $config
         */
        function __construct( Config $config = null ) {
-               $this->data = array();
+               $this->data = [];
                $this->translator = new MediaWikiI18N();
                if ( $config === null ) {
                        wfDebug( __METHOD__ . ' was called with no Config instance passed to it' );
index 83f119d..b80788b 100644 (file)
@@ -55,7 +55,7 @@ abstract class Skin extends ContextSource {
         * @return string[]
         */
        static function getSkinNameMessages() {
-               $messages = array();
+               $messages = [];
                foreach ( self::getSkinNames() as $skinKey => $skinName ) {
                        $messages[] = "skinname-$skinKey";
                }
@@ -122,10 +122,10 @@ abstract class Skin extends ContextSource {
 
                // Older versions of the software used a numeric setting
                // in the user preferences.
-               $fallback = array(
+               $fallback = [
                        0 => $defaultSkin,
                        2 => 'cologneblue'
-               );
+               ];
 
                if ( isset( $fallback[$key] ) ) {
                        $key = $fallback[$key];
@@ -184,20 +184,20 @@ abstract class Skin extends ContextSource {
 
                $out = $this->getOutput();
                $user = $out->getUser();
-               $modules = array(
+               $modules = [
                        // modules that enhance the page content in some way
-                       'content' => array(
+                       'content' => [
                                'mediawiki.page.ready',
-                       ),
+                       ],
                        // modules that exist for legacy reasons
                        'legacy' => ResourceLoaderStartUpModule::getLegacyModules(),
                        // modules relating to search functionality
-                       'search' => array(),
+                       'search' => [],
                        // modules relating to functionality relating to watching an article
-                       'watch' => array(),
+                       'watch' => [],
                        // modules which relate to the current users preferences
-                       'user' => array(),
-               );
+                       'user' => [],
+               ];
 
                // Add various resources if required
                if ( $wgUseAjax && $wgEnableAPI ) {
@@ -226,7 +226,7 @@ abstract class Skin extends ContextSource {
         * Preload the existence of three commonly-requested pages in a single query
         */
        function preloadExistence() {
-               $titles = array();
+               $titles = [];
 
                $user = $this->getUser();
                $title = $this->getRelevantTitle();
@@ -246,7 +246,7 @@ abstract class Skin extends ContextSource {
                        $titles[] = $title->getTalkPage();
                }
 
-               Hooks::run( 'SkinPreloadExistence', array( &$titles, $this ) );
+               Hooks::run( 'SkinPreloadExistence', [ &$titles, $this ] );
 
                if ( count( $titles ) ) {
                        $lb = new LinkBatch( $titles );
@@ -370,13 +370,13 @@ abstract class Skin extends ContextSource {
        public static function getDynamicStylesheetQuery() {
                global $wgSquidMaxage;
 
-               return array(
+               return [
                                'action' => 'raw',
                                'maxage' => $wgSquidMaxage,
                                'usemsgcache' => 'yes',
                                'ctype' => 'text/css',
                                'smaxage' => $wgSquidMaxage,
-                       );
+                       ];
        }
 
        /**
@@ -423,11 +423,11 @@ abstract class Skin extends ContextSource {
         */
        public function getHtmlElementAttributes() {
                $lang = $this->getLanguage();
-               return array(
+               return [
                        'lang' => $lang->getHtmlCode(),
                        'dir' => $lang->getDir(),
                        'class' => 'client-nojs',
-               );
+               ];
        }
 
        /**
@@ -580,7 +580,7 @@ abstract class Skin extends ContextSource {
        protected function afterContentHook() {
                $data = '';
 
-               if ( Hooks::run( 'SkinAfterContent', array( &$data, $this ) ) ) {
+               if ( Hooks::run( 'SkinAfterContent', [ &$data, $this ] ) ) {
                        // adding just some spaces shouldn't toggle the output
                        // of the whole <div/>, so we use trim() here
                        if ( trim( $data ) != '' ) {
@@ -617,7 +617,7 @@ abstract class Skin extends ContextSource {
                // OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
                // up at some point
                $bottomScriptText = $this->getOutput()->getBottomScripts();
-               Hooks::run( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
+               Hooks::run( 'SkinAfterBottomScripts', [ $this, &$bottomScriptText ] );
 
                return $bottomScriptText;
        }
@@ -678,7 +678,7 @@ abstract class Skin extends ContextSource {
                $out = $this->getOutput();
                $subpages = '';
 
-               if ( !Hooks::run( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) {
+               if ( !Hooks::run( 'SkinSubPageSubtitle', [ &$subpages, $this, $out ] ) ) {
                        return $subpages;
                }
 
@@ -789,7 +789,7 @@ abstract class Skin extends ContextSource {
 
                Hooks::run(
                        'SkinCopyrightFooter',
-                       array( $this->getTitle(), $type, &$msg, &$link, &$forContent )
+                       [ $this->getTitle(), $type, &$msg, &$link, &$forContent ]
                );
 
                return $this->msg( $msg )->rawParams( $link )->text();
@@ -843,7 +843,7 @@ abstract class Skin extends ContextSource {
                $text = '<a href="//www.mediawiki.org/"><img src="' . $url1
                        . '" srcset="' . $url1_5 . ' 1.5x, ' . $url2 . ' 2x" '
                        . 'height="31" width="88" alt="Powered by MediaWiki" /></a>';
-               Hooks::run( 'SkinGetPoweredBy', array( &$text, $this ) );
+               Hooks::run( 'SkinGetPoweredBy', [ &$text, $this ] );
                return $text;
        }
 
@@ -917,7 +917,7 @@ abstract class Skin extends ContextSource {
                                $html = htmlspecialchars( $icon["alt"] );
                        }
                        if ( $url ) {
-                               $html = Html::rawElement( 'a', array( "href" => $url ), $html );
+                               $html = Html::rawElement( 'a', [ "href" => $url ], $html );
                        }
                }
                return $html;
@@ -996,7 +996,7 @@ abstract class Skin extends ContextSource {
         * @private
         */
        function editUrlOptions() {
-               $options = array( 'action' => 'edit' );
+               $options = [ 'action' => 'edit' ];
 
                if ( !$this->isRevisionCurrent() ) {
                        $options['oldid'] = intval( $this->getRevisionId() );
@@ -1164,10 +1164,10 @@ abstract class Skin extends ContextSource {
                $title = Title::newFromText( $name );
                self::checkTitle( $title, $name );
 
-               return array(
+               return [
                        'href' => $title->getLocalURL( $urlaction ),
                        'exists' => $title->isKnown(),
-               );
+               ];
        }
 
        /**
@@ -1180,10 +1180,10 @@ abstract class Skin extends ContextSource {
                $title = Title::newFromText( $name );
                self::checkTitle( $title, $name );
 
-               return array(
+               return [
                        'href' => $title->getLocalURL( $urlaction ),
                        'exists' => true
-               );
+               ];
        }
 
        /**
@@ -1227,9 +1227,9 @@ abstract class Skin extends ContextSource {
 
                $that = $this;
                $callback = function () use ( $that ) {
-                       $bar = array();
+                       $bar = [];
                        $that->addToSidebar( $bar, 'sidebar' );
-                       Hooks::run( 'SkinBuildSidebar', array( $that, &$bar ) );
+                       Hooks::run( 'SkinBuildSidebar', [ $that, &$bar ] );
 
                        return $bar;
                };
@@ -1240,14 +1240,14 @@ abstract class Skin extends ContextSource {
                                $cache->makeKey( 'sidebar', $this->getLanguage()->getCode() ),
                                $wgSidebarCacheExpiry,
                                $callback,
-                               array( 'lockTSE' => 30 )
+                               [ 'lockTSE' => 30 ]
                        );
                } else {
                        $sidebar = $callback();
                }
 
                // Apply post-processing to the cached value
-               Hooks::run( 'SidebarBeforeOutput', array( $this, &$sidebar ) );
+               Hooks::run( 'SidebarBeforeOutput', [ $this, &$sidebar ] );
 
                return $sidebar;
        }
@@ -1286,7 +1286,7 @@ abstract class Skin extends ContextSource {
                        if ( strpos( $line, '**' ) !== 0 ) {
                                $heading = trim( $line, '* ' );
                                if ( !array_key_exists( $heading, $bar ) ) {
-                                       $bar[$heading] = array();
+                                       $bar[$heading] = [];
                                }
                        } else {
                                $line = trim( $line, '* ' );
@@ -1300,7 +1300,7 @@ abstract class Skin extends ContextSource {
                                                continue;
                                        }
 
-                                       $extraAttribs = array();
+                                       $extraAttribs = [];
 
                                        $msgLink = $this->msg( $line[0] )->inContentLanguage();
                                        if ( $msgLink->exists() ) {
@@ -1342,12 +1342,12 @@ abstract class Skin extends ContextSource {
                                                }
                                        }
 
-                                       $bar[$heading][] = array_merge( array(
+                                       $bar[$heading][] = array_merge( [
                                                'text' => $text,
                                                'href' => $href,
                                                'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
                                                'active' => false
-                                       ), $extraAttribs );
+                                       ], $extraAttribs );
                                } else {
                                        continue;
                                }
@@ -1386,7 +1386,7 @@ abstract class Skin extends ContextSource {
                $out = $this->getOutput();
 
                // Allow extensions to disable or modify the new messages alert
-               if ( !Hooks::run( 'GetNewMessagesAlert', array( &$newMessagesAlert, $newtalks, $user, $out ) ) ) {
+               if ( !Hooks::run( 'GetNewMessagesAlert', [ &$newMessagesAlert, $newtalks, $user, $out ] ) ) {
                        return '';
                }
                if ( $newMessagesAlert ) {
@@ -1417,17 +1417,17 @@ abstract class Skin extends ContextSource {
                        $newMessagesLink = Linker::linkKnown(
                                $uTalkTitle,
                                $this->msg( 'newmessageslinkplural' )->params( $plural )->escaped(),
-                               array(),
-                               array( 'redirect' => 'no' )
+                               [],
+                               [ 'redirect' => 'no' ]
                        );
 
                        $newMessagesDiffLink = Linker::linkKnown(
                                $uTalkTitle,
                                $this->msg( 'newmessagesdifflinkplural' )->params( $plural )->escaped(),
-                               array(),
+                               [],
                                $lastSeenRev !== null
-                                       ? array( 'oldid' => $lastSeenRev->getId(), 'diff' => 'cur' )
-                                       : array( 'diff' => 'cur' )
+                                       ? [ 'oldid' => $lastSeenRev->getId(), 'diff' => 'cur' ]
+                                       : [ 'diff' => 'cur' ]
                        );
 
                        if ( $nofAuthors >= 1 && $nofAuthors <= 10 ) {
@@ -1449,12 +1449,12 @@ abstract class Skin extends ContextSource {
                        $out->setCdnMaxage( 0 );
                } elseif ( count( $newtalks ) ) {
                        $sep = $this->msg( 'newtalkseparator' )->escaped();
-                       $msgs = array();
+                       $msgs = [];
 
                        foreach ( $newtalks as $newtalk ) {
                                $msgs[] = Xml::element(
                                        'a',
-                                       array( 'href' => $newtalk['link'] ), $newtalk['wiki']
+                                       [ 'href' => $newtalk['link'] ], $newtalk['wiki']
                                );
                        }
                        $parts = implode( $sep, $msgs );
@@ -1509,12 +1509,12 @@ abstract class Skin extends ContextSource {
 
                if ( $needParse ) {
                        $parsed = $this->getOutput()->parse( $notice );
-                       $parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
+                       $parserMemc->set( $key, [ 'html' => $parsed, 'hash' => md5( $notice ) ], 600 );
                        $notice = $parsed;
                }
 
-               $notice = Html::rawElement( 'div', array( 'id' => 'localNotice',
-                       'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $notice );
+               $notice = Html::rawElement( 'div', [ 'id' => 'localNotice',
+                       'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ], $notice );
                return $notice;
        }
 
@@ -1526,7 +1526,7 @@ abstract class Skin extends ContextSource {
        function getSiteNotice() {
                $siteNotice = '';
 
-               if ( Hooks::run( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
+               if ( Hooks::run( 'SiteNoticeBefore', [ &$siteNotice, $this ] ) ) {
                        if ( is_object( $this->getUser() ) && $this->getUser()->isLoggedIn() ) {
                                $siteNotice = $this->getCachedNotice( 'sitenotice' );
                        } else {
@@ -1542,7 +1542,7 @@ abstract class Skin extends ContextSource {
                        }
                }
 
-               Hooks::run( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
+               Hooks::run( 'SiteNoticeAfter', [ &$siteNotice, $this ] );
                return $siteNotice;
        }
 
@@ -1565,7 +1565,7 @@ abstract class Skin extends ContextSource {
 
                $lang = wfGetLangObj( $lang );
 
-               $attribs = array();
+               $attribs = [];
                if ( !is_null( $tooltip ) ) {
                        # Bug 25462: undo double-escaping.
                        $tooltip = Sanitizer::decodeCharReferences( $tooltip );
@@ -1573,21 +1573,21 @@ abstract class Skin extends ContextSource {
                                ->inLanguage( $lang )->text();
                }
 
-               $links = array(
-                       'editsection' => array(
+               $links = [
+                       'editsection' => [
                                'text' => wfMessage( 'editsection' )->inLanguage( $lang )->escaped(),
                                'targetTitle' => $nt,
                                'attribs' => $attribs,
-                               'query' => array( 'action' => 'edit', 'section' => $section ),
-                               'options' => array( 'noclasses', 'known' )
-                       )
-               );
+                               'query' => [ 'action' => 'edit', 'section' => $section ],
+                               'options' => [ 'noclasses', 'known' ]
+                       ]
+               ];
 
-               Hooks::run( 'SkinEditSectionLinks', array( $this, $nt, $section, $tooltip, &$links, $lang ) );
+               Hooks::run( 'SkinEditSectionLinks', [ $this, $nt, $section, $tooltip, &$links, $lang ] );
 
                $result = '<span class="mw-editsection"><span class="mw-editsection-bracket">[</span>';
 
-               $linksHtml = array();
+               $linksHtml = [];
                foreach ( $links as $k => $linkDetails ) {
                        $linksHtml[] = Linker::link(
                                $linkDetails['targetTitle'],
@@ -1609,7 +1609,7 @@ abstract class Skin extends ContextSource {
                // Deprecated, use SkinEditSectionLinks hook instead
                Hooks::run(
                        'DoEditSectionLink',
-                       array( $this, $nt, $section, $tooltip, &$result, $lang ),
+                       [ $this, $nt, $section, $tooltip, &$result, $lang ],
                        '1.25'
                );
                return $result;
@@ -1625,7 +1625,7 @@ abstract class Skin extends ContextSource {
         * @return mixed
         */
        function __call( $fname, $args ) {
-               $realFunction = array( 'Linker', $fname );
+               $realFunction = [ 'Linker', $fname ];
                if ( is_callable( $realFunction ) ) {
                        wfDeprecated( get_class( $this ) . '::' . $fname, '1.21' );
                        return call_user_func_array( $realFunction, $args );
index 2fef220..1145efd 100644 (file)
@@ -42,7 +42,7 @@ class SkinApi extends SkinTemplate {
        // Skip work and hooks for stuff we don't use
 
        function buildSidebar() {
-               return array();
+               return [];
        }
 
        function getNewtalks() {
@@ -54,18 +54,18 @@ class SkinApi extends SkinTemplate {
        }
 
        public function getLanguages() {
-               return array();
+               return [];
        }
 
        protected function buildPersonalUrls() {
-               return array();
+               return [];
        }
 
        protected function buildContentNavigationUrls() {
-               return array();
+               return [];
        }
 
        protected function buildNavUrls() {
-               return array();
+               return [];
        }
 }
index 97b7038..f7d7cb2 100644 (file)
@@ -50,14 +50,14 @@ class SkinApiTemplate extends BaseTemplate {
        // Skip work and hooks for stuff we don't use
 
        function getToolbox() {
-               return array();
+               return [];
        }
 
        function getPersonalTools() {
-               return array();
+               return [];
        }
 
-       function getSidebar( $options = array() ) {
-               return array();
+       function getSidebar( $options = [] ) {
+               return [];
        }
 }
index ffbe629..366862d 100644 (file)
@@ -32,14 +32,14 @@ class SkinFactory {
         * Map of name => callback
         * @var array
         */
-       private $factoryFunctions = array();
+       private $factoryFunctions = [];
        /**
         * Map of name => fallback human-readable name, used when the 'skinname-<skin>' message is not
         * available
         *
         * @var array
         */
-       private $displayNames = array();
+       private $displayNames = [];
 
        /**
         * @var SkinFactory
index cd5e43c..ee8d841 100644 (file)
@@ -46,8 +46,8 @@ class SkinFallbackTemplate extends BaseTemplate {
                $enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER );
 
                if ( $installedSkins ) {
-                       $skinsInstalledText = array();
-                       $skinsInstalledSnippet = array();
+                       $skinsInstalledText = [];
+                       $skinsInstalledSnippet = [];
 
                        foreach ( $installedSkins as $skin ) {
                                $normalizedKey = strtolower( $skin );
@@ -105,7 +105,7 @@ class SkinFallbackTemplate extends BaseTemplate {
                <form action="<?php $this->text( 'wgScript' ) ?>">
                        <input type="hidden" name="title" value="<?php $this->text( 'searchtitle' ) ?>" />
                        <h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3>
-                       <?php echo $this->makeSearchInput( array( "id" => "searchInput" ) ) ?>
+                       <?php echo $this->makeSearchInput( [ "id" => "searchInput" ] ) ?>
                        <?php echo $this->makeSearchButton( 'go' ) ?>
                </form>
 
index 134c096..d6e0377 100644 (file)
@@ -51,11 +51,11 @@ class SkinTemplate extends Skin {
         * @param OutputPage $out
         */
        function setupSkinUserCss( OutputPage $out ) {
-               $moduleStyles = array(
+               $moduleStyles = [
                        'mediawiki.legacy.shared',
                        'mediawiki.legacy.commonPrint',
                        'mediawiki.sectionAnchor'
-               );
+               ];
                if ( $out->isSyndicated() ) {
                        $moduleStyles[] = 'mediawiki.feedlink';
                }
@@ -92,11 +92,11 @@ class SkinTemplate extends Skin {
        public function getLanguages() {
                global $wgHideInterlanguageLinks;
                if ( $wgHideInterlanguageLinks ) {
-                       return array();
+                       return [];
                }
 
                $userLang = $this->getLanguage();
-               $languageLinks = array();
+               $languageLinks = [];
 
                foreach ( $this->getOutput()->getLanguageLinks() as $languageLinkText ) {
                        $class = 'interlanguage-link interwiki-' . explode( ':', $languageLinkText, 2 )[0];
@@ -164,17 +164,17 @@ class SkinTemplate extends Skin {
                                }
 
                                $ilInterwikiCodeBCP47 = wfBCP47( $ilInterwikiCode );
-                               $languageLink = array(
+                               $languageLink = [
                                        'href' => $languageLinkTitle->getFullURL(),
                                        'text' => $ilLangName,
                                        'title' => $ilTitle,
                                        'class' => $class,
                                        'lang' => $ilInterwikiCodeBCP47,
                                        'hreflang' => $ilInterwikiCodeBCP47,
-                               );
+                               ];
                                Hooks::run(
                                        'SkinTemplateGetLanguageLink',
-                                       array( &$languageLink, $languageLinkTitle, $this->getTitle(), $this->getOutput() )
+                                       [ &$languageLink, $languageLinkTitle, $this->getTitle(), $this->getOutput() ]
                                );
                                $languageLinks[] = $languageLink;
                        }
@@ -194,7 +194,7 @@ class SkinTemplate extends Skin {
                $this->thispage = $title->getPrefixedDBkey();
                $this->titletxt = $title->getPrefixedText();
                $this->userpage = $user->getUserPage()->getPrefixedText();
-               $query = array();
+               $query = [];
                if ( !$request->wasPosted() ) {
                        $query = $request->getValues();
                        unset( $query['title'] );
@@ -291,13 +291,13 @@ class SkinTemplate extends Skin {
 
                $tpl->set( 'catlinks', $this->getCategories() );
                if ( $out->isSyndicated() ) {
-                       $feeds = array();
+                       $feeds = [];
                        foreach ( $out->getSyndicationLinks() as $format => $link ) {
-                               $feeds[$format] = array(
+                               $feeds[$format] = [
                                        // Messages: feed-atom, feed-rss
                                        'text' => $this->msg( "feed-$format" )->text(),
                                        'href' => $link
-                               );
+                               ];
                        }
                        $tpl->setRef( 'feeds', $feeds );
                } else {
@@ -386,19 +386,19 @@ class SkinTemplate extends Skin {
                $tpl->set( 'privacy', $this->privacyLink() );
                $tpl->set( 'about', $this->aboutLink() );
 
-               $tpl->set( 'footerlinks', array(
-                       'info' => array(
+               $tpl->set( 'footerlinks', [
+                       'info' => [
                                'lastmod',
                                'numberofwatchingusers',
                                'credits',
                                'copyright',
-                       ),
-                       'places' => array(
+                       ],
+                       'places' => [
                                'privacy',
                                'about',
                                'disclaimer',
-                       ),
-               ) );
+                       ],
+               ] );
 
                global $wgFooterIcons;
                $tpl->set( 'footericons', $wgFooterIcons );
@@ -426,12 +426,12 @@ class SkinTemplate extends Skin {
                $tpl->set( 'printfooter', $this->printSource() );
 
                # An ID that includes the actual body text; without categories, contentSub, ...
-               $realBodyAttribs = array( 'id' => 'mw-content-text' );
+               $realBodyAttribs = [ 'id' => 'mw-content-text' ];
 
                # Add a mw-content-ltr/rtl class to be able to style based on text direction
                # when the content is different from the UI language, i.e.:
                # not for special pages or file pages AND only when viewing
-               if ( !in_array( $title->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
+               if ( !in_array( $title->getNamespace(), [ NS_SPECIAL, NS_FILE ] ) &&
                        Action::getActionName( $this ) === 'view' ) {
                        $pageLang = $title->getPageViewLanguage();
                        $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
@@ -467,7 +467,7 @@ class SkinTemplate extends Skin {
                $tpl->set( 'reporttime', wfReportTime() );
 
                // original version by hansm
-               if ( !Hooks::run( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
+               if ( !Hooks::run( 'SkinTemplateOutputPageBeforeExec', [ &$this, &$tpl ] ) ) {
                        wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
                }
 
@@ -480,7 +480,7 @@ class SkinTemplate extends Skin {
                // start not outputting information.
                $tpl->data['bodytext'] .= Html::rawElement(
                        'div',
-                       array( 'class' => 'printfooter' ),
+                       [ 'class' => 'printfooter' ],
                        "\n{$tpl->data['printfooter']}"
                ) . "\n";
                $tpl->data['bodytext'] .= $tpl->data['debughtml'];
@@ -554,7 +554,7 @@ class SkinTemplate extends Skin {
                $pageurl = $title->getLocalURL();
 
                /* set up the default links for the personal toolbar */
-               $personal_urls = array();
+               $personal_urls = [];
 
                # Due to bug 32276, if a user does not have read permissions,
                # $this->getTitle() will just give Special:Badtitle, which is
@@ -566,7 +566,7 @@ class SkinTemplate extends Skin {
                        $page = Title::newFromText( $request->getVal( 'title', '' ) );
                }
                $page = $request->getVal( 'returnto', $page );
-               $a = array();
+               $a = [];
                if ( strval( $page ) !== '' ) {
                        $a['returnto'] = $page;
                        $query = $request->getVal( 'returntoquery', $this->thisquery );
@@ -577,34 +577,34 @@ class SkinTemplate extends Skin {
 
                $returnto = wfArrayToCgi( $a );
                if ( $this->loggedin ) {
-                       $personal_urls['userpage'] = array(
+                       $personal_urls['userpage'] = [
                                'text' => $this->username,
                                'href' => &$this->userpageUrlDetails['href'],
                                'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
                                'active' => ( $this->userpageUrlDetails['href'] == $pageurl ),
                                'dir' => 'auto'
-                       );
+                       ];
                        $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
-                       $personal_urls['mytalk'] = array(
+                       $personal_urls['mytalk'] = [
                                'text' => $this->msg( 'mytalk' )->text(),
                                'href' => &$usertalkUrlDetails['href'],
                                'class' => $usertalkUrlDetails['exists'] ? false : 'new',
                                'active' => ( $usertalkUrlDetails['href'] == $pageurl )
-                       );
+                       ];
                        $href = self::makeSpecialUrl( 'Preferences' );
-                       $personal_urls['preferences'] = array(
+                       $personal_urls['preferences'] = [
                                'text' => $this->msg( 'mypreferences' )->text(),
                                'href' => $href,
                                'active' => ( $href == $pageurl )
-                       );
+                       ];
 
                        if ( $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
                                $href = self::makeSpecialUrl( 'Watchlist' );
-                               $personal_urls['watchlist'] = array(
+                               $personal_urls['watchlist'] = [
                                        'text' => $this->msg( 'mywatchlist' )->text(),
                                        'href' => $href,
                                        'active' => ( $href == $pageurl )
-                               );
+                               ];
                        }
 
                        # We need to do an explicit check for Special:Contributions, as we
@@ -625,12 +625,12 @@ class SkinTemplate extends Skin {
                        }
 
                        $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
-                       $personal_urls['mycontris'] = array(
+                       $personal_urls['mycontris'] = [
                                'text' => $this->msg( 'mycontris' )->text(),
                                'href' => $href,
                                'active' => $active
-                       );
-                       $personal_urls['logout'] = array(
+                       ];
+                       $personal_urls['logout'] = [
                                'text' => $this->msg( 'pt-userlogout' )->text(),
                                'href' => self::makeSpecialUrl( 'Userlogout',
                                        // userlogout link must always contain an & character, otherwise we might not be able
@@ -638,7 +638,7 @@ class SkinTemplate extends Skin {
                                        $title->isSpecial( 'Preferences' ) ? 'noreturnto' : $returnto
                                ),
                                'active' => false
-                       );
+                       ];
                } else {
                        $useCombinedLoginLink = $this->useCombinedLoginLink();
                        $loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink
@@ -646,24 +646,24 @@ class SkinTemplate extends Skin {
                                : 'pt-login';
                        $is_signup = $request->getText( 'type' ) == 'signup';
 
-                       $login_url = array(
+                       $login_url = [
                                'text' => $this->msg( $loginlink )->text(),
                                'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
                                'active' => $title->isSpecial( 'Userlogin' )
                                        && ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
-                       );
-                       $createaccount_url = array(
+                       ];
+                       $createaccount_url = [
                                'text' => $this->msg( 'pt-createaccount' )->text(),
                                'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
                                'active' => $title->isSpecial( 'Userlogin' ) && $is_signup,
-                       );
+                       ];
 
                        // No need to show Talk and Contributions to anons if they can't contribute!
                        if ( User::groupHasPermission( '*', 'edit' ) ) {
                                // Show the text "Not logged in"
-                               $personal_urls['anonuserpage'] = array(
+                               $personal_urls['anonuserpage'] = [
                                        'text' => $this->msg( 'notloggedin' )->text()
-                               );
+                               ];
 
                                // Because of caching, we can't link directly to the IP talk and
                                // contributions pages. Instead we use the special page shortcuts
@@ -671,16 +671,16 @@ class SkinTemplate extends Skin {
                                // determine whether these links are active or not, but since major
                                // skins (MonoBook, Vector) don't use this information, it's not a
                                // huge loss.
-                               $personal_urls['anontalk'] = array(
+                               $personal_urls['anontalk'] = [
                                        'text' => $this->msg( 'anontalk' )->text(),
                                        'href' => self::makeSpecialUrlSubpage( 'Mytalk', false ),
                                        'active' => false
-                               );
-                               $personal_urls['anoncontribs'] = array(
+                               ];
+                               $personal_urls['anoncontribs'] = [
                                        'text' => $this->msg( 'anoncontribs' )->text(),
                                        'href' => self::makeSpecialUrlSubpage( 'Mycontributions', false ),
                                        'active' => false
-                               );
+                               ];
                        }
 
                        if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
@@ -690,7 +690,7 @@ class SkinTemplate extends Skin {
                        $personal_urls['login'] = $login_url;
                }
 
-               Hooks::run( 'PersonalUrls', array( &$personal_urls, &$title, $this ) );
+               Hooks::run( 'PersonalUrls', [ &$personal_urls, &$title, $this ] );
                return $personal_urls;
        }
 
@@ -706,7 +706,7 @@ class SkinTemplate extends Skin {
         * @return array
         */
        function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
-               $classes = array();
+               $classes = [];
                if ( $selected ) {
                        $classes[] = 'selected';
                }
@@ -734,18 +734,18 @@ class SkinTemplate extends Skin {
                                MWNamespace::getSubject( $title->getNamespace() ) );
                }
 
-               $result = array();
-               if ( !Hooks::run( 'SkinTemplateTabAction', array( &$this,
+               $result = [];
+               if ( !Hooks::run( 'SkinTemplateTabAction', [ &$this,
                                $title, $message, $selected, $checkEdit,
-                               &$classes, &$query, &$text, &$result ) ) ) {
+                               &$classes, &$query, &$text, &$result ] ) ) {
                        return $result;
                }
 
-               return array(
+               return [
                        'class' => implode( ' ', $classes ),
                        'text' => $text,
                        'href' => $title->getLocalURL( $query ),
-                       'primary' => true );
+                       'primary' => true ];
        }
 
        function makeTalkUrlDetails( $name, $urlaction = '' ) {
@@ -755,10 +755,10 @@ class SkinTemplate extends Skin {
                }
                $title = $title->getTalkPage();
                self::checkTitle( $title, $name );
-               return array(
+               return [
                        'href' => $title->getLocalURL( $urlaction ),
                        'exists' => $title->isKnown(),
-               );
+               ];
        }
 
        /**
@@ -768,10 +768,10 @@ class SkinTemplate extends Skin {
                $title = Title::newFromText( $name );
                $title = $title->getSubjectPage();
                self::checkTitle( $title, $name );
-               return array(
+               return [
                        'href' => $title->getLocalURL( $urlaction ),
                        'exists' => $title->exists(),
-               );
+               ];
        }
 
        /**
@@ -819,12 +819,12 @@ class SkinTemplate extends Skin {
                $request = $this->getRequest();
                $user = $this->getUser();
 
-               $content_navigation = array(
-                       'namespaces' => array(),
-                       'views' => array(),
-                       'actions' => array(),
-                       'variants' => array()
-               );
+               $content_navigation = [
+                       'namespaces' => [],
+                       'views' => [],
+                       'actions' => [],
+                       'variants' => []
+               ];
 
                // parameters
                $action = $request->getVal( 'action', 'view' );
@@ -832,7 +832,7 @@ class SkinTemplate extends Skin {
                $userCanRead = $title->quickUserCan( 'read', $user );
 
                $preventActiveTabs = false;
-               Hooks::run( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
+               Hooks::run( 'SkinTemplatePreventOtherActiveTabs', [ &$this, &$preventActiveTabs ] );
 
                // Checks if page is some kind of content
                if ( $title->canExist() ) {
@@ -855,7 +855,7 @@ class SkinTemplate extends Skin {
                        $skname = $this->skinname;
 
                        // Adds namespace links
-                       $subjectMsg = array( "nstab-$subjectId" );
+                       $subjectMsg = [ "nstab-$subjectId" ];
                        if ( $subjectPage->isMainPage() ) {
                                array_unshift( $subjectMsg, 'mainpage-nstab' );
                        }
@@ -864,7 +864,7 @@ class SkinTemplate extends Skin {
                        );
                        $content_navigation['namespaces'][$subjectId]['context'] = 'subject';
                        $content_navigation['namespaces'][$talkId] = $this->tabAction(
-                               $talkPage, array( "nstab-$talkId", 'talk' ), $isTalk && !$preventActiveTabs, '', $userCanRead
+                               $talkPage, [ "nstab-$talkId", 'talk' ], $isTalk && !$preventActiveTabs, '', $userCanRead
                        );
                        $content_navigation['namespaces'][$talkId]['context'] = 'talk';
 
@@ -876,7 +876,7 @@ class SkinTemplate extends Skin {
                                if ( $title->exists() || $isForeignFile ) {
                                        $content_navigation['views']['view'] = $this->tabAction(
                                                $isTalk ? $talkPage : $subjectPage,
-                                               array( "$skname-view-view", 'view' ),
+                                               [ "$skname-view-view", 'view' ],
                                                ( $onPage && ( $action == 'view' || $action == 'purge' ) ), '', true
                                        );
                                        // signal to hide this from simple content_actions
@@ -886,14 +886,14 @@ class SkinTemplate extends Skin {
                                // If it is a non-local file, show a link to the file in its own repository
                                if ( $isForeignFile ) {
                                        $file = $this->getWikiPage()->getFile();
-                                       $content_navigation['views']['view-foreign'] = array(
+                                       $content_navigation['views']['view-foreign'] = [
                                                'class' => '',
                                                'text' => wfMessageFallback( "$skname-view-foreign", 'view-foreign' )->
                                                        setContext( $this->getContext() )->
                                                        params( $file->getRepo()->getDisplayName() )->text(),
                                                'href' => $file->getDescriptionUrl(),
                                                'primary' => false,
-                                       );
+                                       ];
                                }
 
                                // Checks if user can edit the current page if it exists or create it otherwise
@@ -919,7 +919,7 @@ class SkinTemplate extends Skin {
                                        } else {
                                                $msgKey = $isForeignFile ? 'create-local' : 'create';
                                        }
-                                       $content_navigation['views']['edit'] = array(
+                                       $content_navigation['views']['edit'] = [
                                                'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection )
                                                        ? 'selected'
                                                        : ''
@@ -928,58 +928,58 @@ class SkinTemplate extends Skin {
                                                        ->setContext( $this->getContext() )->text(),
                                                'href' => $title->getLocalURL( $this->editUrlOptions() ),
                                                'primary' => !$isForeignFile, // don't collapse this in vector
-                                       );
+                                       ];
 
                                        // section link
                                        if ( $showNewSection ) {
                                                // Adds new section link
                                                // $content_navigation['actions']['addsection']
-                                               $content_navigation['views']['addsection'] = array(
+                                               $content_navigation['views']['addsection'] = [
                                                        'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
                                                        'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )
                                                                ->setContext( $this->getContext() )->text(),
                                                        'href' => $title->getLocalURL( 'action=edit&section=new' )
-                                               );
+                                               ];
                                        }
                                // Checks if the page has some kind of viewable content
                                } elseif ( $title->hasSourceText() ) {
                                        // Adds view source view link
-                                       $content_navigation['views']['viewsource'] = array(
+                                       $content_navigation['views']['viewsource'] = [
                                                'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
                                                'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )
                                                        ->setContext( $this->getContext() )->text(),
                                                'href' => $title->getLocalURL( $this->editUrlOptions() ),
                                                'primary' => true, // don't collapse this in vector
-                                       );
+                                       ];
                                }
 
                                // Checks if the page exists
                                if ( $title->exists() ) {
                                        // Adds history view link
-                                       $content_navigation['views']['history'] = array(
+                                       $content_navigation['views']['history'] = [
                                                'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
                                                'text' => wfMessageFallback( "$skname-view-history", 'history_short' )
                                                        ->setContext( $this->getContext() )->text(),
                                                'href' => $title->getLocalURL( 'action=history' ),
-                                       );
+                                       ];
 
                                        if ( $title->quickUserCan( 'delete', $user ) ) {
-                                               $content_navigation['actions']['delete'] = array(
+                                               $content_navigation['actions']['delete'] = [
                                                        'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
                                                        'text' => wfMessageFallback( "$skname-action-delete", 'delete' )
                                                                ->setContext( $this->getContext() )->text(),
                                                        'href' => $title->getLocalURL( 'action=delete' )
-                                               );
+                                               ];
                                        }
 
                                        if ( $title->quickUserCan( 'move', $user ) ) {
                                                $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
-                                               $content_navigation['actions']['move'] = array(
+                                               $content_navigation['actions']['move'] = [
                                                        'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
                                                        'text' => wfMessageFallback( "$skname-action-move", 'move' )
                                                                ->setContext( $this->getContext() )->text(),
                                                        'href' => $moveTitle->getLocalURL()
-                                               );
+                                               ];
                                        }
                                } else {
                                        // article doesn't exist or is deleted
@@ -990,26 +990,26 @@ class SkinTemplate extends Skin {
                                                        // If the user can't undelete but can view deleted
                                                        // history show them a "View .. deleted" tab instead.
                                                        $msgKey = $user->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
-                                                       $content_navigation['actions']['undelete'] = array(
+                                                       $content_navigation['actions']['undelete'] = [
                                                                'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
                                                                'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
                                                                        ->setContext( $this->getContext() )->numParams( $n )->text(),
                                                                'href' => $undelTitle->getLocalURL()
-                                                       );
+                                                       ];
                                                }
                                        }
                                }
 
                                if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
-                                       MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== array( '' )
+                                       MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
                                ) {
                                        $mode = $title->isProtected() ? 'unprotect' : 'protect';
-                                       $content_navigation['actions'][$mode] = array(
+                                       $content_navigation['actions'][$mode] = [
                                                'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
                                                'text' => wfMessageFallback( "$skname-action-$mode", $mode )
                                                        ->setContext( $this->getContext() )->text(),
                                                'href' => $title->getLocalURL( "action=$mode" )
-                                       );
+                                       ];
                                }
 
                                // Checks if the user is logged in
@@ -1024,18 +1024,18 @@ class SkinTemplate extends Skin {
                                         * the global versions.
                                         */
                                        $mode = $user->isWatched( $title ) ? 'unwatch' : 'watch';
-                                       $content_navigation['actions'][$mode] = array(
+                                       $content_navigation['actions'][$mode] = [
                                                'class' => 'mw-watchlink ' . (
                                                        $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : ''
                                                ),
                                                // uses 'watch' or 'unwatch' message
                                                'text' => $this->msg( $mode )->text(),
-                                               'href' => $title->getLocalURL( array( 'action' => $mode ) )
-                                       );
+                                               'href' => $title->getLocalURL( [ 'action' => $mode ] )
+                                       ];
                                }
                        }
 
-                       Hooks::run( 'SkinTemplateNavigation', array( &$this, &$content_navigation ) );
+                       Hooks::run( 'SkinTemplateNavigation', [ &$this, &$content_navigation ] );
 
                        if ( $userCanRead && !$wgDisableLangConversion ) {
                                $pageLang = $title->getPageLanguage();
@@ -1051,38 +1051,38 @@ class SkinTemplate extends Skin {
                                                $params = $request->getQueryValues();
                                                unset( $params['title'] );
                                        } else {
-                                               $params = array();
+                                               $params = [];
                                        }
                                        // Loops over each variant
                                        foreach ( $variants as $code ) {
                                                // Gets variant name from language code
                                                $varname = $pageLang->getVariantname( $code );
                                                // Appends variant link
-                                               $content_navigation['variants'][] = array(
+                                               $content_navigation['variants'][] = [
                                                        'class' => ( $code == $preferred ) ? 'selected' : false,
                                                        'text' => $varname,
-                                                       'href' => $title->getLocalURL( array( 'variant' => $code ) + $params ),
+                                                       'href' => $title->getLocalURL( [ 'variant' => $code ] + $params ),
                                                        'lang' => wfBCP47( $code ),
                                                        'hreflang' => wfBCP47( $code ),
-                                               );
+                                               ];
                                        }
                                }
                        }
                } else {
                        // If it's not content, it's got to be a special page
-                       $content_navigation['namespaces']['special'] = array(
+                       $content_navigation['namespaces']['special'] = [
                                'class' => 'selected',
                                'text' => $this->msg( 'nstab-special' )->text(),
                                'href' => $request->getRequestURL(), // @see: bug 2457, bug 2510
                                'context' => 'subject'
-                       );
+                       ];
 
                        Hooks::run( 'SkinTemplateNavigation::SpecialPage',
-                               array( &$this, &$content_navigation ) );
+                               [ &$this, &$content_navigation ] );
                }
 
                // Equiv to SkinTemplateContentActions
-               Hooks::run( 'SkinTemplateNavigation::Universal', array( &$this, &$content_navigation ) );
+               Hooks::run( 'SkinTemplateNavigation::Universal', [ &$this, &$content_navigation ] );
 
                // Setup xml ids and tooltip info
                foreach ( $content_navigation as $section => &$links ) {
@@ -1108,7 +1108,7 @@ class SkinTemplate extends Skin {
                # give the edit tab an accesskey, because that's fairly
                # superfluous and conflicts with an accesskey (Ctrl-E) often
                # used for editing in Safari.
-               if ( in_array( $action, array( 'edit', 'submit' ) ) ) {
+               if ( in_array( $action, [ 'edit', 'submit' ] ) ) {
                        if ( isset( $content_navigation['views']['edit'] ) ) {
                                $content_navigation['views']['edit']['tooltiponly'] = true;
                        }
@@ -1134,7 +1134,7 @@ class SkinTemplate extends Skin {
                // compatibility and also for skins that just want simple tabs content_actions
                // is now built by flattening the content_navigation arrays into one
 
-               $content_actions = array();
+               $content_actions = [];
 
                foreach ( $content_navigation as $links ) {
                        foreach ( $links as $key => $value ) {
@@ -1174,16 +1174,16 @@ class SkinTemplate extends Skin {
                $out = $this->getOutput();
                $request = $this->getRequest();
 
-               $nav_urls = array();
-               $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
+               $nav_urls = [];
+               $nav_urls['mainpage'] = [ 'href' => self::makeMainPageUrl() ];
                if ( $wgUploadNavigationUrl ) {
-                       $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
+                       $nav_urls['upload'] = [ 'href' => $wgUploadNavigationUrl ];
                } elseif ( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
-                       $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
+                       $nav_urls['upload'] = [ 'href' => self::makeSpecialUrl( 'Upload' ) ];
                } else {
                        $nav_urls['upload'] = false;
                }
-               $nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) );
+               $nav_urls['specialpages'] = [ 'href' => self::makeSpecialUrl( 'Specialpages' ) ];
 
                $nav_urls['print'] = false;
                $nav_urls['permalink'] = false;
@@ -1199,42 +1199,42 @@ class SkinTemplate extends Skin {
                // A print stylesheet is attached to all pages, but nobody ever
                // figures that out. :)  Add a link...
                if ( !$out->isPrintable() && ( $out->isArticle() || $this->getTitle()->isSpecialPage() ) ) {
-                       $nav_urls['print'] = array(
+                       $nav_urls['print'] = [
                                'text' => $this->msg( 'printableversion' )->text(),
                                'href' => $this->getTitle()->getLocalURL(
                                        $request->appendQueryValue( 'printable', 'yes' ) )
-                       );
+                       ];
                }
 
                if ( $out->isArticle() ) {
                        // Also add a "permalink" while we're at it
                        $revid = $this->getRevisionId();
                        if ( $revid ) {
-                               $nav_urls['permalink'] = array(
+                               $nav_urls['permalink'] = [
                                        'text' => $this->msg( 'permalink' )->text(),
                                        'href' => $this->getTitle()->getLocalURL( "oldid=$revid" )
-                               );
+                               ];
                        }
 
                        // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
                        Hooks::run( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink',
-                               array( &$this, &$nav_urls, &$revid, &$revid ) );
+                               [ &$this, &$nav_urls, &$revid, &$revid ] );
                }
 
                if ( $out->isArticleRelated() ) {
-                       $nav_urls['whatlinkshere'] = array(
+                       $nav_urls['whatlinkshere'] = [
                                'href' => SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage )->getLocalURL()
-                       );
+                       ];
 
-                       $nav_urls['info'] = array(
+                       $nav_urls['info'] = [
                                'text' => $this->msg( 'pageinfo-toolboxlink' )->text(),
                                'href' => $this->getTitle()->getLocalURL( "action=info" )
-                       );
+                       ];
 
                        if ( $this->getTitle()->exists() ) {
-                               $nav_urls['recentchangeslinked'] = array(
+                               $nav_urls['recentchangeslinked'] = [
                                        'href' => SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage )->getLocalURL()
-                               );
+                               ];
                        }
                }
 
@@ -1242,37 +1242,37 @@ class SkinTemplate extends Skin {
                if ( $user ) {
                        $rootUser = $user->getName();
 
-                       $nav_urls['contributions'] = array(
+                       $nav_urls['contributions'] = [
                                'text' => $this->msg( 'contributions', $rootUser )->text(),
                                'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser ),
-                               'tooltip-params' => array( $rootUser ),
-                       );
+                               'tooltip-params' => [ $rootUser ],
+                       ];
 
-                       $nav_urls['log'] = array(
+                       $nav_urls['log'] = [
                                'href' => self::makeSpecialUrlSubpage( 'Log', $rootUser )
-                       );
+                       ];
 
                        if ( $this->getUser()->isAllowed( 'block' ) ) {
-                               $nav_urls['blockip'] = array(
+                               $nav_urls['blockip'] = [
                                        'text' => $this->msg( 'blockip', $rootUser )->text(),
                                        'href' => self::makeSpecialUrlSubpage( 'Block', $rootUser )
-                               );
+                               ];
                        }
 
                        if ( $this->showEmailUser( $user ) ) {
-                               $nav_urls['emailuser'] = array(
+                               $nav_urls['emailuser'] = [
                                        'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser ),
-                                       'tooltip-params' => array( $rootUser ),
-                               );
+                                       'tooltip-params' => [ $rootUser ],
+                               ];
                        }
 
                        if ( !$user->isAnon() ) {
                                $sur = new UserrightsPage;
                                $sur->setContext( $this->getContext() );
                                if ( $sur->userCanExecute( $this->getUser() ) ) {
-                                       $nav_urls['userrights'] = array(
+                                       $nav_urls['userrights'] = [
                                                'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
-                                       );
+                                       ];
                                }
                        }
                }
index 8084a66..9e3a620 100644 (file)
@@ -23,20 +23,20 @@ class SkinTemplateTest extends MediaWikiTestCase {
        }
 
        public function makeListItemProvider() {
-               return array(
-                       array(
+               return [
+                       [
                                '<li class="class" title="itemtitle"><a href="url" title="title">text</a></li>',
                                '',
-                               array(
+                               [
                                        'class' => 'class',
                                        'itemtitle' => 'itemtitle',
                                        'href' => 'url',
                                        'title' => 'title',
                                        'text' => 'text'
-                               ),
-                               array(),
+                               ],
+                               [],
                                'Test makteListItem with normal values'
-                       )
-               );
+                       ]
+               ];
        }
 }
index a3122b9..81e2c65 100644 (file)
@@ -17,14 +17,14 @@ class SideBarTest extends MediaWikiLangTestCase {
        private function initMessagesHref() {
                # List of default messages for the sidebar. The sidebar doesn't care at
                # all whether they are full URLs, interwiki links or local titles.
-               $URL_messages = array(
+               $URL_messages = [
                        'mainpage',
                        'portal-url',
                        'currentevents-url',
                        'recentchanges-url',
                        'randompage-url',
                        'helppage',
-               );
+               ];
 
                # We're assuming that isValidURI works as advertised: it's also
                # tested separately, in tests/phpunit/includes/HttpTest.php.
@@ -54,7 +54,7 @@ class SideBarTest extends MediaWikiLangTestCase {
         * @todo this assert method to should be converted to a test using a dataprovider..
         */
        private function assertSideBar( $expected, $text, $message = '' ) {
-               $bar = array();
+               $bar = [];
                $this->skin->addToSidebarPlain( $bar, $text );
                $this->assertEquals( $expected, $bar, $message );
        }
@@ -64,10 +64,10 @@ class SideBarTest extends MediaWikiLangTestCase {
         */
        public function testSidebarWithOnlyTwoTitles() {
                $this->assertSideBar(
-                       array(
-                               'Title1' => array(),
-                               'Title2' => array(),
-                       ),
+                       [
+                               'Title1' => [],
+                               'Title2' => [],
+                       ],
                        '* Title1
 * Title2
 '
@@ -79,14 +79,14 @@ class SideBarTest extends MediaWikiLangTestCase {
         */
        public function testExpandMessages() {
                $this->assertSidebar(
-                       array( 'Title' => array(
-                               array(
+                       [ 'Title' => [
+                               [
                                        'text' => 'Help',
                                        'href' => $this->messages['helppage']['href'],
                                        'id' => 'n-help',
                                        'active' => null
-                               )
-                       ) ),
+                               ]
+                       ] ],
                        '* Title
 ** helppage|help
 '
@@ -97,24 +97,24 @@ class SideBarTest extends MediaWikiLangTestCase {
         * @covers SkinTemplate::addToSidebarPlain
         */
        public function testExternalUrlsRequireADescription() {
-               $this->setMwGlobals( array(
+               $this->setMwGlobals( [
                        'wgNoFollowLinks' => true,
-                       'wgNoFollowDomainExceptions' => array(),
-                       'wgNoFollowNsExceptions' => array(),
-               ) );
+                       'wgNoFollowDomainExceptions' => [],
+                       'wgNoFollowNsExceptions' => [],
+               ] );
                $this->assertSidebar(
-                       array( 'Title' => array(
+                       [ 'Title' => [
                                # ** http://www.mediawiki.org/| Home
-                               array(
+                               [
                                        'text' => 'Home',
                                        'href' => 'http://www.mediawiki.org/',
                                        'id' => 'n-Home',
                                        'active' => null,
                                        'rel' => 'nofollow',
-                               ),
+                               ],
                                # ** http://valid.no.desc.org/
                                # ... skipped since it is missing a pipe with a description
-                       ) ),
+                       ] ],
                        '* Title
 ** http://www.mediawiki.org/| Home
 ** http://valid.no.desc.org/
@@ -129,24 +129,24 @@ class SideBarTest extends MediaWikiLangTestCase {
         */
        public function testTrickyPipe() {
                $this->assertSidebar(
-                       array( 'Title' => array(
+                       [ 'Title' => [
                                # The first 2 are skipped
                                # Doesn't really test the url properly
                                # because it will vary with $wgArticlePath et al.
                                # ** Baz|Fred
-                               array(
+                               [
                                        'text' => 'Fred',
                                        'href' => Title::newFromText( 'Baz' )->getLocalURL(),
                                        'id' => 'n-Fred',
                                        'active' => null,
-                               ),
-                               array(
+                               ],
+                               [
                                        'text' => 'title-to-display',
                                        'href' => Title::newFromText( 'page-to-go-to' )->getLocalURL(),
                                        'id' => 'n-title-to-display',
                                        'active' => null,
-                               ),
-                       ) ),
+                               ],
+                       ] ],
                        '* Title
 ** {{PAGENAME|Foo}}
 ** Bar
@@ -162,7 +162,7 @@ class SideBarTest extends MediaWikiLangTestCase {
                $text = '* Title
 ** http://www.mediawiki.org/| Home';
 
-               $bar = array();
+               $bar = [];
                $this->skin->addToSideBarPlain( $bar, $text );
 
                return $bar['Title'][0];
@@ -172,12 +172,12 @@ class SideBarTest extends MediaWikiLangTestCase {
         * Simple test to verify our helper assertAttribs() is functional
         */
        public function testTestAttributesAssertionHelper() {
-               $this->setMwGlobals( array(
+               $this->setMwGlobals( [
                        'wgNoFollowLinks' => true,
-                       'wgNoFollowDomainExceptions' => array(),
-                       'wgNoFollowNsExceptions' => array(),
+                       'wgNoFollowDomainExceptions' => [],
+                       'wgNoFollowNsExceptions' => [],
                        'wgExternalLinkTarget' => false,
-               ) );
+               ] );
                $attribs = $this->getAttribs();
 
                $this->assertArrayHasKey( 'rel', $attribs );
@@ -211,9 +211,9 @@ class SideBarTest extends MediaWikiLangTestCase {
        }
 
        public static function dataRespectExternallinktarget() {
-               return array(
-                       array( '_blank' ),
-                       array( '_self' ),
-               );
+               return [
+                       [ '_blank' ],
+                       [ '_self' ],
+               ];
        }
 }