diff options
author | Thiemo Kreuz <thiemo.kreuz@wikimedia.de> | 2019-01-09 17:24:36 +0100 |
---|---|---|
committer | Thiemo Kreuz <thiemo.kreuz@wikimedia.de> | 2019-01-15 17:28:49 +0100 |
commit | 734a969d5506a80ceabfa2bc61bda79f76d73d5f (patch) | |
tree | eaa619f76fce39e07f8e755593bb0cd7c80520ad | |
parent | a4880e9bbfd90642cfa5b852bdabf4101760f092 (diff) | |
download | mediawikicore-734a969d5506a80ceabfa2bc61bda79f76d73d5f.tar.gz mediawikicore-734a969d5506a80ceabfa2bc61bda79f76d73d5f.zip |
Safe replacement of a lot of `!count()` with `=== []`
This was originally a global search and replace. I manually checked all
replacements and reverted them if (due to the lack of type hints) either
null (that would be 0 when counted) or a Countable object can end in the
variable or property in question.
Now this patch only touches places where I'm sure nothing can break.
For the sanity of the honorable reviewers this patch is exclusively touching
negated counts. You should not find a single `!== []` in this patch, that
would be a mistake.
Change-Id: I5eafd4d8fccdb53a668be8e6f25a566f9c3a0a95
40 files changed, 55 insertions, 56 deletions
diff --git a/includes/Block.php b/includes/Block.php index fb3caf658c7d..7138301d94df 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -1307,7 +1307,7 @@ class Block { * @since 1.22 */ public static function getBlocksForIPList( array $ipChain, $isAnon, $fromMaster = false ) { - if ( !count( $ipChain ) ) { + if ( $ipChain === [] ) { return []; } @@ -1332,7 +1332,7 @@ class Block { $conds[] = self::getRangeCond( IP::toHex( $ipaddr ) ); } - if ( !count( $conds ) ) { + if ( $conds === [] ) { return []; } @@ -1388,7 +1388,7 @@ class Block { * @return Block|null The "best" block from the list */ public static function chooseBlock( array $blocks, array $ipChain ) { - if ( !count( $blocks ) ) { + if ( $blocks === [] ) { return null; } elseif ( count( $blocks ) == 1 ) { return $blocks[0]; diff --git a/includes/HistoryBlob.php b/includes/HistoryBlob.php index 1d4f6e4e8d8e..bca6c7e5bc5f 100644 --- a/includes/HistoryBlob.php +++ b/includes/HistoryBlob.php @@ -445,8 +445,7 @@ class DiffHistoryBlob implements HistoryBlob { // Already compressed return; } - if ( !count( $this->mItems ) ) { - // Empty + if ( $this->mItems === [] ) { return; } @@ -492,7 +491,7 @@ class DiffHistoryBlob implements HistoryBlob { $this->mDiffs = []; $this->mDiffMap = []; foreach ( $sequences as $seq ) { - if ( !count( $seq['diffs'] ) ) { + if ( $seq['diffs'] === [] ) { continue; } if ( $tail === '' ) { @@ -627,8 +626,7 @@ class DiffHistoryBlob implements HistoryBlob { */ function __sleep() { $this->compress(); - if ( !count( $this->mItems ) ) { - // Empty object + if ( $this->mItems === [] ) { $info = false; } else { // Take forward differences to improve the compression ratio for sequences diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 7d5f6e2a5901..7b5df5047d2c 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -94,7 +94,7 @@ class ApiQueryAllUsers extends ApiQueryBase { } // no group with the given right(s) exists, no need for a query - if ( !count( $groups ) ) { + if ( $groups === [] ) { $this->getResult()->addIndexedTagName( [ 'query', $this->getModuleName() ], '' ); return; diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index d9fe50b8d605..c92f037c9cc2 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -277,7 +277,7 @@ abstract class ApiQueryBase extends ApiBase { if ( count( $ids ) ) { $ids = $this->filterIDs( [ [ $table, $field ] ], $ids ); - if ( !count( $ids ) ) { + if ( $ids === [] ) { // Return nothing, no IDs are valid $this->where[] = '0 = 1'; } else { diff --git a/includes/api/ApiQueryContributors.php b/includes/api/ApiQueryContributors.php index 642c9ac3e56a..a8f970e17067 100644 --- a/includes/api/ApiQueryContributors.php +++ b/includes/api/ApiQueryContributors.php @@ -64,7 +64,7 @@ class ApiQueryContributors extends ApiQueryBase { return $v >= $cont_page; } ); } - if ( !count( $pages ) ) { + if ( $pages === [] ) { // Nothing to do return; } diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 2ab3c56c6492..8a54c0be113d 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -721,7 +721,7 @@ class ApiQueryInfo extends ApiQueryBase { $getTitles[] = $t->getTalkPage(); } } - if ( !count( $getTitles ) ) { + if ( $getTitles === [] ) { return; } @@ -751,7 +751,7 @@ class ApiQueryInfo extends ApiQueryBase { $pageIds = array_keys( $this->titles ); - if ( !count( $pageIds ) ) { + if ( $pageIds === [] ) { return; } @@ -768,7 +768,7 @@ class ApiQueryInfo extends ApiQueryBase { } private function getVariantTitles() { - if ( !count( $this->titles ) ) { + if ( $this->titles === [] ) { return; } $this->variantTitles = []; diff --git a/includes/api/ApiQueryPageProps.php b/includes/api/ApiQueryPageProps.php index 2bee69837e33..325800428022 100644 --- a/includes/api/ApiQueryPageProps.php +++ b/includes/api/ApiQueryPageProps.php @@ -50,7 +50,7 @@ class ApiQueryPageProps extends ApiQueryBase { $pages = $filteredPages; } - if ( !count( $pages ) ) { + if ( $pages === [] ) { # Nothing to do return; } diff --git a/includes/api/ApiQueryUserContribs.php b/includes/api/ApiQueryUserContribs.php index ed831306eb59..60826178b460 100644 --- a/includes/api/ApiQueryUserContribs.php +++ b/includes/api/ApiQueryUserContribs.php @@ -136,7 +136,7 @@ class ApiQueryUserContribs extends ApiQueryBase { // prepareQuery might try to sort by actor and confuse everything. $batchSize = 1; } elseif ( isset( $this->params['userids'] ) ) { - if ( !count( $this->params['userids'] ) ) { + if ( $this->params['userids'] === [] ) { $encParamName = $this->encodeParamName( 'userids' ); $this->dieWithError( [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName" ); } diff --git a/includes/clientpool/SquidPurgeClientPool.php b/includes/clientpool/SquidPurgeClientPool.php index f6109f1d88d3..6dd85e708da7 100644 --- a/includes/clientpool/SquidPurgeClientPool.php +++ b/includes/clientpool/SquidPurgeClientPool.php @@ -61,9 +61,10 @@ class SquidPurgeClientPool { $writeSockets["$clientIndex/$i"] = $socket; } } - if ( !count( $readSockets ) && !count( $writeSockets ) ) { + if ( $readSockets === [] && $writeSockets === [] ) { break; } + $exceptSockets = null; $timeout = min( $startTime + $this->timeout - microtime( true ), 1 ); Wikimedia\suppressWarnings(); diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 628b47bd536d..6af6de52fe0b 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -589,7 +589,7 @@ class DatabaseOracle extends Database { public function upsert( $table, array $rows, array $uniqueIndexes, array $set, $fname = __METHOD__ ) { - if ( !count( $rows ) ) { + if ( $rows === [] ) { return true; // nothing to do } diff --git a/includes/editpage/TextboxBuilder.php b/includes/editpage/TextboxBuilder.php index 81dc78d6d0db..354cc610063f 100644 --- a/includes/editpage/TextboxBuilder.php +++ b/includes/editpage/TextboxBuilder.php @@ -58,7 +58,7 @@ class TextboxBuilder { * @return mixed[] */ public function mergeClassesIntoAttributes( array $classes, array $attribs ) { - if ( !count( $classes ) ) { + if ( $classes === [] ) { return $attribs; } diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index b3eae900ee6c..bb65b0ad8964 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -405,7 +405,7 @@ class LocalRepo extends FileRepo { * @return array[] An Array of arrays or iterators of file objects and the hash as key */ function findBySha1s( array $hashes ) { - if ( !count( $hashes ) ) { + if ( $hashes === [] ) { return []; // empty parameter } diff --git a/includes/filerepo/file/ArchivedFile.php b/includes/filerepo/file/ArchivedFile.php index 4a84cff172a5..6a3e819a334e 100644 --- a/includes/filerepo/file/ArchivedFile.php +++ b/includes/filerepo/file/ArchivedFile.php @@ -169,7 +169,7 @@ class ArchivedFile { $conds['fa_sha1'] = $this->sha1; } - if ( !count( $conds ) ) { + if ( $conds === [] ) { throw new MWException( "No specific information for retrieving archived file" ); } diff --git a/includes/jobqueue/JobQueue.php b/includes/jobqueue/JobQueue.php index 3689ba4943c9..4f4728d91721 100644 --- a/includes/jobqueue/JobQueue.php +++ b/includes/jobqueue/JobQueue.php @@ -323,7 +323,7 @@ abstract class JobQueue { final public function batchPush( array $jobs, $flags = 0 ) { $this->assertNotReadOnly(); - if ( !count( $jobs ) ) { + if ( $jobs === [] ) { return; // nothing to do } diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php index 9931d833c437..fa17284ecda7 100644 --- a/includes/jobqueue/JobQueueDB.php +++ b/includes/jobqueue/JobQueueDB.php @@ -214,7 +214,7 @@ class JobQueueDB extends JobQueue { * @return void */ public function doBatchPushInternal( IDatabase $dbw, array $jobs, $flags, $method ) { - if ( !count( $jobs ) ) { + if ( $jobs === [] ) { return; } diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php index b103b8eb4693..4853c4afffdc 100644 --- a/includes/jobqueue/JobQueueGroup.php +++ b/includes/jobqueue/JobQueueGroup.php @@ -143,7 +143,7 @@ class JobQueueGroup { } $jobs = is_array( $jobs ) ? $jobs : [ $jobs ]; - if ( !count( $jobs ) ) { + if ( $jobs === [] ) { return; } diff --git a/includes/jobqueue/JobQueueRedis.php b/includes/jobqueue/JobQueueRedis.php index b868128d597d..a1ef28b1d2a0 100644 --- a/includes/jobqueue/JobQueueRedis.php +++ b/includes/jobqueue/JobQueueRedis.php @@ -203,7 +203,7 @@ class JobQueueRedis extends JobQueue { } } - if ( !count( $items ) ) { + if ( $items === [] ) { return; // nothing to do } diff --git a/includes/libs/filebackend/FileBackend.php b/includes/libs/filebackend/FileBackend.php index 27e69244763f..e32d496913b2 100644 --- a/includes/libs/filebackend/FileBackend.php +++ b/includes/libs/filebackend/FileBackend.php @@ -417,7 +417,7 @@ abstract class FileBackend implements LoggerAwareInterface { if ( empty( $opts['bypassReadOnly'] ) && $this->isReadOnly() ) { return $this->newStatus( 'backend-fail-readonly', $this->name, $this->readOnly ); } - if ( !count( $ops ) ) { + if ( $ops === [] ) { return $this->newStatus(); // nothing to do } @@ -655,7 +655,7 @@ abstract class FileBackend implements LoggerAwareInterface { if ( empty( $opts['bypassReadOnly'] ) && $this->isReadOnly() ) { return $this->newStatus( 'backend-fail-readonly', $this->name, $this->readOnly ); } - if ( !count( $ops ) ) { + if ( $ops === [] ) { return $this->newStatus(); // nothing to do } diff --git a/includes/libs/filebackend/filejournal/FileJournal.php b/includes/libs/filebackend/filejournal/FileJournal.php index 47be4eba0035..999594b85e81 100644 --- a/includes/libs/filebackend/filejournal/FileJournal.php +++ b/includes/libs/filebackend/filejournal/FileJournal.php @@ -97,7 +97,7 @@ abstract class FileJournal { * @return StatusValue */ final public function logChangeBatch( array $entries, $batchId ) { - if ( !count( $entries ) ) { + if ( $entries === [] ) { return StatusValue::newGood(); } diff --git a/includes/libs/lockmanager/FSLockManager.php b/includes/libs/lockmanager/FSLockManager.php index f2624e721a78..019029c4807c 100644 --- a/includes/libs/lockmanager/FSLockManager.php +++ b/includes/libs/lockmanager/FSLockManager.php @@ -169,7 +169,7 @@ class FSLockManager extends LockManager { if ( $this->locksHeld[$path][$type] <= 0 ) { unset( $this->locksHeld[$path][$type] ); } - if ( !count( $this->locksHeld[$path] ) ) { + if ( $this->locksHeld[$path] === [] ) { unset( $this->locksHeld[$path] ); // no locks on this path if ( isset( $this->handles[$path] ) ) { $handlesToClose[] = $this->handles[$path]; diff --git a/includes/libs/lockmanager/PostgreSqlLockManager.php b/includes/libs/lockmanager/PostgreSqlLockManager.php index 65c69938a486..fd3ffa5cbcd6 100644 --- a/includes/libs/lockmanager/PostgreSqlLockManager.php +++ b/includes/libs/lockmanager/PostgreSqlLockManager.php @@ -18,7 +18,7 @@ class PostgreSqlLockManager extends DBLockManager { protected function doGetLocksOnServer( $lockSrv, array $paths, $type ) { $status = StatusValue::newGood(); - if ( !count( $paths ) ) { + if ( $paths === [] ) { return $status; // nothing to lock } diff --git a/includes/libs/lockmanager/QuorumLockManager.php b/includes/libs/lockmanager/QuorumLockManager.php index 1d2e21aa0d70..1ef4642a84a6 100644 --- a/includes/libs/lockmanager/QuorumLockManager.php +++ b/includes/libs/lockmanager/QuorumLockManager.php @@ -98,7 +98,7 @@ abstract class QuorumLockManager extends LockManager { $bucket = $this->getBucketFromPath( $path ); $pathsToUnlock[$bucket][$type][] = $path; } - if ( !count( $this->locksHeld[$path] ) ) { + if ( $this->locksHeld[$path] === [] ) { unset( $this->locksHeld[$path] ); // no SH or EX locks left for key } } @@ -110,7 +110,7 @@ abstract class QuorumLockManager extends LockManager { foreach ( $pathsToUnlock as $bucket => $pathsToUnlockByType ) { $status->merge( $this->doUnlockingRequestBucket( $bucket, $pathsToUnlockByType ) ); } - if ( !count( $this->locksHeld ) ) { + if ( $this->locksHeld === [] ) { $status->merge( $this->releaseAllLocks() ); $this->degradedBuckets = []; // safe to retry the normal quorum } diff --git a/includes/libs/rdbms/ChronologyProtector.php b/includes/libs/rdbms/ChronologyProtector.php index 938e5345dbe8..3e71e3626b96 100644 --- a/includes/libs/rdbms/ChronologyProtector.php +++ b/includes/libs/rdbms/ChronologyProtector.php @@ -202,7 +202,7 @@ class ChronologyProtector implements LoggerAwareInterface { ); } - if ( !count( $this->shutdownPositions ) ) { + if ( $this->shutdownPositions === [] ) { return []; // nothing to save } diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index 9a9e36ac6f82..7d971af9297f 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -2855,7 +2855,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware public function upsert( $table, array $rows, array $uniqueIndexes, array $set, $fname = __METHOD__ ) { - if ( !count( $rows ) ) { + if ( $rows === [] ) { return true; // nothing to do } diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php index 3fcbcf964d53..186c89f3d661 100644 --- a/includes/libs/rdbms/database/DatabaseMysqlBase.php +++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php @@ -1337,7 +1337,7 @@ abstract class DatabaseMysqlBase extends Database { public function upsert( $table, array $rows, array $uniqueIndexes, array $set, $fname = __METHOD__ ) { - if ( !count( $rows ) ) { + if ( $rows === [] ) { return true; // nothing to do } diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index ca181223c341..ab5c3cda44dc 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -408,7 +408,7 @@ class LoadBalancer implements ILoadBalancer { * @return array (reader index, lagged replica mode) or false on failure */ private function pickReaderIndex( array $loads, $domain = false ) { - if ( !count( $loads ) ) { + if ( $loads === [] ) { throw new InvalidArgumentException( "Empty server array given to LoadBalancer" ); } @@ -476,7 +476,7 @@ class LoadBalancer implements ILoadBalancer { } // If all servers were down, quit now - if ( !count( $currentLoads ) ) { + if ( $currentLoads === [] ) { $this->connLogger->error( __METHOD__ . ": all servers down" ); } diff --git a/includes/mail/EmailNotification.php b/includes/mail/EmailNotification.php index 8a089f69307d..76a7760d76b0 100644 --- a/includes/mail/EmailNotification.php +++ b/includes/mail/EmailNotification.php @@ -154,7 +154,7 @@ class EmailNotification { // If nobody is watching the page, and there are no users notified on all changes // don't bother creating a job/trying to send emails, unless it's a // talk page with an applicable notification. - if ( !count( $watchers ) && !count( $wgUsersNotifiedOnAllChanges ) ) { + if ( $watchers === [] && !count( $wgUsersNotifiedOnAllChanges ) ) { $sendEmail = false; // Only send notification for non minor edits, unless $wgEnotifMinorEdits if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) { diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index f4e4efa72406..3bcd012f4f59 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -878,7 +878,7 @@ class PPDStack { } public function pop() { - if ( !count( $this->stack ) ) { + if ( $this->stack === [] ) { throw new MWException( __METHOD__ . ': no elements remaining' ); } $temp = array_pop( $this->stack ); @@ -902,7 +902,7 @@ class PPDStack { * @return array */ public function getFlags() { - if ( !count( $this->stack ) ) { + if ( $this->stack === [] ) { return [ 'findEquals' => false, 'findPipe' => false, diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 9570e038a8f6..c513aed018f4 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -781,7 +781,7 @@ class ResourceLoader implements LoggerAwareInterface { } // Save response to file cache unless there are errors - if ( isset( $fileCache ) && !$this->errors && !count( $missing ) ) { + if ( isset( $fileCache ) && !$this->errors && $missing === [] ) { // Cache single modules and images...and other requests if there are enough hits if ( ResourceFileCache::useFileCache( $context ) ) { if ( $fileCache->isCacheWorthy() ) { @@ -1036,7 +1036,7 @@ class ResourceLoader implements LoggerAwareInterface { $out = ''; $states = []; - if ( !count( $modules ) && !count( $missing ) ) { + if ( $modules === [] && $missing === [] ) { return <<<MESSAGE /* This file is the Web entry point for MediaWiki's ResourceLoader: <https://www.mediawiki.org/wiki/ResourceLoader>. In this request, diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 9cd245a8603c..0cbb41c4711b 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -98,7 +98,7 @@ class SearchOracle extends SearchDatabase { if ( is_null( $this->namespaces ) ) { return ''; } - if ( !count( $this->namespaces ) ) { + if ( $this->namespaces === [] ) { $namespaces = '0'; } else { $namespaces = $this->db->makeList( $this->namespaces ); diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index 6332ea2b84f0..f653796a6fc1 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -199,7 +199,7 @@ class SearchSqlite extends SearchDatabase { if ( is_null( $this->namespaces ) ) { return ''; # search all } - if ( !count( $this->namespaces ) ) { + if ( $this->namespaces === [] ) { $namespaces = '0'; } else { $namespaces = $this->db->makeList( $this->namespaces ); diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 08ff8f0c49da..e31bc06b56a6 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -519,7 +519,7 @@ abstract class Skin extends ContextSource { $out = $this->getOutput(); $allCats = $out->getCategoryLinks(); - if ( !count( $allCats ) ) { + if ( $allCats === [] ) { return ''; } diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 70b420763855..b05c81ab1ac2 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -431,7 +431,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { * Attempts to clean up broken items */ private function cleanupWatchlist() { - if ( !count( $this->badItems ) ) { + if ( $this->badItems === [] ) { return; // nothing to do } diff --git a/includes/specials/SpecialListgrants.php b/includes/specials/SpecialListgrants.php index 1a04eec473f8..ba16baf92439 100644 --- a/includes/specials/SpecialListgrants.php +++ b/includes/specials/SpecialListgrants.php @@ -62,7 +62,7 @@ class SpecialListGrants extends SpecialPage { '<span class="mw-listgrants-right-name">' . $permission . '</span>' )->parse(); } - if ( !count( $descs ) ) { + if ( $descs === [] ) { $grantCellHtml = ''; } else { sort( $descs ); diff --git a/includes/specials/SpecialPasswordPolicies.php b/includes/specials/SpecialPasswordPolicies.php index 0a3a6799a5f2..573dcb52aaf4 100644 --- a/includes/specials/SpecialPasswordPolicies.php +++ b/includes/specials/SpecialPasswordPolicies.php @@ -151,7 +151,7 @@ class SpecialPasswordPolicies extends SpecialPage { '<span class="mw-passwordpolicies-policy-name">' . $gp . '</span>' )->parse(); } - if ( !count( $ret ) ) { + if ( $ret === [] ) { return ''; } else { return '<ul><li>' . implode( "</li>\n<li>", $ret ) . '</li></ul>'; diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 60e797e0c3a8..b566305fc56c 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -709,7 +709,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { $categories = array_map( 'trim', explode( '|', $opts['categories'] ) ); - if ( !count( $categories ) ) { + if ( $categories === [] ) { return; } @@ -744,7 +744,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { } # Shortcut? - if ( !count( $articles ) || !count( $cats ) ) { + if ( $articles === [] || $cats === [] ) { return; } diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index d904ad16d3d2..ec6c5b94c99b 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -212,13 +212,13 @@ class SpecialSearch extends SpecialPage { # Extract manually requested namespaces $nslist = $this->powerSearch( $request ); - if ( !count( $nslist ) ) { + if ( $nslist === [] ) { # Fallback to user preference $nslist = $this->searchConfig->userNamespaces( $user ); } $profile = null; - if ( !count( $nslist ) ) { + if ( $nslist === [] ) { $profile = 'default'; } diff --git a/includes/specials/SpecialSpecialpages.php b/includes/specials/SpecialSpecialpages.php index 585a7cd35f3b..9de31da3314a 100644 --- a/includes/specials/SpecialSpecialpages.php +++ b/includes/specials/SpecialSpecialpages.php @@ -55,7 +55,7 @@ class SpecialSpecialpages extends UnlistedSpecialPage { $pages = MediaWikiServices::getInstance()->getSpecialPageFactory()-> getUsablePages( $this->getUser() ); - if ( !count( $pages ) ) { + if ( $pages === [] ) { # Yeah, that was pointless. Thanks for coming. return false; } diff --git a/includes/specials/SpecialTrackingCategories.php b/includes/specials/SpecialTrackingCategories.php index 3ee7cea1ca0a..4a586b7312c6 100644 --- a/includes/specials/SpecialTrackingCategories.php +++ b/includes/specials/SpecialTrackingCategories.php @@ -94,7 +94,7 @@ class SpecialTrackingCategories extends SpecialPage { } # Extra message, when no category was found - if ( !count( $allMsgs ) ) { + if ( $allMsgs === [] ) { $allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse(); } diff --git a/includes/user/User.php b/includes/user/User.php index 65fc4b4659e9..79889ae96348 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -1579,7 +1579,7 @@ class User implements IDBAccessObject, UserIdentity { if ( is_array( $data ) ) { if ( isset( $data['user_groups'] ) && is_array( $data['user_groups'] ) ) { - if ( !count( $data['user_groups'] ) ) { + if ( $data['user_groups'] === [] ) { $this->mGroupMemberships = []; } else { $firstGroup = reset( $data['user_groups'] ); @@ -1645,7 +1645,7 @@ class User implements IDBAccessObject, UserIdentity { } $toPromote = Autopromote::getAutopromoteOnceGroups( $this, $event ); - if ( !count( $toPromote ) ) { + if ( $toPromote === [] ) { return []; } |