Page MenuHomePhabricator

Standardise the docs for variadic arguments and make doxygen understand it
Closed, ResolvedPublic

Description

Somewhat related to T231710. When it comes to documenting variadic parameters, I've seen various format across MediaWiki. The two correct ones are (IMHO):

(1)

/**
 * @param string $params,...
*/
function foo ( ...$params ) // <-- ...$params may or may not be present in the actual signature

(2)

/**
 * @param string ...$params
*/
function foo ( ...$params ) // <-- I think ...$params must be present in the signature in this case

(1) seems to be the format recommended by phpDocumentor (ref); however, in the phpDocumentor example, the variadic parameter is omitted in the signature. Hence, it's possible that this format is only intended for use in that case. PHPCS can read it, phan cannot (I think).

(2) seems like a more natural way to document variadic arguments; PHPCS can read it, and so does phan.

Our doxygen output doesn't prettily handle any of those: example with 1, example with 2.

DOD: We should settle on a single format, and forbid the other one with PHPCS. Our docs generator should also be able to properly handle the chosen format.

Event Timeline

Change 539177 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/tools/codesniffer@master] Improve checks for variargs

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

Change 539177 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Improve checks for variargs

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

Daimona removed a project: Patch-For-Review.