🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Type inference fails with @phpstan-self-out #13253

Description

@sanmai

Bug report

PHPStan fails to correctly infer callback parameter types when using @phpstan-self-out with methods that accept callbacks returning generators (at very least). The issue manifests when chaining such methods, causing PHPStan to lose track of generic types.

Code snippet that reproduces the problem

https://phpstan.org/r/9bc8431d-be6a-4dfb-9b1a-c8665c724f09

Expected output

I expect no errors in both examples. Currently, the example that does not use method chaining, has no errors, but that which does - ends with lost type information. At the same time @phpstan-self-out and @return declare identical types.

Did PHPStan help you today? Did it make you happy in any way?

It is really surprising how well PHPStan works. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions