Page MenuHomePhabricator

Should we mass replace usages of __CLASS__ with self::class?
Open, Needs TriagePublic

Description

A static function MyClass::myFunction

class MyClass {
	private static myFunction() {
	}
}

can be referenced as callable in the same by class as

[ self::class, 'myFunction' ]
self::class . '::myFunction'
[ __CLASS__, 'myFunction' ]
__CLASS__ . '::myFunction'
[ 'MyClass', 'myFunction' ]
'MyClass::myFunction'

It's unclear if there is a preferred variant and which one it should be.

Event Timeline

Change 900813 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/core@master] Use self::class instead of __CLASS__ to resolve self class name

https://gerrit.wikimedia.org/r/900813

thiemowmde renamed this task from Use self::class to reference a function in the self class as callable to Should we mass replace usages of __CLASS__ with self::class?.Mar 28 2023, 3:50 PM
thiemowmde removed Fomafix as the assignee of this task.
thiemowmde edited projects, added: MediaWiki-Codesniffer; removed: MediaWiki-General.
thiemowmde updated the task description. (Show Details)
thiemowmde added subscribers: Krinkle, Umherirrender.

Change #900823 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/JsonData@master] Use self::class instead of __CLASS__ to reference the self class

https://gerrit.wikimedia.org/r/900823

Change #900823 merged by jenkins-bot:

[mediawiki/extensions/JsonData@master] Use self::class instead of __CLASS__ to reference the self class

https://gerrit.wikimedia.org/r/900823

Change #1081918 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/Video@master] Use self::class reference a static function in the same class

https://gerrit.wikimedia.org/r/1081918

Change #900820 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/Gadgets@master] Use self::class instead of __CLASS__ to resolve self class name

https://gerrit.wikimedia.org/r/900820

Change #1081918 merged by jenkins-bot:

[mediawiki/extensions/Video@master] Use self::class reference a static function in the same class

https://gerrit.wikimedia.org/r/1081918

Change #900820 merged by jenkins-bot:

[mediawiki/extensions/Gadgets@master] Use self::class reference a static function in the same class

https://gerrit.wikimedia.org/r/900820

Change #900827 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/FlaggedRevs@master] Use self::class to reference a static function in the same class

https://gerrit.wikimedia.org/r/900827

Change #900827 merged by jenkins-bot:

[mediawiki/extensions/FlaggedRevs@master] Use self::class to reference a static function in the same class

https://gerrit.wikimedia.org/r/900827

Change #900813 merged by jenkins-bot:

[mediawiki/core@master] Use self::class to reference a static function in the same class

https://gerrit.wikimedia.org/r/900813