Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Util\Common::$allowedTypes and ::suggestTypes() prefer non-normative types #406

Open
3 tasks done
andrewnicols opened this issue Mar 18, 2024 · 0 comments
Open
3 tasks done

Comments

@andrewnicols
Copy link

andrewnicols commented Mar 18, 2024

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 of bool
  • integer instead of int

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.

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:

  • I have searched the issue list and am not opening a duplicate issue.
  • I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • I have verified the issue still exists in the master branch of PHP_CodeSniffer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants