Page MenuHomePhabricator

Provide Codesniffer rules to enforce primitive types in lowercase in documentation
Closed, ResolvedPublic

Description

The @param or @return or @var documentation tags should use lowercase primitive types:

int, string, bool, array, object, float, double

this should also search for boolean and int, if the short type sniff is disabled - T145162

This could also enforce lowercase for null, true and false and the correct spelling of stdClass

Event Timeline

I am not sure, if this is possible in all cases. When having a class 'Integer' a type hint for that would be okay. But I am not sure, if someone would create such a class in a project to pass objects around instead of primitive types.

Same could be done for all the other types. Feel free to wontfix, if not necessary.

I feel violations are relatively rare, and barely have any impact. In my opinion this does not justify creating a sniff that potentially breaks code that does have a String class.

If anybody want's to tackle this, I feel this should be part of one of the existing sniffs that already check @param and @return tags.

Note that replacements like booleanbool are already done by the FunctionCommentSniff.

I've submitted patches for the deployed uses of String (except for operations/mediawiki-config, which would require a swat deploy) - https://gerrit.wikimedia.org/r/#/q/topic:lowercase-string+(status:open+OR+status:merged)

Change 591443 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/tools/codesniffer@master] Expand FunctionCommentSniff to enforce lowercase primitive types

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

Change 591443 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Expand FunctionCommentSniff to enforce lowercase primitive types

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

this should also search for boolean and int, if the short type sniff is disabled

That part is not done, but it is hard to find out if a sniff is disabled and doing other things so it is okay how it was fixed