PHP_CodeSniffer
PHP_CodeSniffer copied to clipboard
Util\Common::$allowedTypes and ::suggestTypes() prefer non-normative types
Describe the bug
The \PHP_CodeSniffer\Util\Common::$allowedTypes
array and \PHP_CodeSniffer\Util\Common::suggestTypes()
method prefer some non-normative types, including:
-
boolean
instead ofbool
-
integer
instead ofint
These aren't the types accepted by the parser for type declarations, and tooling like phpdocumentor and psalm prefer bool
and int
. They do accept both boolean
, and integer
, but then normalise to bool
and int
respectively.
I realise that changing to the normative types may break b/c, but they're just wrong and confusing. I suspect that the sniffs using these are not well used, in part because of these cases.
- https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Util/Common.php#L24-L26
- https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Util/Common.php#L460-L468
Code sample
N/A
Custom ruleset
N/A
Expected behavior
Use bool
and int
.
Versions (please complete the following information)
master branch
Additional context
Used in:
- src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php
- src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php
Please confirm:
- [x] I have searched the issue list and am not opening a duplicate issue.
- [x] I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
- [x] I have verified the issue still exists in the
master
branch of PHP_CodeSniffer.