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

Squiz/DisallowMultipleAssignments: fix sniff walking back too far when going in/out of PHP #538

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jul 13, 2024

Description

The sniff did not recognize that when it would encounter a PHP close tag, it had reached a previous statement, leading to false positives for list assignments.

Fixed now. Includes tests.

Suggested changelog entry

Squiz.PHP.DisallowMultipleAssignments false positive for list assignments at the start of a new PHP block after an embedded PHP statement.

Related issues/external references

Fixes #537

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
@biinari
Copy link
Contributor

biinari commented Jul 13, 2024

Fantastic, thanks for putting this fix together so quickly @jrfnl. Looks good to me and a thorough range of test cases to cover variations.

I've tested this with my original code that brought this issue up for me and it works perfectly.

Copy link
Contributor

@rodrigoprimo rodrigoprimo left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@rodrigoprimo
Copy link
Contributor

While reviewing this PR, I found another false positive that could happen when live coding. The following code triggers the sniff and it should not:

function missingClosingParenthesis($a =

I have a fix ready and I will create a new PR once this one is merged to avoid conflicts.

@rodrigoprimo
Copy link
Contributor

I opened an issue to document the bug that I described above which is probably which I should have done in the first place instead of reporting the problem here in the comment above: #551

…n going in/out of PHP

The sniff did not recognize that when it would encounter a PHP close tag, it had reached a previous statement, leading to false positives for list assignments.

Fixed now. Includes tests.

Fixes 537
@jrfnl jrfnl force-pushed the feature/537-squiz-disallowmultipleassignments-bug-fix branch from bf3d6f5 to 17731a1 Compare July 15, 2024 17:48
@jrfnl
Copy link
Member Author

jrfnl commented Jul 15, 2024

Rebased without changes. Merging once the build has passed.

@jrfnl jrfnl merged commit 131886e into master Jul 15, 2024
48 checks passed
@jrfnl jrfnl deleted the feature/537-squiz-disallowmultipleassignments-bug-fix branch July 15, 2024 19:05
@jrfnl jrfnl mentioned this pull request Jul 15, 2024
54 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment