New sniff to catch another redundant empty case#2879
Conversation
📝 WalkthroughWalkthroughThis PR introduces a new PHPCS sniff that detects and automatically fixes redundant Changes
Sequence DiagramsequenceDiagram
participant PHPCS as PHPCS Framework
participant Sniff as RemoveRedundantEmptyAfterTruthySniff
participant Tokens as Token Stream
PHPCS->>Tokens: Parse PHP file into tokens
PHPCS->>Sniff: process(File, stackPtr) at T_BOOLEAN_AND
Sniff->>Tokens: Extract left operand tokens
Sniff->>Tokens: Extract right operand tokens
alt Pattern Match: $var && !empty($var)
Sniff->>Sniff: Extract variable name
Sniff->>PHPCS: Report fixable error
Sniff->>Tokens: Replace tokens: remove && !empty(...)
Sniff->>Tokens: Adjust whitespace
Note over Sniff: Simplified to: $var
else No Match
Sniff->>PHPCS: Continue to next token
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This issue in
errors.phpwas throwing an error in PHPStan. It's easily detectable and auto-fixable, so I've added a new sniff.Summary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.