Closed darrenedale closed 9 months ago
@darrenedale I've never seen anyone else ask for this and it goes against industry standards like PSR12, so I'm not sure this feature should be accepted without validation that this is something that more than one person intends to use.
I'm leaving this PR open for now to see if more people are interested in this feature.
Please be aware that as things are, the PR is not in a mergable state as there are no tests covering the new feature included.
OK, I'll find a different solution.
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.