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

Details

Related Gerrit Patches:

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 6 2018, 8:39 PM

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 added a subscriber: kostajh.

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 closed this task as Resolved.Sep 4 2019, 6:18 PM
Krinkle claimed this task.
Krinkle added a subscriber: Krinkle.

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