You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP 7.4 introduces arrow functions. It would be great if this library would add support for these.
// Currently throwing false positives for undefined variables $a x 2, $b x 2, $c x 1.$fn = fn($a, $b, $c) => $a + $b; // Unused $c (false negative).functionfoo() {
$a = 120;
// Currently throwing false positive for undefined variable $b x 2.$fn1 = fn($b) => $a + $b;
// Currently throwing false positive for undefined variable $b.$fn2 = fn($b) => $a; // Unused $b (false negative).// Currently throwing false positive for undefined variable $b x 2, $c x 1.$fn3 = fn($b) => $b + $c; // Undefined $c (false negative). Unused variable $fn3 (correctly thrown).var_dump( $fn1(10) );
var_dump( $fn2(10) );
}
Note: PHPCS itself doesn't properly support arrow functions until PHPCS 3.5.5 (not yet released).
If continued support for older PHPCS versions is desired, you may want to look at the PHPCSUtilsFunctionDeclarations::isArrowFunction() and FunctionDeclarations::getArrowFunctionOpenClose() methods.
Subscribing for updates. Really hoping for a fix, unfortunately having to add // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable to each arrow function really discourages us from using them more widely.
PHP 7.4 introduces arrow functions. It would be great if this library would add support for these.
Note: PHPCS itself doesn't properly support arrow functions until PHPCS 3.5.5 (not yet released).
If continued support for older PHPCS versions is desired, you may want to look at the
PHPCSUtils
FunctionDeclarations::isArrowFunction()
andFunctionDeclarations::getArrowFunctionOpenClose()
methods.Refs:
The text was updated successfully, but these errors were encountered: