From 0c5b6ecc8fb68aa67606f80d5425334c37991c9d Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 6 Mar 2017 18:14:14 -0800 Subject: [PATCH] Clean up get_class() in /includes/filerepo and /includes/resourceloader * get_class() -> __CLASS__ (same as self::class) * get_called_class() -> static::class * get_class($this) -> static::class Change-Id: Ic4f9b150ddc35e25f51297de7fc12410d421be4d --- includes/filerepo/ForeignAPIRepo.php | 6 +++--- includes/filerepo/ForeignDBRepo.php | 2 +- includes/filerepo/ForeignDBViaLBRepo.php | 2 +- includes/filerepo/NullRepo.php | 2 +- includes/filerepo/file/File.php | 2 +- includes/filerepo/file/LocalFile.php | 6 +++--- includes/resourceloader/ResourceLoaderModule.php | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index ca417187e0..43f1d211b3 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -571,7 +571,7 @@ class ForeignAPIRepo extends FileRepo { $cache = ObjectCache::getMainWANInstance(); return $cache->getWithSetCallback( - $this->getLocalCacheKey( get_class( $this ), $target, md5( $url ) ), + $this->getLocalCacheKey( static::class, $target, md5( $url ) ), $cacheTTL, function ( $curValue, &$ttl ) use ( $url, $cache ) { $html = self::httpGet( $url, 'default', [], $mtime ); @@ -593,13 +593,13 @@ class ForeignAPIRepo extends FileRepo { * @throws MWException */ function enumFiles( $callback ) { - throw new MWException( 'enumFiles is not supported by ' . get_class( $this ) ); + throw new MWException( 'enumFiles is not supported by ' . static::class ); } /** * @throws MWException */ protected function assertWritableRepo() { - throw new MWException( get_class( $this ) . ': write operations are not supported.' ); + throw new MWException( static::class . ': write operations are not supported.' ); } } diff --git a/includes/filerepo/ForeignDBRepo.php b/includes/filerepo/ForeignDBRepo.php index f49ef88c5c..3e8850823e 100644 --- a/includes/filerepo/ForeignDBRepo.php +++ b/includes/filerepo/ForeignDBRepo.php @@ -138,7 +138,7 @@ class ForeignDBRepo extends LocalRepo { } protected function assertWritableRepo() { - throw new MWException( get_class( $this ) . ': write operations are not supported.' ); + throw new MWException( static::class . ': write operations are not supported.' ); } /** diff --git a/includes/filerepo/ForeignDBViaLBRepo.php b/includes/filerepo/ForeignDBViaLBRepo.php index a9cd030869..f83fd1c813 100644 --- a/includes/filerepo/ForeignDBViaLBRepo.php +++ b/includes/filerepo/ForeignDBViaLBRepo.php @@ -100,7 +100,7 @@ class ForeignDBViaLBRepo extends LocalRepo { } protected function assertWritableRepo() { - throw new MWException( get_class( $this ) . ': write operations are not supported.' ); + throw new MWException( static::class . ': write operations are not supported.' ); } public function getInfo() { diff --git a/includes/filerepo/NullRepo.php b/includes/filerepo/NullRepo.php index f2b7395c7b..1c12e0274a 100644 --- a/includes/filerepo/NullRepo.php +++ b/includes/filerepo/NullRepo.php @@ -33,6 +33,6 @@ class NullRepo extends FileRepo { } protected function assertWritableRepo() { - throw new MWException( get_class( $this ) . ': write operations are not supported.' ); + throw new MWException( static::class . ': write operations are not supported.' ); } } diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 3b873eada1..f7e85a8a40 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -1766,7 +1766,7 @@ abstract class File implements IDBAccessObject { * @throws MWException */ function readOnlyError() { - throw new MWException( get_class( $this ) . ': write operations are not supported' ); + throw new MWException( static::class . ': write operations are not supported' ); } /** diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index a1cb0a2473..a633fd2f8d 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -391,7 +391,7 @@ class LocalFile extends File { * @param int $flags */ function loadFromDB( $flags = 0 ) { - $fname = get_class( $this ) . '::' . __FUNCTION__; + $fname = static::class . '::' . __FUNCTION__; # Unconditionally set loaded=true, we don't want the accessors constantly rechecking $this->dataLoaded = true; @@ -416,7 +416,7 @@ class LocalFile extends File { * This covers fields that are sometimes not cached. */ protected function loadExtraFromDB() { - $fname = get_class( $this ) . '::' . __FUNCTION__; + $fname = static::class . '::' . __FUNCTION__; # Unconditionally set loaded=true, we don't want the accessors constantly rechecking $this->extraDataLoaded = true; @@ -1100,7 +1100,7 @@ class LocalFile extends File { */ public function nextHistoryLine() { # Polymorphic function name to distinguish foreign and local fetches - $fname = get_class( $this ) . '::' . __FUNCTION__; + $fname = static::class . '::' . __FUNCTION__; $dbr = $this->repo->getReplicaDB(); diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index d4dabe7d71..a2b4b1d67f 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -843,7 +843,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { */ public function getDefinitionSummary( ResourceLoaderContext $context ) { return [ - '_class' => get_class( $this ), + '_class' => static::class, '_cacheEpoch' => $this->getConfig()->get( 'CacheEpoch' ), ]; } -- 2.20.1