Thiemo Kreuz (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/400413 )

Change subject: Utilize the …::class feature instead of class names in strings
......................................................................

Utilize the …::class feature instead of class names in strings

Yes, the …::class feature works, even if a class is not available. It's
technically still a string. However, most tools can much easier understand
that the string before …::class refers to a class name, and properly warn
when the class is renamed or moved to an other namespace.

note this conflicts with I4e47cdd! Whatever is merged first (and I believe
both can be merged), the other patch must be rebased then.

Change-Id: If8056135a212cf11017bce4c5fd08f83cd910d97
---
M includes/MobileFormatter.php
M includes/MobileFrontend.body.php
M includes/MobileFrontend.hooks.php
M includes/api/ApiMobileView.php
4 files changed, 9 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/13/400413/1

diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php
index 938f90b..ea6a5fd 100644
--- a/includes/MobileFormatter.php
+++ b/includes/MobileFormatter.php
@@ -650,7 +650,7 @@
         *  {@see MobileFormatter::getHeadings}
         * @param array $transformOptions Options to pass when transforming 
content per section
         */
-       protected function makeSections( DOMDocument $doc, array $headings, 
$transformOptions ) {
+       protected function makeSections( DOMDocument $doc, array $headings, 
array $transformOptions ) {
                // Find the parser output wrapper div
                $xpath = new DOMXPath( $doc );
                $containers = $xpath->query( 
'body/div[@class="mw-parser-output"][1]' );
diff --git a/includes/MobileFrontend.body.php b/includes/MobileFrontend.body.php
index d2b059a..c3750c7 100644
--- a/includes/MobileFrontend.body.php
+++ b/includes/MobileFrontend.body.php
@@ -19,7 +19,7 @@
         * @param array $data The data to be recorded against the schema
         */
        public static function eventLog( $schema, $revision, $data ) {
-               if ( is_callable( 'EventLogging::logEvent' ) ) {
+               if ( is_callable( [ EventLogging::class, 'logEvent' ] ) ) {
                        EventLogging::logEvent( $schema, $revision, $data );
                }
        }
@@ -132,7 +132,7 @@
         * @return mw.wikibase.entity|null
         */
        public static function getWikibaseEntity( $item ) {
-               if ( !class_exists( 'Wikibase\\Client\\WikibaseClient' ) ) {
+               if ( !class_exists( WikibaseClient::class ) ) {
                        return null;
                }
 
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 37636b8..4836e5a 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -905,7 +905,7 @@
                self::registerMobileLoggingSchemasModule( $resourceLoader );
 
                // add VisualEditor related modules only, if VisualEditor seems 
to be installed - T85007
-               if ( class_exists( 'VisualEditorHooks' ) ) {
+               if ( class_exists( \VisualEditorHooks::class ) ) {
                        $resourceLoader->register( [
                                'mobile.editor.ve' => $resourceBoilerplate + [
                                        'dependencies' => [
@@ -1038,7 +1038,7 @@
                $schemaMobileWebMainMenuClickTracking = 
$mfResourceFileModuleBoilerplate;
                $schemaMobileWebSearch = $mfResourceFileModuleBoilerplate;
 
-               if ( class_exists( 'EventLogging' ) ) {
+               if ( class_exists( \EventLogging::class ) ) {
                        // schema.Edit is provided by WikimediaEvents
                        if ( $resourceLoader->isModuleRegistered( 'schema.Edit' 
) ) {
                                $schemaEdit += [
diff --git a/includes/api/ApiMobileView.php b/includes/api/ApiMobileView.php
index c3380c9..51e3f47 100644
--- a/includes/api/ApiMobileView.php
+++ b/includes/api/ApiMobileView.php
@@ -248,7 +248,7 @@
                // https://bugzilla.wikimedia.org/show_bug.cgi?id=51586
                // Inform ppl if the page is infested with LiquidThreads but 
that's the
                // only thing we support about it.
-               if ( class_exists( 'LqtDispatch' ) && LqtDispatch::isLqtPage( 
$title ) ) {
+               if ( class_exists( \LqtDispatch::class ) && 
\LqtDispatch::isLqtPage( $title ) ) {
                        $resultObj->addValue( null, $moduleName,
                                [ 'liquidthreads' => true ]
                        );
@@ -271,13 +271,13 @@
        /**
         * Small wrapper around XAnalytics extension
         *
-        * @see XAnalytics::addItem
+        * @see \XAnalytics::addItem
         * @param string $name
         * @param string $value
         */
        private function addXAnalyticsItem( $name, $value ) {
-               if ( is_callable( 'XAnalytics::addItem' ) ) {
-                       XAnalytics::addItem( $name, $value );
+               if ( is_callable( [ \XAnalytics::class, 'addItem' ] ) ) {
+                       \XAnalytics::addItem( $name, $value );
                }
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/400413
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If8056135a212cf11017bce4c5fd08f83cd910d97
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Thiemo Kreuz (WMDE) <thiemo.kr...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to