From: umherirrender Date: Sun, 1 Nov 2015 19:56:20 +0000 (+0100) Subject: phpcs: Fix some "Assignment expression not allowed" X-Git-Tag: 1.31.0-rc.0~9150^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=96473ea6e484cae15981d11b13c211d55ddaf14c;p=lhc%2Fweb%2Fwiklou.git phpcs: Fix some "Assignment expression not allowed" Found by new version of mediawiki/codesniffer https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs/1939/consoleFull Change-Id: I673f71fd0dfc8d6ba1ce6c3d5da21787ff95cb32 --- diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index f88dd057e7..a856f1ee10 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -476,7 +476,8 @@ class Sanitizer { } $badtag = false; - if ( isset( $htmlelements[$t = strtolower( $t )] ) ) { + $t = strtolower( $t ); + if ( isset( $htmlelements[$t] ) ) { # Check our stack if ( $slash && isset( $htmlsingleonly[$t] ) ) { $badtag = true; @@ -596,7 +597,8 @@ class Sanitizer { list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs; $badtag = false; - if ( isset( $htmlelements[$t = strtolower( $t )] ) ) { + $t = strtolower( $t ); + if ( isset( $htmlelements[$t] ) ) { if ( is_callable( $processCallback ) ) { call_user_func_array( $processCallback, array( &$params, $args ) ); } diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 5208c23876..f7ba4d28a5 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -708,8 +708,11 @@ class ResourceLoader implements LoggerAwareInterface { // Capture any PHP warnings from the output buffer and append them to the // error list if we're in debug mode. - if ( $context->getDebug() && strlen( $warnings = ob_get_contents() ) ) { - $this->errors[] = $warnings; + if ( $context->getDebug() ) { + $warnings = ob_get_contents(); + if ( strlen( $warnings ) ) { + $this->errors[] = $warnings; + } } // Save response to file cache unless there are errors @@ -877,8 +880,11 @@ class ResourceLoader implements LoggerAwareInterface { $response = $fileCache->fetchText(); // Capture any PHP warnings from the output buffer and append them to the // response in a comment if we're in debug mode. - if ( $context->getDebug() && strlen( $warnings = ob_get_contents() ) ) { - $response = self::makeComment( $warnings ) . $response; + if ( $context->getDebug() ) { + $warnings = ob_get_contents(); + if ( strlen( $warnings ) ) { + $response = self::makeComment( $warnings ) . $response; + } } // Remove the output buffer and output the response ob_end_clean(); diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 9672580d8c..f0a5aa6c89 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -107,7 +107,8 @@ class SpecialContributions extends IncludableSpecialPage { )->inContentLanguage() ); } - if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) { + $ns = $request->getVal( 'namespace', null ); + if ( $ns !== null && $ns !== '' ) { $this->opts['namespace'] = intval( $ns ); } else { $this->opts['namespace'] = ''; diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index 44352a78b5..6f8e786e5f 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -413,7 +413,8 @@ class DeletedContributionsPage extends SpecialPage { $target = $userObj->getName(); $out->addSubtitle( $this->getSubTitle( $userObj ) ); - if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) { + $ns = $request->getVal( 'namespace', null ); + if ( $ns !== null && $ns !== '' ) { $options['namespace'] = intval( $ns ); } else { $options['namespace'] = ''; diff --git a/includes/title/MediaWikiTitleCodec.php b/includes/title/MediaWikiTitleCodec.php index 6b2e87714b..0fb208ea35 100644 --- a/includes/title/MediaWikiTitleCodec.php +++ b/includes/title/MediaWikiTitleCodec.php @@ -255,7 +255,8 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser { $m = array(); if ( preg_match( $prefixRegexp, $dbkey, $m ) ) { $p = $m[1]; - if ( ( $ns = $this->language->getNsIndex( $p ) ) !== false ) { + $ns = $this->language->getNsIndex( $p ); + if ( $ns !== false ) { # Ordinary namespace $dbkey = $m[2]; $parts['namespace'] = $ns; diff --git a/includes/utils/MWCryptRand.php b/includes/utils/MWCryptRand.php index 53c77c22cc..10606c16d0 100644 --- a/includes/utils/MWCryptRand.php +++ b/includes/utils/MWCryptRand.php @@ -97,7 +97,8 @@ class MWCryptRand { } } // The absolute filename itself will differ from install to install so don't leave it out - if ( ( $path = realpath( $file ) ) !== false ) { + $path = realpath( $file ); + if ( $path !== false ) { $state .= $path; } else { $state .= $file; diff --git a/maintenance/importDump.php b/maintenance/importDump.php index bf594952c9..8cea5a2c5d 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -119,7 +119,8 @@ TEXT; private function getNsIndex( $namespace ) { global $wgContLang; - if ( ( $result = $wgContLang->getNsIndex( $namespace ) ) !== false ) { + $result = $wgContLang->getNsIndex( $namespace ); + if ( $result !== false ) { return $result; } $ns = intval( $namespace );