Page MenuHomePhabricator

Make maintenance/findDeprecated use phan instead of php-parser, consider moving to another repo
Open, Needs TriagePublic

Description

While auditing composer dependencies to try to exclude them from phan's analyzed files, I came across nikic/php-parser, which is only used by maintenance/findDeprecated.php. What this script does is iterate all files in includes and, for each file, make a list of deprecated methods (via wfDeprecated and/or @deprecated). Then, it prints the list, order by the MW version in which the methods were deprecated.

This is something that can probably be done using phan, so that we don't have to add another dependency. Moreover, we could think of moving the script to another library (e.g. mediawiki/tools/phan) and make it configurable, e.g. add a directory parameter to use instead of includes.

Details

Event Timeline

Daimona renamed this task from Makee maintenance/findDeprecated use phan instead of php-parser to Make maintenance/findDeprecated use phan instead of php-parser, consider moving to another repo.Jan 22 2020, 1:05 PM

Change 566537 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] Rewrite findDeprecated using phan instead of php-parser

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

Hm, apparently there are other consumers for php-parser. Will need to check up those as well, and see if we can use phan instead (or just leave php-parser in place).

So, aside from findDeprecated, there are two consumers.

  • maintenance/shell.php - This is also the only consumer of Psysh. It looks "weird" to have a single file require two libraries, but I guess it's fine
  • In Flow, scripts/one-class-per-file.php - This looks like a generic util that could be moved elsewhere.

So, for now, I guess we should keep PhpParser.

The Flow script looks ancient and is actually broken, we can safely remove it.

I'm not actively working on this, but I'd be happy to refresh my old patch if others think that moving findDeprecated to another repo as a more generic tool would be a good idea.

I'm not actively working on this, but I'd be happy to refresh my old patch if others think that moving findDeprecated to another repo as a more generic tool would be a good idea.

I'd like if this could be improved and I would be happy to review. I've written a test for this as the script broke (T374832), but the current implementation causes deprecation warnings in PHP 8.2 and above.

Perhaps your patch could be based on top of my test patch ( https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1073181 ) so that we can check that the new implementation works as expected?

Change #566537 abandoned by Hashar:

[mediawiki/core@master] Rewrite findDeprecated using phan instead of php-parser

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

Change #566537 restored by Thcipriani:

[mediawiki/core@master] Rewrite findDeprecated using phan instead of php-parser

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