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

Normalize and fix phpdoc typehints across the code #3256

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Riimu
Copy link
Contributor

@Riimu Riimu commented Mar 4, 2021

While writing my own github actions reporter format (to get annotations properly in github), I noticed that my PHPStan was complaining about types in some of the PHP_CodeSniffer code. As a result I noticed that there were several issues when it came to phpdoc types in the code base.

This PR introduces bunch of normalization and fixes to the type hints in the phpdocs of various methods. I tried to normalize the types to what was already the most common format. The following changes have been applied:

  • All occurrences of boolean have been replaced with bool
  • All occurrences of integer have been replaced with int
  • Several instances of \PHP_CodeSniffer\File have been fixed to the correct type \PHP_CodeSniffer\Files\File
  • Couple instanced of File have been replaced with \PHP_CodeSniffer\Files\File since rest of the code base used FQCNs exclusively
  • Couple array types were normalized to what rest of the code base uses

I have not touched any actual code. Only phpdoc comments. Additionally, this PR does not modify any files in test directories, only those that are part of the actual code.

Copy link
Contributor

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Riimu I vaguely seem to remember this codebase preferred long form boolean and integer over short form. I believe it used to actually throw errors about it, but clearly doesn't anymore. So that may need clarification. Other than that, looking good!

@Riimu
Copy link
Contributor Author

Riimu commented Mar 4, 2021

Ah. I assumed int and bool would be preferred since those are what PHP now uses and there seemed to be more usages of int and bool than integer and boolean.

I can swap those around, if requested, or remove those changes entirely too. The real important part is the fixing of those \PHP_CodeSniffer\File references, since they refer to non-existing classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants