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

Separate out the sniffing for extract(). #604

Merged
merged 1 commit into from
Jul 17, 2016

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jul 15, 2016

Currently only VIP checked for the usage of extract(), even though it is an explicit rule for core.

Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#dont-extract

Solves #90 for real ;-)

Currently only VIP checked for the usage of `extract()`, even though it is an explicit rule for core.

Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#dont-extract

Solved #90 for real ;-)
@JDGrimes
Copy link
Contributor

Why not give the sniff a more generic name, so that other functions can be added in the future? Maybe just Restricted instead of DontExtract?

@JDGrimes
Copy link
Contributor

I guess this relates to #582.

@jrfnl
Copy link
Member Author

jrfnl commented Jul 16, 2016

Why not give the sniff a more generic name, so that other functions can be added in the future

@JDGrimes I followed the handbook - it has a separate section all to itself, so it seemed appropriate to name the rule after the section.

I'd rather have these kind of sniffs more modular and pluggable as - yes - noted in #582, rather than have all of them jumbled together.
That will also make for less backward compatibility breaks for these kind of sniffs.

@JDGrimes JDGrimes added this to the 0.10.0 milestone Jul 17, 2016
@JDGrimes JDGrimes merged commit f19bbab into develop Jul 17, 2016
@JDGrimes JDGrimes deleted the WPCS/feature/dont-extract branch July 17, 2016 16:51
@JDGrimes
Copy link
Contributor

@jrfnl I've decided that you are right and we should keep these sniffs more modular. However, I would add that this will impact performance as we reprocess the tokens for every single child sniff. This ought not so to be. We should refactor the parent sniff so that it only processes each token once. It could keep an index of functions that it found, and then if a child sniff flagged a particular function, it would have stack pointer for all of the times in the file that that function was used already saved from when it processed the functions previously. (Or possibly there is a better way to do this?) Anyway, that is for its own issue.

@jrfnl
Copy link
Member Author

jrfnl commented Jul 18, 2016

@JDGrimes Made a very small start with some efficiency improvement for the AbstractFunctionRestrictionsSniff in #615

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

Successfully merging this pull request may close these issues.

3 participants