Skip to content

Generic/MultipleStatementAlignment: fix wrapped chained assignment#1444

Open
morozov wants to merge 1 commit into
PHPCSStandards:4.xfrom
morozov:multiple-statement-alignment-wrapped-assignment
Open

Generic/MultipleStatementAlignment: fix wrapped chained assignment#1444
morozov wants to merge 1 commit into
PHPCSStandards:4.xfrom
morozov:multiple-statement-alignment-wrapped-assignment

Conversation

@morozov

@morozov morozov commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

Fixed Generic.Formatting.MultipleStatementAlignment fixer failure to fix a standard violation if a chained assignment is wrapped.

Change summary:

  1. Instead of aligning a wrapped assignment operator against its operand, align it against the start of its own line when it follows another assignment. This stops the fixer from looping.
  2. Measure its padding from the indentation before the operator, not the whitespace after the operand.

Suggested changelog entry

Fixed Generic.Formatting.MultipleStatementAlignment fixer failure to fix a standard violation if a chained assignment is wrapped.

Related issues/external references

Fixes #1435

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

PR checklist

  • I have checked there is no other PR open for the same change.
  • I have read the Contribution Guidelines.
  • I grant the project the right to include and distribute the code under the BSD-3-Clause license (and I have the right to grant these rights).
  • I have added tests to cover my changes.
  • I have verified that the code complies with the projects coding standards.
  • [Required for new sniffs] I have added XML documentation for the sniff.
  • I have opened a sister-PR in the documentation repository to update the Wiki.

Handle assignment operators that are wrapped onto their own line as part
of a chained assignment.
@morozov morozov force-pushed the multiple-statement-alignment-wrapped-assignment branch from f63cac3 to 9813b26 Compare June 24, 2026 01:54
@morozov morozov marked this pull request as ready for review June 24, 2026 02:03
@jrfnl

jrfnl commented Jun 25, 2026

Copy link
Copy Markdown
Member

@morozov Thanks for this PR. Just wondering what happened to the PR template ?

@morozov

morozov commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Just wondering what happened to the PR template ?

Sorry, I prepared the PR description in a local editor and then mechanically inserted into the form.

@jrfnl

jrfnl commented Jun 26, 2026

Copy link
Copy Markdown
Member

Sorry, I prepared the PR description in a local editor and then mechanically inserted into the form.

Understood. Thanks for fixing that up. I'll try and have a look at this tomorrow when my brain is fresh again ;-)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic.Formatting.MultipleStatementAlignment fixer fails on a wrapped chained assignment

2 participants