Skip to content

Existing function used in Closure::bind leads to "Call to an undefined method" error #4865

@pretzlaw

Description

@pretzlaw

Bug report

(Closure::bind($this->hydrate(), $instance, get_class($instance)))($fieldToValue);
The existing $this->hydrate() function errors with "Call to an undefined method".

Happens in version 0.11.19 (report level 6) as well as the latest version as the playground shows.
A fix for both would be great!

Code snippet that reproduces the problem

https://phpstan.org/r/ff2fa776-026c-43c7-ac75-de530cad4207

A smaller snippet says

Undefined variable: $this

https://phpstan.org/r/8e2b4bdb-668f-4ef3-935d-937d13cc6058

which may be the same or another problem

Expected output

Test is green.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions