Repository navigation
Fix fixer loops that kept phpcbf from converging - #90
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #85
Fixes the three loops from the ticket, plus a fourth in the same sniff:
InlineDocBlock: an inline@var Type $var descriptionis accepted as is. Only a reversed$var Typepair 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-linefor (...)header keep their PSR12 indent.SlevomatCodingStandard.Attributes.AttributeAndTargetSpacinggetsallowOnSameLine, so#[SensitiveParameter] array $xstays 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.