Automattic / VIP-Coding-Standards

PHP_CodeSniffer ruleset to enforce WordPress VIP coding standards.
https://wpvip.com/documentation/how-to-install-php-code-sniffer-for-wordpress-com-vip/
Other
236 stars 40 forks source link

Remove Undefined Variable Warning when Arguments are Passed to Templates #598

Closed kopepasah closed 1 year ago

kopepasah commented 3 years ago

What problem would the enhancement address for VIP?

Since WordPress 5.5, we are able to pass argument to a template: https://make.wordpress.org/core/2020/07/17/passing-arguments-to-template-files-in-wordpress-5-5/

However, when doing so the VIP coding standards flags this as an undefined variable.

VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable

Describe the solution you'd like

Pass arguments variable to templates without receiving a warning.

What code should be reported as a violation?

Any time the arguments are pass and not used, perhaps?

What code should not be reported as a violation?

Arguments passed as a variable to templates.

Additional context

Nothing at this time.

jrfnl commented 1 year ago

Correct me if I'm wrong, but wasn't this addressed by adding the allowUndefinedVariablesInFileScope property in PR #690 (included in VIPCS 2.3.3) ?