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

Find undefined and unused variables with the PHP Codesniffer static analysis tool.

Results 31 phpcs-variable-analysis issues
Sort by recently updated
recently updated
newest added

Intended to fix https://github.com/sirbrillig/phpcs-variable-analysis/issues/253

Hey, Do you have an ETA for when v3 can have a stable tag? arrow functions are not possible if I recall correctly due to constrains in this package Regards,...

question

Hello! False-positive: ```php if ( true ) [ $a ] = [ 'hi' ]; // VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable return $a ?? ''; // VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable ``` Fine: ```php if ( true ) {...

bug

I noticed when fixing up the CS, that the `VariableAnalysisSniff::processVariableAsStaticDeclaration()` uses outdated assumptions on what can be part of an initial value: ```php // Are we a static declaration? //...

bug

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...

enhancement

I like the idea of allowing some variables only in some files. Other linteres have a `/* global */` special comment, where you can define variables which are passed into...

enhancement
help wanted

As reported in https://github.com/sirbrillig/phpcs-variable-analysis/pull/234 > Array functions like array_merge() and array_values() are "expensive".

enhancement

Trying to avoid this example BAD (due to refactoring, or simple human error): ```php $has_free_tag = has_tag( 'free' ); if ( $has_free_tag ) { ... } ``` BETTER: ```php if...

enhancement
help wanted

Abstract classes can contain abstract methods which are _required_ to be overloaded, but they can also contain empty methods which are _optional_ to overload. ```php abstract class Foo { //...

enhancement

As pointed out by @jrfnl in https://github.com/sirbrillig/phpcs-variable-analysis/pull/207, which added some missing superglobals, `$php_errormsg` is only available conditionally, and even then is deprecated. Therefore I think we should remove it from...