Skip to content

[CodingStyle] Fix NewlineBeforeNewAssignSetRector false positive on local var and $this property name collision - #8535

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-8534-newline-assign-this-property-collision
Oct 7, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
fix-8534-newline-assign-this-property-collision

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes #8534

When a local variable and a class property share the same name, resolveCurrentStmtVariableName() resolved both to the same bare string. A $this->query assign returned the property name query, colliding with a local $query variable.

$query = [];                                    // resolved: query
$this->query = \is_array($query) ? $query : []; // resolved: query  <- collision
$this->another = 'string';                      // resolved: another

Two consecutive same-name entries then tricked the grouping into inserting a blank line before the next statement.

Fix: namespace the $this property result as this->property, so it can no longer match a local variable of the same name. Real runs of the same property still group correctly.

@TomasVotruba
TomasVotruba merged commit d439618 into main Oct 7, 2026
50 checks passed
@TomasVotruba
TomasVotruba deleted the fix-8534-newline-assign-this-property-collision branch October 7, 2026 12:12
@TomasVotruba

TomasVotruba commented Oct 7, 2026 •

Copy link
Copy Markdown
Member Author

This should be fixed as variable and property name are not the same logical concept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

NewlineBeforeNewAssignSetRector false positive with identical local var and class property name

1 participant