Skip to content

Incorrect type inference for return type of array_sum() with constant types #9808

@zer0-star

Description

@zer0-star

Bug report

When the type list<1> passed to array_sum(), PHPStan reports the return type is 1, which is not always true.

Code snippet that reproduces the problem

https://phpstan.org/r/2d45917d-fb24-4ecb-8c93-ad279fdd7318

Expected output

Dumped type of $total should be int<1, max>

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

Yes :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions