Thanks to visit codestin.com
Credit goes to github.com

Skip to content

static return type evaluates to parent class #9449

@Neol3108

Description

@Neol3108

Bug report

We use PHPStan in combination with Laravel a lot and noticed that the static return type on the make method on a child class of Collection (which the make method is declared on) evaluates to Collection as return type, and not the child class.

This seems like unwanted behaviour and can't find a mistake in the phpdocs. Please correct me if I'm wrong tho.

PS: In Laravel the make method is on a trait, at first I thought that was the issue. It seems to however also not work when the method is on the base class, that's why I submitted it like this.

Code snippet that reproduces the problem

https://phpstan.org/r/f747641a-9d84-4349-9a34-510022e3e8e2

Expected output

Dumped type: EloquentCollection<NEVER, NEVER>

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

It helps me everyday spotting little things I would oversee

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