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

Change exclude property to array #1368

Closed
jrfnl opened this issue Jun 8, 2018 · 1 comment
Closed

Change exclude property to array #1368

jrfnl opened this issue Jun 8, 2018 · 1 comment
Milestone

Comments

@jrfnl
Copy link
Member

jrfnl commented Jun 8, 2018

The exclude property which is included in the AbstractFunctionRestrictions sniff and by extension in all sniffs which use the abstract, currently expects a comma-delimited list.
This comma-delimited list is then exploded to an array from within the sniff.

In other words, in reality the sniff expects an array.

I would like to propose to change the expected format for the property to array. Code-wise, this is a very minor change, just changing the docblock & the default value.
The documentation in the wiki would also need to be updated.

While this change is significant, it will not cause a BC-break as the merge_custom_array() function which is used for the exploding is already tolerant of array properties which are incorrectly passed as comma-delimited strings.
Having said that, it makes sense to make this change for the WPCS 1.0.0 release,

The upside of making this change will be that users who use WPCS 3.3.0, can start using the new property array format in their custom rulesets which makes for a more easily readable ruleset.

Old format:

<rule ref="WordPress.VIP.RestrictedFunctions">
	<properties>
		<property name="exclude" value="switch_to_blog,wp_remote_get,cookies" />
	</properties>
</rule>

New format which would become possible after this change:

<rule ref="WordPress.VIP.RestrictedFunctions">
	<properties>
		<property name="exclude" type="array">
			<element value="switch_to_blog"/>
			<element value="wp_remote_get"/>
			<element value="cookies"/>
		</property>
	</properties>
</rule>

Opinions ?

Also: what about removing the support for incorrectly passed array properties in WPCS 2.0.0 ?

@jrfnl jrfnl added this to the 1.0.0 milestone Jun 8, 2018
@JDGrimes
Copy link
Contributor

JDGrimes commented Jun 8, 2018

I'd be good with this change, and I'd favor dropping support for incorrectly passed properties in 2.0.0.

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

No branches or pull requests

2 participants