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

Functions/DynamicCalls: various bug fixes and improvements #592

Merged
merged 12 commits into from
Nov 23, 2020
Merged
26 changes: 0 additions & 26 deletions WordPressVIPMinimum/Sniffs/Functions/DynamicCallsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,6 @@ public function process_token( $stackPtr ) {
* @return void
*/
private function collect_variables() {
/*
* Make sure we are working with a variable,
* get its value if so.
*/

if (
$this->tokens[ $this->stackPtr ]['type'] !==
'T_VARIABLE'
) {
return;
}

$current_var_name = $this->tokens[ $this->stackPtr ]['content'];

Expand All @@ -131,10 +120,6 @@ private function collect_variables() {
return;
}

if ( $this->tokens[ $t_item_key ]['length'] !== 1 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - what tokens are == and ===?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • == => T_IS_EQUAL
  • === => T_IS_IDENTICAL

Ref: https://www.php.net/manual/en/tokens.php

return;
}

/*
* Find encapsulated string ( "" )
*/
Expand Down Expand Up @@ -181,17 +166,6 @@ private function find_dynamic_calls() {
return;
}

/*
* Make sure we do have a variable to work with.
*/

if (
$this->tokens[ $this->stackPtr ]['type'] !==
'T_VARIABLE'
) {
return;
}

/*
* If variable is not found in our registry of
* variables, do nothing, as we cannot be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ function my_test() {


$my_notokay_func = 'extract';
$my_notokay_func();
$my_notokay_func(); // Bad.

$my_okay_func = 'my_test';
$my_okay_func();
$my_okay_func(); // OK.