Page MenuHomePhabricator

$maintClass in maintenance class files should be set with ::class name resolution
Closed, ResolvedPublic

Description

Using the ::class name resolution feature for the $maintClass variable in maintenance script would be a nice code improvement and allows to validate the line with phan.

$maintClass = "DeleteInactiveNewsletters";

better:

$maintClass = DeleteInactiveNewsletters::class;

Without the need of \Namespace, because it is always in the same namespace as the file.

https://codesearch.wmcloud.org/search/?q=%5C%24maintClass%5Cs*%3D%5Cs*%5B%5Ea-zA-Z%5Cs%5D&i=nope&files=&excludeFiles=&repos=

Example patch set: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Newsletter/+/494026

Should be detected by a linter like codesniffer or phan? (when using phan, maybe could be resolved together with T234749)

Event Timeline

I think this specific instance can be resolved with PHPCS. We'd only be looking for a variable named $maintClass in the global scope in a maintenance script, as long as there's nothing more, codesniffer would suffice.

Change 684987 had a related patch set uploaded (by Sahilgrewalhere; author: Sahilgrewalhere):

[mediawiki/extensions/BlueSpiceSocial@master] Added: ::class name resolution in $maintclass

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

Change 684987 merged by jenkins-bot:

[mediawiki/extensions/BlueSpiceSocial@master] Added: ::class name resolution in $maintclass

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

Change 685920 had a related patch set uploaded (by Sahilgrewalhere; author: Sahilgrewalhere):

[mediawiki/extensions/BlueSpicePermissionManager@master] Added: ::class name resolution in $maintclass

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

Change 685920 abandoned by Sahilgrewalhere:

[mediawiki/extensions/BlueSpicePermissionManager@master] Added: ::class name resolution in $maintclass

Reason:

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

Change 686217 had a related patch set uploaded (by Sahilgrewalhere; author: Sahilgrewalhere):

[mediawiki/extensions/MathSearch@master] Added: ::class name resolution in $maintclass

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

Change 686347 had a related patch set uploaded (by Sahilgrewalhere; author: Sahilgrewalhere):

[mediawiki/extensions/Cargo@master] Added: ::class name resolution in $maintclass

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

Change 686350 had a related patch set uploaded (by Sahilgrewalhere; author: Sahilgrewalhere):

[mediawiki/extensions/NSFileRepo@master] Added: ::class name resolution in $maintclass

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

Change 686362 had a related patch set uploaded (by Sahilgrewalhere; author: Sahilgrewalhere):

[mediawiki/extensions/RevisionCommentSupplement@master] Added: ::class name resolution in $maintclass

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

Change 686347 merged by jenkins-bot:

[mediawiki/extensions/Cargo@master] Added: ::class name resolution in $maintclass

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

Change 686362 merged by jenkins-bot:

[mediawiki/extensions/RevisionCommentSupplement@master] Added: ::class name resolution in $maintclass

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

Change 685920 restored by Umherirrender:

[mediawiki/extensions/BlueSpicePermissionManager@master] Added: ::class name resolution in $maintclass

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

Change 685920 merged by Umherirrender:

[mediawiki/extensions/BlueSpicePermissionManager@master] Added: ::class name resolution in $maintclass

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

Change 686217 merged by jenkins-bot:

[mediawiki/extensions/MathSearch@master] Added: ::class name resolution in $maintclass

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

Change 686350 merged by jenkins-bot:

[mediawiki/extensions/NSFileRepo@master] Added: ::class name resolution in $maintclass

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

Change 687756 had a related patch set uploaded (by Sahilgrewalhere; author: Sahilgrewalhere):

[mediawiki/extensions/BlueSpiceDashboards@master] Added: ::class name resolution in $maintclass

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

Change 687759 had a related patch set uploaded (by Sahilgrewalhere; author: Sahilgrewalhere):

[mediawiki/extensions/BibManager@master] Added: ::class name resolution in $maintclass

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

Change 687765 had a related patch set uploaded (by Sahilgrewalhere; author: Sahilgrewalhere):

[mediawiki/extensions/BlueSpiceBookshelf@master] Added: ::class name resolution in $maintclass

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

Change 687756 merged by jenkins-bot:

[mediawiki/extensions/BlueSpiceDashboards@master] Added: ::class name resolution in $maintclass

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

Change 687765 merged by jenkins-bot:

[mediawiki/extensions/BlueSpiceBookshelf@master] Added: ::class name resolution in $maintclass

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

Change 687759 merged by jenkins-bot:

[mediawiki/extensions/BibManager@master] Added: ::class name resolution in $maintclass

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

Change 689476 had a related patch set uploaded (by Sahilgrewalhere; author: Sahilgrewalhere):

[mediawiki/extensions/ApprovedRevs@master] Added: ::class name resolution in $maintclass

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

Change 689476 merged by jenkins-bot:

[mediawiki/extensions/ApprovedRevs@master] Added: ::class name resolution in $maintclass

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

Change 749568 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/LDAPProvider@master] Use ::class for class names in maintenance scripts

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

Change 749568 merged by jenkins-bot:

[mediawiki/extensions/LDAPProvider@master] Use ::class for class names in maintenance scripts

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

Umherirrender claimed this task.
Umherirrender removed a project: Patch-For-Review.

I have updated the demo and all extensions on gerrit, that should be enough