Per @matmarex, apparently we normally use int not integer and bool not boolean; would be nice to enforce this (and any other similar ones).
Description
Details
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Open | None | T155473 Improve documentation of OOUI | |||
Resolved | Volker_E | T143623 PHP code documentation comments inconsistently use int/number and bool/boolean for types of parameters and return values | |||
Resolved | None | T145162 Provide Codesniffer rules to enforce "short" type definitions (int/bool, not integer/boolean) |
Event Timeline
I looked upstream and the only thing I could find was https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/666
So we'll probably have to write our own.
So I believe there are two places this needs to be done: type casts and documentation blocks. Anywhere else?
Change 362171 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/tools/codesniffer@master] Add sniff to verify type-casts use the short form (bool, int)
Change 362171 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Add sniff to verify type-casts use the short form (bool, int)
Change 362593 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/tools/codesniffer@master] Sniff that the short type form is used in @return tags
Change 362593 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Sniff that the short type form is used in @return tags
The sniff should also check case insensitive and with a colon after it, have seen "@return Boolean: Some comment" in extension RSS
Change 370232 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/tools/codesniffer@master] Enforce "short" type definitions on @param in comments
Have seen "@return integer|bool", which is not covered - also not from my patch set for @param
The check is not run for existing @return/@param of private functions, because the sniff is returning in that case too early for this check. In my opinion if a @param/@return exists on private function it should be checked.
Change 370232 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Enforce "short" type definitions on @param in comments
It is also not run for function of interface or for abstract functions, which can have @return to check.
Change 373954 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/tools/codesniffer@master] Enforce "short" type definitions in multi types in function comments
Change 373954 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Enforce "short" type definitions in multi types in function comments
In https://gerrit.wikimedia.org/r/#/c/375285/1/ShortUrl.utils.php "@return Boolean" was not changed to the short form. I think it's because the B was capitalized? Maybe lowercase forms of all primitive types (array, string, etc) should be a separate task?
I would say that all work is done here. Feel free to create a new task, if anything is open.