Squiz/FunctionDeclarationArgumentSpacing: make the reference operator spacing configurable #3900
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.
Description
Enables the amount of whitespace between the reference operator and the argument name in function declarations to be defined by a property in XML config. The existing sniff fixes this at 0 spaces, meaning function declarations with by-reference arguments must look like this:
My coding style follows PSR12, with a few modifications, one of which is to have a space between the reference operator and the argument name:
Since the PSR12 standard imports
Standards\Squizz\Sniffs\Functions\FunctionDeclarationArgumentSpacingSniff
, and since at present this sniff has a strict requirement of 0 spaces between the reference operator and the argument name, it's not possible to base my standard off PSR12 and make this customisation. This PR resolves that by making the amount of space between the reference operator and the argument name configurable in the XML file, thus:The feature has been implemented similarly to other properties that are configurable in this sniff. Notably, the property controlling the required number of spaces after the reference operator defaults to 0, ensuring that where no customisation is present for this property for this sniff in the configuration file, the sniff continues to behave as it does currently. Therefore existing workflows using this sniff will be unaffected.
Suggested changelog entry
Allow the required spacing between the reference operator and the argument name in function declarations to be customised in configuration files for the Squizz standard's FunctionDeclarationArgumentSpacing sniff.
Related issues/external references
Fixes #
Types of changes
PR checklist
package.xml
file.* I've checked the test and it doesn't look like it's possible to test the sniff with alternate configurations. I'm
happy to write one if I've missed how this is done.