The following code shows me an error:

My guess: Because of the arrow function I cannot use use($f) but as the code is working, it shouldn't be marked as error.

When I change it to function($v) use ($f) { return $v == $f; } then it won't show the error.

Codeinator May I ask if you're running the latest version of phptools extension? (version 1.51)

I'm not getting that, but I remember this was fixed a year ago or so.

    Yes, I'm using the version 1.51

    I tried to create a small example to recreate this problem and I couldn't get it on the first try.
    So I took one more look into my bigger class and I found out that this problem appears in one function which I've disabled for now by placing a return as first line.

    That means that the shown error is much less critical but also not correct.

    So this example should show the error:

    function test()
    {
        return;
    
        $somethingElse = 1; // Unreachable warning shown here
    
        $filter = [1, 2, 3];
        $a = [1, 2, 3];
    
        foreach ($filter as $f)
        {
            $b = array_filter($a, fn($v) => $v === $f);
        }
    }

      Codeinator I see! thank you for finding the sample.

      Yes, I confirm this happens inside an unreachable piece code.

        Write a Reply...