From 0cf40a4f7a79ef73d8f2c187a25159d57bd8c7b0 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 22 Jul 2020 17:49:12 +0100 Subject: [PATCH] Flip Yoda conditionals Change-Id: Id3495b6f15c267123c89f3a0ace496e6ecbeb58e --- includes/AutoLoader.php | 2 +- includes/Title.php | 12 ++++++------ includes/content/WikitextContentHandler.php | 2 +- includes/json/FormatJson.php | 2 +- includes/page/Article.php | 2 +- includes/watcheditem/WatchedItem.php | 2 +- languages/Language.php | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 2dd7c00181a..831ac051363 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -76,7 +76,7 @@ class AutoLoader { if ( !$filename && strpos( $className, '\\' ) !== false ) { // This class is namespaced, so try looking at the namespace map $prefix = $className; - while ( false !== $pos = strrpos( $prefix, '\\' ) ) { + while ( ( $pos = strrpos( $prefix, '\\' ) ) !== false ) { // Check to see if this namespace prefix is in the map $prefix = substr( $className, 0, $pos + 1 ); if ( isset( self::$psr4Namespaces[$prefix] ) ) { diff --git a/includes/Title.php b/includes/Title.php index 82ad6d0bae3..35faf35baa1 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1473,7 +1473,7 @@ class Title implements LinkTarget, IDBAccessObject { */ public function isUserCssConfigPage() { return ( - NS_USER == $this->mNamespace + $this->mNamespace == NS_USER && $this->isSubpage() && $this->hasContentModel( CONTENT_MODEL_CSS ) ); @@ -1487,7 +1487,7 @@ class Title implements LinkTarget, IDBAccessObject { */ public function isUserJsonConfigPage() { return ( - NS_USER == $this->mNamespace + $this->mNamespace == NS_USER && $this->isSubpage() && $this->hasContentModel( CONTENT_MODEL_JSON ) ); @@ -1501,7 +1501,7 @@ class Title implements LinkTarget, IDBAccessObject { */ public function isUserJsConfigPage() { return ( - NS_USER == $this->mNamespace + $this->mNamespace == NS_USER && $this->isSubpage() && $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT ) ); @@ -1515,7 +1515,7 @@ class Title implements LinkTarget, IDBAccessObject { */ public function isSiteCssConfigPage() { return ( - NS_MEDIAWIKI == $this->mNamespace + $this->mNamespace == NS_MEDIAWIKI && ( $this->hasContentModel( CONTENT_MODEL_CSS ) // paranoia - a MediaWiki: namespace page with mismatching extension and content @@ -1533,7 +1533,7 @@ class Title implements LinkTarget, IDBAccessObject { */ public function isSiteJsonConfigPage() { return ( - NS_MEDIAWIKI == $this->mNamespace + $this->mNamespace == NS_MEDIAWIKI && ( $this->hasContentModel( CONTENT_MODEL_JSON ) // paranoia - a MediaWiki: namespace page with mismatching extension and content @@ -1551,7 +1551,7 @@ class Title implements LinkTarget, IDBAccessObject { */ public function isSiteJsConfigPage() { return ( - NS_MEDIAWIKI == $this->mNamespace + $this->mNamespace == NS_MEDIAWIKI && ( $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT ) // paranoia - a MediaWiki: namespace page with mismatching extension and content diff --git a/includes/content/WikitextContentHandler.php b/includes/content/WikitextContentHandler.php index d8183605c5b..0b10c7b51bc 100644 --- a/includes/content/WikitextContentHandler.php +++ b/includes/content/WikitextContentHandler.php @@ -162,7 +162,7 @@ class WikitextContentHandler extends TextContentHandler { $fields['defaultsort'] = $structure->getDefaultSort(); // Until we have full first-class content handler for files, we invoke it explicitly here - if ( NS_FILE == $page->getTitle()->getNamespace() ) { + if ( $page->getTitle()->getNamespace() == NS_FILE ) { $fields = array_merge( $fields, $this->getFileHandler()->getDataForSearchIndex( $page, $parserOutput, $engine ) ); } diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php index 263f608c01e..d087a60f6d8 100644 --- a/includes/json/FormatJson.php +++ b/includes/json/FormatJson.php @@ -206,7 +206,7 @@ class FormatJson { $value, -1, $count ); if ( $count > 0 ) { $result = json_decode( $value, $assoc ); - if ( JSON_ERROR_NONE === json_last_error() ) { + if ( json_last_error() === JSON_ERROR_NONE ) { // Report warning $st = Status::newGood( $result ); $st->warning( wfMessage( 'json-warn-trailing-comma' )->numParams( $count ) ); diff --git a/includes/page/Article.php b/includes/page/Article.php index ee660fd066d..9c7d2cbb5be 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -192,7 +192,7 @@ class Article implements Page { * @return Article */ public static function newFromTitle( $title, IContextSource $context ) { - if ( NS_MEDIA == $title->getNamespace() ) { + if ( $title->getNamespace() == NS_MEDIA ) { // XXX: This should not be here, but where should it go? $title = Title::makeTitle( NS_FILE, $title->getDBkey() ); } diff --git a/includes/watcheditem/WatchedItem.php b/includes/watcheditem/WatchedItem.php index 4c9018a2d71..92ed262f133 100644 --- a/includes/watcheditem/WatchedItem.php +++ b/includes/watcheditem/WatchedItem.php @@ -143,7 +143,7 @@ class WatchedItem { * @return bool */ public function isExpired(): bool { - if ( null === $this->getExpiry() ) { + if ( $this->getExpiry() === null ) { return false; } diff --git a/languages/Language.php b/languages/Language.php index 978867b5900..75811003aba 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -2963,7 +2963,7 @@ class Language { // Break down Hangul syllables to grab the first jamo $code = mb_ord( $firstChar ); - if ( $code < 0xac00 || 0xd7a4 <= $code ) { + if ( $code < 0xac00 || $code >= 0xd7a4 ) { return $firstChar; } elseif ( $code < 0xb098 ) { return "\u{3131}";