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

Improve global function call detection #1667

Merged
merged 7 commits into from
Mar 29, 2019

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Mar 28, 2019

Sniff: add two new utility methods is_class_object_call() and is_token_namespaced()

These should help make the checking of whether or not a function call is a global function, method call or a namespaced function call more consistent.

This also implements allowing for the namespace keyword being used as an operator, though this may yield false negatives when the operator is used in a non-namespaced file, but I rate the chances of that happening as small.

These functions will be unit tested by the implementations in various other places and the fact that the existing unit tests still pass after that.

Loosely related to #764

Implement the new methods

In:

  • Sniff::is_in_isset_or_empty()
  • Sniff::is_validated()
  • Sniff::is_use_of_global_constant()
  • AbstractFunctionRestrictionsSniff
  • WordPress.WP.GlobalVariablesOverride
  • WordPress.WP.DiscouragedConstants

jrfnl added 7 commits March 28, 2019 21:00
…oken_namespaced()`

These should help make the checking of whether or not a function call is a global function, method call or a namespaced function call more consistent.

These functions will be unit tested by the implementations in various other places and the fact that the existing unit tests still pass after that.
@GaryJones GaryJones merged commit d3ac40a into develop Mar 29, 2019
@GaryJones GaryJones deleted the feature/improve-global-function-call-detection branch March 29, 2019 00:17
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.

2 participants