Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom property arrays: be lenient about space usage #1689

Merged

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Oct 7, 2017

While it is debatable whether it is a bug or a feature that custom property arrays are unforgiving about spaces surrounding the individual keys and values, all custom array properties in PHPCS itself do not expect spaces around them.

This minor change removes spaces around array keys and values before the property is passed to the sniff.

This means that each of the below examples will now result in the same property value being set:

<rule ref="Generic.PHP.ForbiddenFunctions">
        <properties>
            <property name="forbiddenFunctions" value="print=>echo,create_function=>null" type="array" />
            <property name="forbiddenFunctions" value="print=>echo, create_function=>null" type="array" />
            <property name="forbiddenFunctions" value="print => echo, create_function => null" type="array" />
        </properties>
</rule>

Fixes #1688

While it is debatable whether it is a bug or a feature that custom property arrays are unforgiving about spaces surrounding the individual keys and values, all custom properties in PHPCS itself do not expect spaces around them.

This minor change removes spaces around array keys and values before the property is passed to the sniff.

This means that each of the below examples will now result in the same property value being set:
```xml
<rule ref="Generic.PHP.ForbiddenFunctions">
        <properties>
            <property name="forbiddenFunctions" value="print=>echo,create_function=>null" type="array" />
            <property name="forbiddenFunctions" value="print=>echo, create_function=>null" type="array" />
            <property name="forbiddenFunctions" value="print => echo, create_function => null" type="array" />
        </properties>
</rule>
```

Fixes 1688
@gsherwood
Copy link
Member

Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants