Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/341482 )

Change subject: Clean up remaining get_class() uses
......................................................................

Clean up remaining get_class() uses

* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: I1888a1897ecf4548a2e5a67a942e5c080dd7e3d3
---
M includes/collation/IcuCollation.php
M includes/context/ContextSource.php
M includes/exception/MWException.php
M includes/htmlform/HTMLFormField.php
M includes/htmlform/fields/HTMLCheckMatrix.php
M includes/htmlform/fields/HTMLFormFieldCloner.php
M includes/installer/WebInstallerPage.php
M includes/jobqueue/JobSpecification.php
M includes/media/TransformationalImageHandler.php
M includes/pager/IndexPager.php
M includes/session/SessionProvider.php
M includes/skins/Skin.php
M includes/skins/SkinTemplate.php
M includes/specialpage/QueryPage.php
M includes/specialpage/RedirectSpecialPage.php
M includes/tidy/TidyDriverBase.php
M languages/Language.php
M languages/LanguageConverter.php
M tests/phpunit/MediaWikiTestCase.php
M tests/phpunit/includes/api/ApiTestCase.php
20 files changed, 32 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/82/341482/1

diff --git a/includes/collation/IcuCollation.php 
b/includes/collation/IcuCollation.php
index bf1fe74..e0eb1c1 100644
--- a/includes/collation/IcuCollation.php
+++ b/includes/collation/IcuCollation.php
@@ -330,7 +330,7 @@
                        $cache = ObjectCache::getLocalServerInstance( 
CACHE_ANYTHING );
                        $cacheKey = $cache->makeKey(
                                'first-letters',
-                               get_class( $this ),
+                               static::class,
                                $this->locale,
                                $this->digitTransformLanguage->getCode(),
                                self::getICUVersion(),
diff --git a/includes/context/ContextSource.php 
b/includes/context/ContextSource.php
index 829dd73..ea5278f 100644
--- a/includes/context/ContextSource.php
+++ b/includes/context/ContextSource.php
@@ -39,7 +39,7 @@
         */
        public function getContext() {
                if ( $this->context === null ) {
-                       $class = get_class( $this );
+                       $class = static::class;
                        wfDebug( __METHOD__ . " ($class): called and \$context 
is null. " .
                                "Using RequestContext::getMain() for sanity\n" 
);
                        $this->context = RequestContext::getMain();
diff --git a/includes/exception/MWException.php 
b/includes/exception/MWException.php
index e958c94..4ff8636 100644
--- a/includes/exception/MWException.php
+++ b/includes/exception/MWException.php
@@ -112,7 +112,7 @@
                        "</p>\n";
                } else {
                        $logId = WebRequest::getRequestId();
-                       $type = get_class( $this );
+                       $type = static::class;
                        return "<div class=\"errorbox\">" .
                        '[' . $logId . '] ' .
                        gmdate( 'Y-m-d H:i:s' ) . ": " .
@@ -164,7 +164,7 @@
                if ( $this->useOutputPage() ) {
                        $wgOut->prepareErrorPage( $this->getPageTitle() );
 
-                       $hookResult = $this->runHooks( get_class( $this ) );
+                       $hookResult = $this->runHooks( static::class );
                        if ( $hookResult ) {
                                $wgOut->addHTML( $hookResult );
                        } else {
@@ -183,7 +183,7 @@
                                '<style>body { font-family: sans-serif; margin: 
0; padding: 0.5em 2em; }</style>' .
                                "</head><body>\n";
 
-                       $hookResult = $this->runHooks( get_class( $this ) . 
'Raw' );
+                       $hookResult = $this->runHooks( static::class . 'Raw' );
                        if ( $hookResult ) {
                                echo $hookResult;
                        } else {
@@ -203,7 +203,7 @@
 
                if ( defined( 'MW_API' ) ) {
                        // Unhandled API exception, we can't be sure that 
format printer is alive
-                       self::header( 'MediaWiki-API-Error: 
internal_api_error_' . get_class( $this ) );
+                       self::header( 'MediaWiki-API-Error: 
internal_api_error_' . static::class );
                        wfHttpError( 500, 'Internal Server Error', 
$this->getText() );
                } elseif ( self::isCommandLine() ) {
                        $message = $this->getText();
diff --git a/includes/htmlform/HTMLFormField.php 
b/includes/htmlform/HTMLFormField.php
index 487d6f6..3a3146b 100644
--- a/includes/htmlform/HTMLFormField.php
+++ b/includes/htmlform/HTMLFormField.php
@@ -475,7 +475,7 @@
        public function getTableRow( $value ) {
                list( $errors, $errorClass ) = $this->getErrorsAndErrorClass( 
$value );
                $inputHtml = $this->getInputHTML( $value );
-               $fieldType = get_class( $this );
+               $fieldType = static::class;
                $helptext = $this->getHelpTextHtmlTable( $this->getHelpText() );
                $cellAttributes = [];
                $rowAttributes = [];
@@ -533,7 +533,7 @@
        public function getDiv( $value ) {
                list( $errors, $errorClass ) = $this->getErrorsAndErrorClass( 
$value );
                $inputHtml = $this->getInputHTML( $value );
-               $fieldType = get_class( $this );
+               $fieldType = static::class;
                $helptext = $this->getHelpTextHtmlDiv( $this->getHelpText() );
                $cellAttributes = [];
                $label = $this->getLabelHtml( $cellAttributes );
@@ -601,7 +601,7 @@
                        $infusable = false;
                }
 
-               $fieldType = get_class( $this );
+               $fieldType = static::class;
                $help = $this->getHelpText();
                $errors = $this->getErrorsRaw( $value );
                foreach ( $errors as &$error ) {
diff --git a/includes/htmlform/fields/HTMLCheckMatrix.php 
b/includes/htmlform/fields/HTMLCheckMatrix.php
index 46172a5..fa18a3c 100644
--- a/includes/htmlform/fields/HTMLCheckMatrix.php
+++ b/includes/htmlform/fields/HTMLCheckMatrix.php
@@ -189,7 +189,7 @@
        public function getTableRow( $value ) {
                list( $errors, $errorClass ) = $this->getErrorsAndErrorClass( 
$value );
                $inputHtml = $this->getInputHTML( $value );
-               $fieldType = get_class( $this );
+               $fieldType = static::class;
                $helptext = $this->getHelpTextHtmlTable( $this->getHelpText() );
                $cellAttributes = [ 'colspan' => 2 ];
 
diff --git a/includes/htmlform/fields/HTMLFormFieldCloner.php 
b/includes/htmlform/fields/HTMLFormFieldCloner.php
index 8fb840a..dd9184b 100644
--- a/includes/htmlform/fields/HTMLFormFieldCloner.php
+++ b/includes/htmlform/fields/HTMLFormFieldCloner.php
@@ -46,7 +46,7 @@
        protected $uniqueId;
 
        public function __construct( $params ) {
-               $this->uniqueId = get_class( $this ) . ++self::$counter . 'x';
+               $this->uniqueId = static::class . ++self::$counter . 'x';
                parent::__construct( $params );
 
                if ( empty( $this->mParams['fields'] ) || !is_array( 
$this->mParams['fields'] ) ) {
diff --git a/includes/installer/WebInstallerPage.php 
b/includes/installer/WebInstallerPage.php
index 7a41ceb..3aad6f8 100644
--- a/includes/installer/WebInstallerPage.php
+++ b/includes/installer/WebInstallerPage.php
@@ -133,7 +133,7 @@
         * @return string
         */
        public function getName() {
-               return str_replace( 'WebInstaller', '', get_class( $this ) );
+               return str_replace( 'WebInstaller', '', static::class );
        }
 
        /**
diff --git a/includes/jobqueue/JobSpecification.php 
b/includes/jobqueue/JobSpecification.php
index d636dc6..d844795 100644
--- a/includes/jobqueue/JobSpecification.php
+++ b/includes/jobqueue/JobSpecification.php
@@ -128,7 +128,7 @@
 
                $this->type = $type;
                $this->params = $params;
-               $this->title = $title ?: Title::makeTitle( NS_SPECIAL, 
'Badtitle/' . get_class( $this ) );
+               $this->title = $title ?: Title::makeTitle( NS_SPECIAL, 
'Badtitle/' . static::class );
                $this->opts = $opts;
        }
 
diff --git a/includes/media/TransformationalImageHandler.php 
b/includes/media/TransformationalImageHandler.php
index 60aec45..1ab0f36 100644
--- a/includes/media/TransformationalImageHandler.php
+++ b/includes/media/TransformationalImageHandler.php
@@ -569,7 +569,7 @@
         */
        public function rotate( $file, $params ) {
                return new MediaTransformError( 'thumbnail_error', 0, 0,
-                       get_class( $this ) . ' rotation not implemented' );
+                       static::class . ' rotation not implemented' );
        }
 
        /**
diff --git a/includes/pager/IndexPager.php b/includes/pager/IndexPager.php
index dc302a2..4694890 100644
--- a/includes/pager/IndexPager.php
+++ b/includes/pager/IndexPager.php
@@ -197,7 +197,7 @@
         */
        public function doQuery() {
                # Use the child class name for profiling
-               $fname = __METHOD__ . ' (' . get_class( $this ) . ')';
+               $fname = __METHOD__ . ' (' . static::class . ')';
                $section = Profiler::instance()->scopedProfileIn( $fname );
 
                // @todo This should probably compare to DIR_DESCENDING and 
DIR_ASCENDING constants
@@ -348,7 +348,7 @@
         * @return string
         */
        function getSqlComment() {
-               return get_class( $this );
+               return static::class;
        }
 
        /**
diff --git a/includes/session/SessionProvider.php 
b/includes/session/SessionProvider.php
index e8d81cb..3cf69b7 100644
--- a/includes/session/SessionProvider.php
+++ b/includes/session/SessionProvider.php
@@ -455,7 +455,7 @@
         * @return string
         */
        public function __toString() {
-               return get_class( $this );
+               return static::class;
        }
 
        /**
@@ -475,7 +475,7 @@
         */
        protected function describeMessage() {
                return wfMessage(
-                       'sessionprovider-' . str_replace( '\\', '-', 
strtolower( get_class( $this ) ) )
+                       'sessionprovider-' . str_replace( '\\', '-', 
strtolower( static::class ) )
                );
        }
 
diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php
index a7740a0..3ef646a 100644
--- a/includes/skins/Skin.php
+++ b/includes/skins/Skin.php
@@ -1038,7 +1038,7 @@
                global $wgStylePath, $wgStyleVersion;
 
                if ( $this->stylename === null ) {
-                       $class = get_class( $this );
+                       $class = static::class;
                        throw new MWException( "$class::\$stylename must be set 
to use getSkinStylePath()" );
                }
 
diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php
index 780fac4..61dbf2b 100644
--- a/includes/skins/SkinTemplate.php
+++ b/includes/skins/SkinTemplate.php
@@ -344,7 +344,7 @@
                $tpl->set( 'charset', 'UTF-8' );
                $tpl->setRef( 'wgScript', $wgScript );
                $tpl->setRef( 'skinname', $this->skinname );
-               $tpl->set( 'skinclass', get_class( $this ) );
+               $tpl->set( 'skinclass', static::class );
                $tpl->setRef( 'skin', $this );
                $tpl->setRef( 'stylename', $this->stylename );
                $tpl->set( 'printable', $out->isPrintable() );
diff --git a/includes/specialpage/QueryPage.php 
b/includes/specialpage/QueryPage.php
index 40f82f5..65e82e8 100644
--- a/includes/specialpage/QueryPage.php
+++ b/includes/specialpage/QueryPage.php
@@ -304,7 +304,7 @@
                        return 0;
                }
 
-               $fname = get_class( $this ) . '::recache';
+               $fname = static::class . '::recache';
                $dbw = wfGetDB( DB_MASTER );
                if ( !$dbw ) {
                        return false;
@@ -389,7 +389,7 @@
         * @since 1.18
         */
        public function reallyDoQuery( $limit, $offset = false ) {
-               $fname = get_class( $this ) . "::reallyDoQuery";
+               $fname = static::class . '::reallyDoQuery';
                $dbr = $this->getRecacheDB();
                $query = $this->getQueryInfo();
                $order = $this->getOrderFields();
@@ -480,7 +480,7 @@
        public function getCachedTimestamp() {
                if ( is_null( $this->cachedTimestamp ) ) {
                        $dbr = wfGetDB( DB_REPLICA );
-                       $fname = get_class( $this ) . '::getCachedTimestamp';
+                       $fname = static::class . '::getCachedTimestamp';
                        $this->cachedTimestamp = $dbr->selectField( 
'querycache_info', 'qci_timestamp',
                                [ 'qci_type' => $this->getName() ], $fname );
                }
diff --git a/includes/specialpage/RedirectSpecialPage.php 
b/includes/specialpage/RedirectSpecialPage.php
index ea7d783..b1ddacf 100644
--- a/includes/specialpage/RedirectSpecialPage.php
+++ b/includes/specialpage/RedirectSpecialPage.php
@@ -52,7 +52,7 @@
 
                        return $redirect;
                } else {
-                       $class = get_class( $this );
+                       $class = static::class;
                        throw new MWException( "RedirectSpecialPage $class 
doesn't redirect!" );
                }
        }
diff --git a/includes/tidy/TidyDriverBase.php b/includes/tidy/TidyDriverBase.php
index 96ee8c3..d3f9d48 100644
--- a/includes/tidy/TidyDriverBase.php
+++ b/includes/tidy/TidyDriverBase.php
@@ -27,7 +27,7 @@
         * @return bool Whether the HTML is valid
         */
        public function validate( $text, &$errorStr ) {
-               throw new \MWException( get_class( $this ) . " does not support 
validate()" );
+               throw new \MWException( static::class . ' does not support 
validate()' );
        }
 
        /**
diff --git a/languages/Language.php b/languages/Language.php
index 2ec2d54..0672315 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -415,10 +415,10 @@
        function __construct() {
                $this->mConverter = new FakeConverter( $this );
                // Set the code to the name of the descendant
-               if ( get_class( $this ) == 'Language' ) {
+               if ( static::class === 'Language' ) {
                        $this->mCode = 'en';
                } else {
-                       $this->mCode = str_replace( '_', '-', strtolower( 
substr( get_class( $this ), 8 ) ) );
+                       $this->mCode = str_replace( '_', '-', strtolower( 
substr( static::class, 8 ) ) );
                }
                self::getLocalisationCache();
        }
diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php
index 6a426e5..7721015 100644
--- a/languages/LanguageConverter.php
+++ b/languages/LanguageConverter.php
@@ -845,9 +845,8 @@
         * @throws MWException
         */
        function loadDefaultTables() {
-               $name = get_class( $this );
-
-               throw new MWException( "Must implement loadDefaultTables() 
method in class $name" );
+               $class = static::class;
+               throw new MWException( "Must implement loadDefaultTables() 
method in class $class" );
        }
 
        /**
diff --git a/tests/phpunit/MediaWikiTestCase.php 
b/tests/phpunit/MediaWikiTestCase.php
index 37f76ff..419ff00 100644
--- a/tests/phpunit/MediaWikiTestCase.php
+++ b/tests/phpunit/MediaWikiTestCase.php
@@ -439,7 +439,7 @@
         * @return string Absolute name of the temporary file
         */
        protected function getNewTempFile() {
-               $fileName = tempnam( wfTempDir(), 'MW_PHPUnit_' . get_class( 
$this ) . '_' );
+               $fileName = tempnam( wfTempDir(), 'MW_PHPUnit_' . static::class 
. '_' );
                $this->tmpFiles[] = $fileName;
 
                return $fileName;
@@ -1304,8 +1304,7 @@
                if ( isset( $compatibility[$func] ) ) {
                        return call_user_func_array( [ $this, 
$compatibility[$func] ], $args );
                } else {
-                       throw new MWException( "Called non-existent $func 
method on "
-                               . get_class( $this ) );
+                       throw new MWException( "Called non-existent $func 
method on " . static::class );
                }
        }
 
diff --git a/tests/phpunit/includes/api/ApiTestCase.php 
b/tests/phpunit/includes/api/ApiTestCase.php
index 6b299c9..abef1c9 100644
--- a/tests/phpunit/includes/api/ApiTestCase.php
+++ b/tests/phpunit/includes/api/ApiTestCase.php
@@ -219,7 +219,7 @@
        }
 
        public function testApiTestGroup() {
-               $groups = PHPUnit_Util_Test::getGroups( get_class( $this ) );
+               $groups = PHPUnit_Util_Test::getGroups( static::class );
                $constraint = PHPUnit_Framework_Assert::logicalOr(
                        $this->contains( 'medium' ),
                        $this->contains( 'large' )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1888a1897ecf4548a2e5a67a942e5c080dd7e3d3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

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

Reply via email to