eclipse-pdt / pdt

PHP Development Tools project (PDT)
https://eclipse.org/pdt
Eclipse Public License 2.0
189 stars 46 forks source link

Validation problem with PHP arrow function arguments #158

Closed kooldev closed 1 year ago

kooldev commented 1 year ago

Arrow function arguments are being reported as undefined variables. Here is a simple reproducer:

$y = 2;
$cb = fn ($x) => $x * $y;

var_dump($cb(1)); // int(2)

Argument $x and use of $x within $x * $y yield undefined variable $x problems. However auto-complete does work. Adding a type-hint to argument $x will suggest completions when I type $x-> within the arrow function expression. No problems are being generated for variable $y and it will be suggested by auto-complete if I write $ and hit CTRL+Space within the arrow function expression (variable $x is absent from the list of suggested variables).

Configuration setting Undefined variable within preferences "PHP" / "Validation" / "Errors/Warnings" needs to be set to any option except for Ignore for this to show up.

I first observed this behavior on Windows 10 using PDT version 7.2.0. The problem is still present after upgrading to PDT 8.0.0 nightly build today.

pounard commented 1 year ago

This is a duplicate of https://github.com/eclipse/pdt/issues/73

kooldev commented 1 year ago

@pounard Whoops, you are right. I forgot to check the list of open issues before posting this. 🤦

pounard commented 1 year ago

No worries, no harm done!