Make phpcs-strict pass on includes/ (1/~10)
authorSiebrand Mazeland <siebrand@kitano.nl>
Sun, 11 May 2014 15:32:18 +0000 (17:32 +0200)
committerReedy <reedy@wikimedia.org>
Sun, 11 May 2014 19:14:17 +0000 (19:14 +0000)
Change-Id: Ib51381a2261d064988ba2f39b71c0252f2458faf

includes/FeedUtils.php
includes/FileDeleteForm.php
includes/GlobalFunctions.php
includes/Hooks.php
includes/Html.php
includes/HtmlFormatter.php
includes/ImageQueryPage.php
includes/Init.php
includes/Licenses.php
includes/Message.php

index d407a0e..83ce755 100644 (file)
@@ -102,7 +102,9 @@ class FeedUtils {
         * @param string $actiontext Text of the action; in case of log event
         * @return string
         */
-       public static function formatDiffRow( $title, $oldid, $newid, $timestamp, $comment, $actiontext = '' ) {
+       public static function formatDiffRow( $title, $oldid, $newid, $timestamp,
+               $comment, $actiontext = ''
+       ) {
                global $wgFeedDiffCutoff, $wgLang;
                wfProfileIn( __METHOD__ );
 
@@ -245,9 +247,15 @@ class FeedUtils {
                        'diff'             => 'background-color: white; color:black;',
                        'diff-otitle'      => 'background-color: white; color:black; text-align: center;',
                        'diff-ntitle'      => 'background-color: white; color:black; text-align: center;',
-                       'diff-addedline'   => 'color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;',
-                       'diff-deletedline' => 'color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;',
-                       'diff-context'     => 'background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;',
+                       'diff-addedline'   => 'color:black; font-size: 88%; border-style: solid; '
+                               . 'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; '
+                               . 'vertical-align: top; white-space: pre-wrap;',
+                       'diff-deletedline' => 'color:black; font-size: 88%; border-style: solid; '
+                               . 'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; '
+                               . 'vertical-align: top; white-space: pre-wrap;',
+                       'diff-context'     => 'background-color: #f9f9f9; color: #333333; font-size: 88%; '
+                               . 'border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; '
+                               . 'border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;',
                        'diffchange'       => 'font-weight: bold; text-decoration: none;',
                );
 
index 642c49e..b4e2458 100644 (file)
@@ -83,7 +83,10 @@ class FileDeleteForm {
                $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' );
 
                if ( $this->oldimage ) {
-                       $this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
+                       $this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName(
+                               $this->title,
+                               $this->oldimage
+                       );
                }
 
                if ( !self::haveDeletableFile( $this->file, $this->oldfile, $this->oldimage ) ) {
@@ -107,11 +110,20 @@ class FileDeleteForm {
                                $reason = $deleteReasonList;
                        }
 
-                       $status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress, $wgUser );
+                       $status = self::doDelete(
+                               $this->title,
+                               $this->file,
+                               $this->oldimage,
+                               $reason,
+                               $suppress,
+                               $wgUser
+                       );
 
                        if ( !$status->isGood() ) {
                                $wgOut->addHTML( '<h2>' . $this->prepareMessage( 'filedeleteerror-short' ) . "</h2>\n" );
-                               $wgOut->addWikiText( '<div class="error">' . $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) . '</div>' );
+                               $wgOut->addWikiText( '<div class="error">' .
+                                       $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' )
+                                       . '</div>' );
                        }
                        if ( $status->ok ) {
                                $wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
@@ -141,7 +153,9 @@ class FileDeleteForm {
         * @throws MWException
         * @return bool|Status
         */
-       public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress, User $user = null ) {
+       public static function doDelete( &$title, &$file, &$oldimage, $reason,
+               $suppress, User $user = null
+       ) {
                if ( $user === null ) {
                        global $wgUser;
                        $user = $wgUser;
@@ -188,7 +202,8 @@ class FileDeleteForm {
                                        }
                                }
                        } catch ( MWException $e ) {
-                               // rollback before returning to prevent UI from displaying incorrect "View or restore N deleted edits?"
+                               // Rollback before returning to prevent UI from displaying
+                               // incorrect "View or restore N deleted edits?"
                                $dbw->rollback( __METHOD__ );
                                throw $e;
                        }
@@ -266,8 +281,14 @@ class FileDeleteForm {
                        <tr>
                                <td></td>
                                <td class='mw-submit'>" .
-                                       Xml::submitButton( wfMessage( 'filedelete-submit' )->text(),
-                                               array( 'name' => 'mw-filedelete-submit', 'id' => 'mw-filedelete-submit', 'tabindex' => '4' ) ) .
+                                       Xml::submitButton(
+                                               wfMessage( 'filedelete-submit' )->text(),
+                                               array(
+                                                       'name' => 'mw-filedelete-submit',
+                                                       'id' => 'mw-filedelete-submit',
+                                                       'tabindex' => '4'
+                                               )
+                                       ) .
                                "</td>
                        </tr>" .
                        Xml::closeElement( 'table' ) .
@@ -309,8 +330,10 @@ class FileDeleteForm {
        private function prepareMessage( $message ) {
                global $wgLang;
                if ( $this->oldimage ) {
+                       # Message keys used:
+                       # 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
                        return wfMessage(
-                               "{$message}-old", # To ensure grep will find them: 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
+                               "{$message}-old",
                                wfEscapeWikiText( $this->title->getText() ),
                                $wgLang->date( $this->getTimestamp(), true ),
                                $wgLang->time( $this->getTimestamp(), true ),
index d94d2f1..ed99aa9 100644 (file)
@@ -2922,8 +2922,10 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(),
                $readyPipes = $pipes;
 
                // Clear last error
+               // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged
                @trigger_error( '' );
                if ( @stream_select( $readyPipes, $emptyArray, $emptyArray, null ) === false ) {
+                       // @codingStandardsIgnoreEnd
                        $error = error_get_last();
                        if ( strncmp( $error['message'], $eintrMessage, strlen( $eintrMessage ) ) == 0 ) {
                                continue;
@@ -3407,9 +3409,11 @@ function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1,
                        $decimal = bcadd( $decimal, $baseChars[$char] );
                }
 
+               // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
                for ( $result = ''; bccomp( $decimal, 0 ); $decimal = bcdiv( $decimal, $destBase, 0 ) ) {
                        $result .= $baseChars[bcmod( $decimal, $destBase )];
                }
+               // @codingStandardsIgnoreEnd
 
                $result = strrev( $result );
        } else {
index 785e717..89457e8 100644 (file)
@@ -27,7 +27,8 @@
 /**
  * @since 1.18
  */
-class MWHookException extends MWException {}
+class MWHookException extends MWException {
+}
 
 /**
  * Hooks class.
@@ -37,7 +38,6 @@ class MWHookException extends MWException {}
  * @since 1.18
  */
 class Hooks {
-
        /**
         * Array of events mapped to an array of callbacks to be run
         * when that event is triggered.
index 2a8c9b1..5262ffe 100644 (file)
@@ -695,16 +695,20 @@ class Html {
         *
         * @param array $params Params to set.
         * - selected: [optional] Id of namespace which should be pre-selected
-        * - all: [optional] Value of item for "all namespaces". If null or unset, no "<option>" is generated to select all namespaces
-        * - label: text for label to add before the field
-        * - exclude: [optional] Array of namespace ids to exclude
-        * - disable: [optional] Array of namespace ids for which the option should be disabled in the selector
+        * - all: [optional] Value of item for "all namespaces". If null or unset,
+        *   no "<option>" is generated to select all namespaces.
+        * - label: text for label to add before the field.
+        * - exclude: [optional] Array of namespace ids to exclude.
+        * - disable: [optional] Array of namespace ids for which the option should
+        *   be disabled in the selector.
         * @param array $selectAttribs HTML attributes for the generated select element.
-        * - id:   [optional], default: 'namespace'
-        * - name: [optional], default: 'namespace'
+        * - id:   [optional], default: 'namespace'.
+        * - name: [optional], default: 'namespace'.
         * @return string HTML code to select a namespace.
         */
-       public static function namespaceSelector( array $params = array(), array $selectAttribs = array() ) {
+       public static function namespaceSelector( array $params = array(),
+               array $selectAttribs = array()
+       ) {
                global $wgContLang;
 
                ksort( $selectAttribs );
index 987a683..b2209c3 100644 (file)
@@ -259,7 +259,8 @@ class HtmlFormatter {
         * specify the $element in the method it'll change the underlying dom and you won't be able to get
         * it back.
         *
-        * @param DOMElement|string|null $element ID of element to get HTML from or false to get it from the whole tree
+        * @param DOMElement|string|null $element ID of element to get HTML from or
+        *   false to get it from the whole tree
         * @return string Processed HTML
         */
        public function getText( $element = null ) {
index 75f7ba6..b5bddf0 100644 (file)
@@ -47,7 +47,9 @@ abstract class ImageQueryPage extends QueryPage {
 
                        # $res might contain the whole 1,000 rows, so we read up to
                        # $num [should update this to use a Pager]
+                       // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
                        for ( $i = 0; $i < $num && $row = $dbr->fetchObject( $res ); $i++ ) {
+                               // @codingStandardsIgnoreEnd
                                $namespace = isset( $row->namespace ) ? $row->namespace : NS_FILE;
                                $title = Title::makeTitleSafe( $namespace, $row->title );
                                if ( $title instanceof Title && $title->getNamespace() == NS_FILE ) {
@@ -60,7 +62,8 @@ abstract class ImageQueryPage extends QueryPage {
        }
 
        // Gotta override this since it's abstract
-       function formatResult( $skin, $result ) { }
+       function formatResult( $skin, $result ) {
+       }
 
        /**
         * Get additional HTML to be shown in a results' cell
index 5b1dc83..d9aeb7b 100644 (file)
@@ -31,7 +31,7 @@
  * deprecated.
  */
 class MWInit {
-       static $compilerVersion;
+       private static $compilerVersion;
 
        /**
         * @deprecated since 1.22
index e3db5b4..54b779e 100644 (file)
  * A License class for use on Special:Upload
  */
 class Licenses extends HTMLFormField {
-       /**
-        * @var string
-        */
+       /** @var string */
        protected $msg;
 
-       /**
-        * @var array
-        */
+       /** @var array */
        protected $licenses = array();
 
-       /**
-        * @var string
-        */
+       /** @var string */
        protected $html;
        /**#@-*/
 
        /**
-        * Constructor
-        *
         * @param array $params
         */
        public function __construct( $params ) {
                parent::__construct( $params );
 
-               $this->msg = empty( $params['licenses'] ) ? wfMessage( 'licenses' )->inContentLanguage()->plain() : $params['licenses'];
+               $this->msg = empty( $params['licenses'] )
+                       ? wfMessage( 'licenses' )->inContentLanguage()->plain()
+                       : $params['licenses'];
                $this->selected = null;
 
                $this->makeLicenses();
@@ -198,19 +192,13 @@ class Licenses extends HTMLFormField {
  * A License class for use on Special:Upload (represents a single type of license).
  */
 class License {
-       /**
-        * @var string
-        */
-       var $template;
+       /** @var string */
+       public $template;
 
-       /**
-        * @var string
-        */
-       var $text;
+       /** @var string */
+       public $text;
 
        /**
-        * Constructor
-        *
         * @param string $str license name??
         */
        function __construct( $str ) {
index 31fbb07..179aca7 100644 (file)
@@ -960,7 +960,14 @@ class Message {
         * @return string Wikitext parsed into HTML.
         */
        protected function parseText( $string ) {
-               $out = MessageCache::singleton()->parse( $string, $this->title, /*linestart*/true, $this->interface, $this->language );
+               $out = MessageCache::singleton()->parse(
+                       $string,
+                       $this->title,
+                        /*linestart*/true,
+                       $this->interface,
+                       $this->language
+               );
+
                return $out instanceof ParserOutput ? $out->getText() : $out;
        }
 
@@ -974,7 +981,12 @@ class Message {
         * @return string Wikitext with {{-constructs replaced with their values.
         */
        protected function transformText( $string ) {
-               return MessageCache::singleton()->transform( $string, $this->interface, $this->language, $this->title );
+               return MessageCache::singleton()->transform(
+                       $string,
+                       $this->interface,
+                       $this->language,
+                       $this->title
+               );
        }
 
        /**