Page MenuHomePhabricator

Enforce use of static closures
Closed, ResolvedPublic

Description

Discussed briefly at https://gerrit.wikimedia.org/r/c/mediawiki/libs/Minify/+/662077/

This can be achieved by enabling PossiblyStaticMethodPlugin, but suppressing PhanPluginPossiblyStaticPublicMethod, PhanPluginPossiblyStaticProtectedMethod and PhanPluginPossiblyStaticPrivateMethod.

Event Timeline

Change 662110 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/tools/codesniffer@master] Add a new StaticClosureSniff

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

I have created a patch set as poc if this is also possible with a sniff.

That would than also covers tests code, which is not analyzed by phan.

But a sniff is limited in detected the static vs. non-static context of some calls like self::

I have created a patch set as poc if this is also possible with a sniff.

It's certainly possible, but I wonder if it's worth the complexity of maintaining our own sniff.

That would than also covers tests code, which is not analyzed by phan.

I had sent a POC for this a few months ago, to have phan analyze test code but only report the issues we care about. It works as expected, but the runtime on MW core skyrockets, see https://gerrit.wikimedia.org/r/c/mediawiki/tools/phan/+/650235.

Change 662110 merged by jenkins-bot:

[mediawiki/tools/codesniffer@master] Add a new StaticClosureSniff

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

Umherirrender claimed this task.