Page MenuHomePhabricator

Define varargs in \IContextSource::msg() in a way phan can understand it
Closed, ResolvedPublic

Description

Running phan (0.12.5) on some extensions I see often:

<error line="" severity="info" message="Call with 2 arg(s) to \IContextSource::msg() which only takes 1 arg(s) defined at ../languages\MessageLocalizer.php:41" source="PhanParamTooMany"/>

I have never seen this for wfMessage and both are defined the same for the second param (@param mixed $params,...). Maybe phan sees the func_get_args and is happy, but that does not possible on interface declaration.

https://gerrit.wikimedia.org/g/mediawiki/core/+/master/languages/MessageLocalizer.php#28
https://gerrit.wikimedia.org/g/mediawiki/core/+/master/includes/GlobalFunctions.php#1412

I have no idea how to fix this for phan. Maybe this is a upstrem issue?.
Doing things only for a static analyzer is not nice, but the tool is helpful to find other mistakes.
Maybe it needs an own Plugin to declare the varargs on runtime inside phan

Event Timeline

Change 439305 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Document varargs for MessageLocalizer::msg and similar

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

kostajh subscribed.

Not sure if these were the right tags to add, but bumping this since I just encountered this in T216964

Change 439305 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Document varargs for MessageLocalizer::msg and similar

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

Change 439305 abandoned by Umherirrender:
Document varargs for MessageLocalizer::msg and similar

Reason:
there are some similar patch out there

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

Krinkle claimed this task.
Krinkle subscribed.

Looks like the builds have been passing for a while with various workarounds in place. The general issue is blocked on the HHVM migration and covered by T228695.

Change 439305 restored by Umherirrender:
Document varargs for MessageLocalizer::msg and similar

Reason:
Fresh try

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

Change 439305 merged by jenkins-bot:
[mediawiki/core@master] Use varargs for MessageLocalizer::msg and similar

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

Change 544252 had a related patch set uploaded (by Reedy; owner: Umherirrender):
[mediawiki/core@REL1_34] Use varargs for MessageLocalizer::msg and similar

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

Change 544252 merged by jenkins-bot:
[mediawiki/core@REL1_34] Use varargs for MessageLocalizer::msg and similar

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