Skip to content

static closures with arrow functions and normal functions are not detected #9148

@torian257x

Description

@torian257x
class MyClass
{


    private $mything = ['gaga'];
    /** @test */
    public function mytest(){
        $rv = array_map(static function($record ) { return $this->mything;}, ['a', 'b']);
    }
class MyClass
{
    private $mything = ['gaga'];
public function mytest(){
   $rv = array_map(static fn($record ) => $this->mything, ['a', 'b']);
}

both is wrong php code since you have no access to $this inside of static closures (static closures are, supposedly, a bit faster https://github.com/Ocramius/GeneratedHydrator/releases/tag/3.0.0 )

https://psalm.dev/r/6414bd28cf

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions