Repository navigation
Fixes
-
phpcbf no longer loops on four constructs (#90). Files containing them ended in "FAILED TO FIX", in one case with a mangled comment:
-
PhpCollective.Commenting.InlineDocBlocktreated the description of an inline var annotation as part of the variable name, so on a comment likebool $flag Expand type for psalmthe fixer moved one word to the end on every pass. Only a reversed$var Typepair is swapped now, and the description stays in place. -
The same sniff added a space before
*/on every pass when the comment ended in a character other than a letter or digit, such as a description ending in.. -
PhpCollective.WhiteSpace.ConsistentIndentdedented the second and third expression of a multi-linefor (...)header, and PSR12 indented them back. -
SlevomatCodingStandard.Attributes.AttributeAndTargetSpacingnow hasallowOnSameLineenabled. Without it, an inline parameter attribute was split onto its own line and the trailing-comma sniffs kept adding and removing a comma:public function auth(Request $request, #[SensitiveParameter] array $credentials): Request
Attributes on the same line as their target are now allowed.
-
-
PhpCollective.Classes.Psr4no longer aborts the run when there is nocomposer.json(#89). Running phpcs from a directory without one threw a fatal error. A missing or unreadablecomposer.jsonnow disables only this sniff. Invalid JSON in an existing file still throws. -
Multi-catch type separators are written without spaces (#92), the same as union types:
} catch (ValueError | TypeError $e) { // now reported, auto-fixable } catch (ValueError|TypeError $e) { // now accepted
New sniff
PhpCollective.WhiteSpace.CatchTypeSeparatorSpacing.PSR12.Operators.OperatorSpacingis replaced byPhpCollective.Operators.OperatorSpacing, which reports the same things except catch separators.Behavior change: if your ruleset silences
PSR12.Operators.OperatorSpacingor one of its codes, rename it toPhpCollective.Operators.OperatorSpacing. Code written ascatch (A | B $e)gets a new, auto-fixable error.
Improvements
-
New sniff
PhpCollective.Operators.OperatorPosition(#91).Universal.Operators.ConcatPositionalready moves a wrapped.to the start of the next line. The new sniff does the same for&&,||,and,or,xor,??, the ternary?and:, and binary arithmetic operators:// before $valid = $hasName && $hasEmail; // after $valid = $hasName && $hasEmail;
Unary
+/-, return-type andcasecolons, and nullable?are not touched. If a comment sits between the operator and the next token, the error is reported but not fixed.Behavior change: code with these operators at the end of a line gets new errors. All of them are auto-fixable with phpcbf.
Full Changelog: 0.6.9...0.6.10