From 734a969d5506a80ceabfa2bc61bda79f76d73d5f Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Wed, 9 Jan 2019 17:24:36 +0100 Subject: [PATCH] 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 --- includes/Block.php | 6 +++--- includes/HistoryBlob.php | 8 +++----- includes/api/ApiQueryAllUsers.php | 2 +- includes/api/ApiQueryBase.php | 2 +- includes/api/ApiQueryContributors.php | 2 +- includes/api/ApiQueryInfo.php | 6 +++--- includes/api/ApiQueryPageProps.php | 2 +- includes/api/ApiQueryUserContribs.php | 2 +- includes/clientpool/SquidPurgeClientPool.php | 3 ++- includes/db/DatabaseOracle.php | 2 +- includes/editpage/TextboxBuilder.php | 2 +- includes/filerepo/LocalRepo.php | 2 +- includes/filerepo/file/ArchivedFile.php | 2 +- includes/jobqueue/JobQueue.php | 2 +- includes/jobqueue/JobQueueDB.php | 2 +- includes/jobqueue/JobQueueGroup.php | 2 +- includes/jobqueue/JobQueueRedis.php | 2 +- includes/libs/filebackend/FileBackend.php | 4 ++-- includes/libs/filebackend/filejournal/FileJournal.php | 2 +- includes/libs/lockmanager/FSLockManager.php | 2 +- includes/libs/lockmanager/PostgreSqlLockManager.php | 2 +- includes/libs/lockmanager/QuorumLockManager.php | 4 ++-- includes/libs/rdbms/ChronologyProtector.php | 2 +- includes/libs/rdbms/database/Database.php | 2 +- includes/libs/rdbms/database/DatabaseMysqlBase.php | 2 +- includes/libs/rdbms/loadbalancer/LoadBalancer.php | 4 ++-- includes/mail/EmailNotification.php | 2 +- includes/parser/Preprocessor_DOM.php | 4 ++-- includes/resourceloader/ResourceLoader.php | 4 ++-- includes/search/SearchOracle.php | 2 +- includes/search/SearchSqlite.php | 2 +- includes/skins/Skin.php | 2 +- includes/specials/SpecialEditWatchlist.php | 2 +- includes/specials/SpecialListgrants.php | 2 +- includes/specials/SpecialPasswordPolicies.php | 2 +- includes/specials/SpecialRecentchanges.php | 4 ++-- includes/specials/SpecialSearch.php | 4 ++-- includes/specials/SpecialSpecialpages.php | 2 +- includes/specials/SpecialTrackingCategories.php | 2 +- includes/user/User.php | 4 ++-- 40 files changed, 55 insertions(+), 56 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index fb3caf658c..7138301d94 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 1d4f6e4e8d..bca6c7e5bc 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 7d5f6e2a59..7b5df5047d 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 d9fe50b8d6..c92f037c9c 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 642c9ac3e5..a8f970e170 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 2ab3c56c64..8a54c0be11 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 2bee69837e..3258004280 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 ed831306eb..60826178b4 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 f6109f1d88..6dd85e708d 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 628b47bd53..6af6de52fe 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 81dc78d6d0..354cc61006 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 b3eae900ee..bb65b0ad89 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 4a84cff172..6a3e819a33 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 3689ba4943..4f4728d917 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 9931d833c4..fa17284ecd 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 b103b8eb46..4853c4afff 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 b868128d59..a1ef28b1d2 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 27e6924476..e32d496913 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 47be4eba00..999594b85e 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 f2624e721a..019029c480 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 65c69938a4..fd3ffa5cbc 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 1d2e21aa0d..1ef4642a84 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 938e5345db..3e71e3626b 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 9a9e36ac6f..7d971af929 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 3fcbcf964d..186c89f3d6 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 ca181223c3..ab5c3cda44 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 8a089f6930..76a7760d76 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 f4e4efa724..3bcd012f4f 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 9570e038a8..c513aed018 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 <<. In this request, diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 9cd245a860..0cbb41c471 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 6332ea2b84..f653796a6f 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 08ff8f0c49..e31bc06b56 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 70b4207638..b05c81ab1a 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 1a04eec473..ba16baf924 100644 --- a/includes/specials/SpecialListgrants.php +++ b/includes/specials/SpecialListgrants.php @@ -62,7 +62,7 @@ class SpecialListGrants extends SpecialPage { '' . $permission . '' )->parse(); } - if ( !count( $descs ) ) { + if ( $descs === [] ) { $grantCellHtml = ''; } else { sort( $descs ); diff --git a/includes/specials/SpecialPasswordPolicies.php b/includes/specials/SpecialPasswordPolicies.php index 0a3a6799a5..573dcb52aa 100644 --- a/includes/specials/SpecialPasswordPolicies.php +++ b/includes/specials/SpecialPasswordPolicies.php @@ -151,7 +151,7 @@ class SpecialPasswordPolicies extends SpecialPage { '' . $gp . '' )->parse(); } - if ( !count( $ret ) ) { + if ( $ret === [] ) { return ''; } else { return ''; diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 60e797e0c3..b566305fc5 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 d904ad16d3..ec6c5b94c9 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 585a7cd35f..9de31da331 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 3ee7cea1ca..4a586b7312 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 65fc4b4659..79889ae963 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 []; } -- 2.20.1