Visitar URL original
Generic not widening based on return type · Issue #15417 · phpstan/phpstan · GitHub
Skip to content

Generic not widening based on return type #15417

Description

@mikethea1

Bug report

See example here: https://phpstan.org/r/bdba8ec5-b1df-4ff2-a5d3-e3c0bca0b890

Note that changing the return type to Collection<int, object{ch: string, x: Collection<0|1|2|3, object{t: string}>}> resolves the issue.

Code snippet that reproduces the problem

https://phpstan.org/r/bdba8ec5-b1df-4ff2-a5d3-e3c0bca0b890

Expected output

It feels like this is being too overzealous in terms of constraining the generic based on what is ultimately an implementation detail.

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

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions