-
Notifications
You must be signed in to change notification settings - Fork 529
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
base: 2.1.x
Are you sure you want to change the base?
Conversation
This pull request has been marked as ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This doesn't have to be limited to properties
- 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".
03b3159
to
59c672f
Compare
@@ -440,11 +440,13 @@ public function testBug4715(): void | |||
public function testBug4734(): void | |||
{ | |||
$errors = $this->runAnalyse(__DIR__ . '/data/bug-4734.php'); | |||
$this->assertCount(3, $errors); | |||
$this->assertCount(5, $errors); // could be 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a topic for a followup: NodeScopeResolver
's ClassStatementsGatherer
works on a per class level, which means access to private properties from a closure-scope (from within a different class) are not seen when analyzing the class which declares the property
I think we are good to go |
@@ -11,8 +11,10 @@ | |||
class LogicalXorConstantConditionRuleTest extends RuleTestCase | |||
{ | |||
|
|||
/** @var true */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than adding @var true
I wonder
- If we should a test with false
- If we should just remove the var
Same for others...
closes phpstan/phpstan#13384