phpcs-variable-analysis icon indicating copy to clipboard operation
phpcs-variable-analysis copied to clipboard

Add validUndefinedVariableNamesInFileScope

Open andrewnicols opened this issue 3 years ago • 1 comments

Where a variable is available within the File scope, it will not be available within a function scope without the use of global $varname;.

At the moment it's possible to either set:

  • validUndefinedVariableNames, but this will incorrectly apply within function scope where the variable is not available to be used; or
  • allowUndefinedVariablesInFileScope, but this is an on/off value and may not be accurate.

It should be possible to define which variables are allowed to be used within the file scope.

andrewnicols avatar Feb 28 '22 07:02 andrewnicols

This is a good idea and I think should be fairly easy to implement. I'll see if I can make the time to do so (although if you have time, feel free to give it a try!)

sirbrillig avatar Mar 01 '22 01:03 sirbrillig