From: Siebrand Mazeland Date: Sun, 11 May 2014 15:33:33 +0000 (+0200) Subject: Make phpcs-strict pass on includes/ (2/~10) X-Git-Tag: 1.31.0-rc.0~15753 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%22id_auteur=%24connect_id_auteur%22%29%20.%20%22?a=commitdiff_plain;h=49cffd699c30cd0c538c6e717254d88dd44147d2;p=lhc%2Fweb%2Fwiklou.git Make phpcs-strict pass on includes/ (2/~10) Change-Id: I59fa9af7b16e0a5a4eb8a5cc764a605b18137316 --- diff --git a/includes/MessageBlobStore.php b/includes/MessageBlobStore.php index f5b346c453..5725898420 100644 --- a/includes/MessageBlobStore.php +++ b/includes/MessageBlobStore.php @@ -32,7 +32,6 @@ * constituent messages or the resource itself is changed. */ class MessageBlobStore { - /** * Get the message blobs for a set of modules * @@ -128,7 +127,8 @@ class MessageBlobStore { * @param string $name Module name * @param ResourceLoaderModule $module * @param string $lang Language code - * @return string Regenerated message blob, or null if there was no blob for the given module/language pair + * @return string Regenerated message blob, or null if there was no blob for + * the given module/language pair. */ public static function updateModule( $name, ResourceLoaderModule $module, $lang ) { $dbw = wfGetDB( DB_MASTER ); @@ -331,6 +331,7 @@ class MessageBlobStore { */ private static function getFromDB( ResourceLoader $resourceLoader, $modules, $lang ) { global $wgCacheEpoch; + $retval = array(); $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'msg_resource', @@ -345,10 +346,14 @@ class MessageBlobStore { // This shouldn't be possible throw new MWException( __METHOD__ . ' passed an invalid module name' ); } + // Update the module's blobs if the set of messages changed or if the blob is // older than $wgCacheEpoch - if ( array_keys( FormatJson::decode( $row->mr_blob, true ) ) !== array_values( array_unique( $module->getMessages() ) ) || - wfTimestamp( TS_MW, $row->mr_timestamp ) <= $wgCacheEpoch ) { + $keys = array_keys( FormatJson::decode( $row->mr_blob, true ) ); + $values = array_values( array_unique( $module->getMessages() ) ); + if ( $keys !== $values + || wfTimestamp( TS_MW, $row->mr_timestamp ) <= $wgCacheEpoch + ) { $retval[$row->mr_resource] = self::updateModule( $row->mr_resource, $module, $lang ); } else { $retval[$row->mr_resource] = $row->mr_blob; diff --git a/includes/OutputHandler.php b/includes/OutputHandler.php index c783fd3344..b3b3b889a7 100644 --- a/includes/OutputHandler.php +++ b/includes/OutputHandler.php @@ -164,7 +164,10 @@ function wfMangleFlashPolicy( $s ) { * @param int $length */ function wfDoContentLength( $length ) { - if ( !headers_sent() && isset( $_SERVER['SERVER_PROTOCOL'] ) && $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0' ) { + if ( !headers_sent() + && isset( $_SERVER['SERVER_PROTOCOL'] ) + && $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0' + ) { header( "Content-Length: $length" ); } } diff --git a/includes/PHPVersionError.php b/includes/PHPVersionError.php index 9b5373b509..0fb3952bd4 100644 --- a/includes/PHPVersionError.php +++ b/includes/PHPVersionError.php @@ -43,10 +43,13 @@ function wfPHPVersionError( $type ) { $phpVersion = phpversion(); $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; - $message = "MediaWiki $mwVersion requires at least PHP version $minimumVersionPHP, you are using PHP $phpVersion."; + $message = "MediaWiki $mwVersion requires at least " + . "PHP version $minimumVersionPHP, you are using PHP $phpVersion."; + if ( $type == 'cli' ) { - $finalOutput = "You are using PHP version $phpVersion but MediaWiki $mwVersion needs PHP $minimumVersionPHP or higher. ABORTING.\n" . - "Check if you have a newer php executable with a different name, such as php5.\n"; + $finalOutput = "You are using PHP version $phpVersion " + . "but MediaWiki $mwVersion needs PHP $minimumVersionPHP or higher. ABORTING.\n" + . "Check if you have a newer php executable with a different name, such as php5.\n"; } elseif ( $type == 'index.php' ) { $pathinfo = pathinfo( $_SERVER['SCRIPT_NAME'] ); $encLogo = htmlspecialchars( diff --git a/includes/Pager.php b/includes/Pager.php index 33bf067bad..5f054601a8 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -365,7 +365,9 @@ abstract class IndexPager extends ContextSource implements Pager { * @return ResultWrapper */ public function reallyDoQuery( $offset, $limit, $descending ) { - list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo( $offset, $limit, $descending ); + list( $tables, $fields, $conds, $fname, $options, $join_conds ) = + $this->buildQueryInfo( $offset, $limit, $descending ); + return $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds ); } @@ -409,7 +411,8 @@ abstract class IndexPager extends ContextSource implements Pager { * * @param ResultWrapper $result */ - protected function preprocessResults( $result ) {} + protected function preprocessResults( $result ) { + } /** * Get the formatted result list. Calls getStartBody(), formatRow() and @@ -491,7 +494,8 @@ abstract class IndexPager extends ContextSource implements Pager { * * @return void */ - protected function doBatchLookups() {} + protected function doBatchLookups() { + } /** * Hook into getBody(), allows text to be inserted at the start. This @@ -924,8 +928,9 @@ abstract class ReverseChronologicalPager extends IndexPager { * @ingroup Pager */ abstract class TablePager extends IndexPager { - var $mSort; - var $mCurrentRow; + protected $mSort; + + protected $mCurrentRow; public function __construct( IContextSource $context = null ) { if ( $context ) { @@ -995,7 +1000,10 @@ abstract class TablePager extends IndexPager { } $tableClass = $this->getTableClass(); - $ret = Html::openElement( 'table', array( 'style' => 'border:1px;', 'class' => "mw-datatable $tableClass" ) ); + $ret = Html::openElement( 'table', array( + 'style' => 'border:1px;', + 'class' => "mw-datatable $tableClass" ) + ); $ret .= Html::rawElement( 'thead', array(), Html::rawElement( 'tr', array(), "\n" . $s . "\n" ) ); $ret .= Html::openElement( 'tbody' ) . "\n"; diff --git a/includes/Preferences.php b/includes/Preferences.php index 493626a0d1..13e94ddd7a 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -46,14 +46,17 @@ * over to the tryUISubmit static method of this class. */ class Preferences { - static $defaultPreferences = null; - static $saveFilters = array( - 'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ), - 'cols' => array( 'Preferences', 'filterIntval' ), - 'rows' => array( 'Preferences', 'filterIntval' ), - 'rclimit' => array( 'Preferences', 'filterIntval' ), - 'wllimit' => array( 'Preferences', 'filterIntval' ), - 'searchlimit' => array( 'Preferences', 'filterIntval' ), + /** @var array */ + protected static $defaultPreferences = null; + + /** @var array */ + protected static $saveFilters = array( + 'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ), + 'cols' => array( 'Preferences', 'filterIntval' ), + 'rows' => array( 'Preferences', 'filterIntval' ), + 'rclimit' => array( 'Preferences', 'filterIntval' ), + 'wllimit' => array( 'Preferences', 'filterIntval' ), + 'searchlimit' => array( 'Preferences', 'filterIntval' ), ); // Stuff that shouldn't be saved as a preference. @@ -1401,7 +1404,10 @@ class Preferences { // Fortunately, the realname field is MUCH simpler // (not really "private", but still shouldn't be edited without permission) - if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) && array_key_exists( 'realname', $formData ) ) { + if ( !in_array( 'realname', $wgHiddenPrefs ) + && $user->isAllowed( 'editmyprivateinfo' ) + && array_key_exists( 'realname', $formData ) + ) { $realName = $formData['realname']; $user->setRealName( $realName ); } diff --git a/includes/PrefixSearch.php b/includes/PrefixSearch.php index c5dd698940..a796d35723 100644 --- a/includes/PrefixSearch.php +++ b/includes/PrefixSearch.php @@ -121,7 +121,7 @@ abstract class PrefixSearch { * @param array $titles * @return array */ - protected abstract function titles( array $titles ); + abstract protected function titles( array $titles ); /** * When implemented in a descendant class, receives an array of titles as strings and returns @@ -131,7 +131,7 @@ abstract class PrefixSearch { * * @return array */ - protected abstract function strings( array $strings ); + abstract protected function strings( array $strings ); /** * Do a prefix search of titles and return a list of matching page names. @@ -296,7 +296,9 @@ class TitlePrefixSearch extends PrefixSearch { class StringPrefixSearch extends PrefixSearch { protected function titles( array $titles ) { - return array_map( function( Title $t ) { return $t->getPrefixedText(); }, $titles ); + return array_map( function ( Title $t ) { + return $t->getPrefixedText(); + }, $titles ); } protected function strings( array $strings ) { diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index 67cf70ca05..1ea6523203 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -459,7 +459,10 @@ class Sanitizer { $badtag = true; } elseif ( $slash ) { # Closing a tag... is it the one we just opened? - $ot = @array_pop( $tagstack ); + wfSuppressWarnings(); + $ot = array_pop( $tagstack ); + wfRestoreWarnings(); + if ( $ot != $t ) { if ( isset( $htmlsingleallowed[$ot] ) ) { # Pop all elements with an optional close tag @@ -489,7 +492,10 @@ class Sanitizer { } } } else { - @array_push( $tagstack, $ot ); + wfSuppressWarnings(); + array_push( $tagstack, $ot ); + wfRestoreWarnings(); + #
  • can be nested in