Skip to content

Report bool properties as too wide when only used with true/false #4243

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

Open
wants to merge 3 commits into
base: 2.1.x
Choose a base branch
from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 14, 2025

-
identifier: property.unusedType
message: '#\(bool\) is never assigned (false|true) so it can be removed from the property type#'
path: ../tests/PHPStan/*RuleTest.php

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we cannot use true/false property types in tests, as the simple-downgrader cannot downgrade them.
therefore ignore the errors

@staabm staabm marked this pull request as ready for review August 14, 2025 20:16
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

  1. This doesn't have to be limited to properties
  2. This doesn't have to be limited to PHP versions with native standalone true/false types support. We have PHPDocs after all.

There are many TooWide* rules with duplicated logic and maybe some variances in the logic. First we should refactor and deduplicate the logic where possible.

Then we could introduce a new bleeding edge toggle to enable reporting "too wide bool".

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.

never written static private property in final class not detected
3 participants