Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squiz/FunctionDeclarationArgumentSpacing: special case "spacing after…
… comma" vs constructor property promotion While incorrect spacing after a comma for constructor property promotion parameters would already be flagged and fixed by the sniff, the error message and code were incorrect/unclear. Given the following test code: ```php class PropertyPromotionSpacingAfterComma { public function __construct(private string|int $propA, protected bool $correctSpace, public MyClass $tooMuchSpace, readonly string $noSpace) {} } ``` Previously the following would be reported: ``` 198 | ERROR | [x] Expected 1 space between comma and type hint "MyClass"; 2 found | | (Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeHint) 198 | ERROR | [x] Expected 1 space between comma and type hint "string"; 0 found | | (Squiz.Functions.FunctionDeclarationArgumentSpacing.NoSpaceBeforeHint) ``` Take note of the "type hint" in the message and the "Hint" suffix for the error codes. With the fix from this commit in place, this will now be reported as follows: ``` 198 | ERROR | [x] Expected 1 space between comma and property modifier "public"; 2 found | | (Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforePropertyModifier) 198 | ERROR | [x] Expected 1 space between comma and property modifier "readonly"; 0 found | | (Squiz.Functions.FunctionDeclarationArgumentSpacing.NoSpaceBeforePropertyModifier) ``` Includes tests.
- Loading branch information