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

array use bug #223

Closed
rogertheriault opened this issue Oct 5, 2018 · 6 comments
Closed

array use bug #223

rogertheriault opened this issue Oct 5, 2018 · 6 comments
Milestone

Comments

@rogertheriault
Copy link

the bot frequently warns about an undefined variable when accessing array attributes

$cat_json_data = [];
		$cat_json_data[] = [
  @wpcomvip-vipgoci-bot
wpcomvip-vipgoci-bot 3 hours ago
❗️ Warning: Variable $cat_json_data is undefined.

and similarly in a foreach loop these false warnings have been seen

@GaryJones
Copy link
Contributor

@rogertheriault Can you please give some more context to this - more code?

@rogertheriault
Copy link
Author

Sure, here's a more complete example that should reproduce the issue:

add_filter(
    'blah', function () {
        $variable_name             = [];
        $variable_name['foo']   = 'some-string';
        $variable_name['bar']   = 'another-string';
        return $variable_name;
    }
);

@GaryJones
Copy link
Contributor

The warning is coming from either here or here.

Relevant: #236

@gudmdharalds How much flexibility does the bot have in ignoring certain checks / sniffs?

@gudmdharalds
Copy link
Contributor

@GaryJones: Relatively high. If we want, we can specify that certain sniffs are to be ignored. That should not be complicated to implement.

@GaryJones
Copy link
Contributor

See #236.

@GaryJones GaryJones added this to the 2.1 milestone Jul 13, 2019
@GaryJones
Copy link
Contributor

Now that #449 is completed to use VariableAnalysis proper, I've confirmed that the provided example above doesn't give an error with the develop version of WordPress-VIP-Go, so this is now fixed for VIPCS 2.2.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

3 participants