Skip to content

Fix fixer loops that kept phpcbf from converging - #90

Merged
dereuromark merged 1 commit into
masterfrom
fix-fixer-loops
Oct 25, 2026
Merged

dereuromark merged 1 commit into
masterfrom
fix-fixer-loops

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

Closes #85

Fixes the three loops from the ticket, plus a fourth in the same sniff:

  • InlineDocBlock: an inline @var Type $var description is accepted as is. Only a reversed $var Type pair is swapped, and the description stays put. Content without a variable in the first two words is still reported, but no longer rewritten.
  • InlineDocBlock: the "single space before */" check required an alphanumeric last character, so /** @var Foo $x Ends with a dot. */ gained a space on every pass. It now accepts any non-space character.
  • ConsistentIndent: tokens inside parentheses count as a multi-line construct, so the parts of a multi-line for (...) header keep their PSR12 indent.
  • Ruleset: SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing gets allowOnSameLine, so #[SensitiveParameter] array $x stays inline instead of being split onto a tab-indented line. This is the same setting the CakePHP ruleset uses. Attributes on their own line are still checked for blank lines between them and their target.

Before this, phpcbf reported "FAILED TO FIX" on 5 of the 206 cakephp files from the ticket. Now all of them converge and lint clean.

InlineDocBlock treated everything after the type as the variable name, so
an inline @var with a description (`@var bool $x Some text`) was reported
as wrong order and the fixer moved one word to the end on every pass,
mangling the comment. It now only swaps a reversed `$var Type` pair and
leaves any description in place. Other content is still reported, but no
longer "fixed". The single-space-before-`*/` check only accepted an
alphanumeric last character, so a description ending in `.` gained a
space on every pass; it now accepts any non-space character.

ConsistentIndent stopped its backward scan at the `;` inside a multi-line
`for (...)` header and dedented the second and third expressions, which
PSR12 ControlStructureSpacing then indented again. Tokens inside
parentheses now count as a multi-line construct.

AttributeAndTargetSpacing (without allowOnSameLine) moved the target of an
inline parameter attribute such as `#[SensitiveParameter] array $x` onto
its own tab-indented line, turning a single-line signature multi-line, so
the trailing-comma sniffs added and removed a comma forever. Attributes on
the same line as their target are now allowed.

On the 206 files of the cakephp PER-CS PR, phpcbf previously failed to fix
5 files; all now converge and lint clean.
@dereuromark dereuromark added the bug Something isn't working label Oct 25, 2026
Copilot AI balanced review requested due to automatic review settings October 25, 2026 13:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@dereuromark
dereuromark merged commit 89523a3 into master Oct 25, 2026
2 of 5 checks passed
@dereuromark
dereuromark deleted the fix-fixer-loops branch October 25, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

phpcbf never converges: three fixer loops (InlineDocBlock, ConsistentIndent, AttributeAndTargetSpacing)

2 participants