Skip to content

false-positive in never return type #8319

@zeriyoshi

Description

@zeriyoshi

Bug report

1.9.1 + PHP 8.1.12 and Playground

Code snippet that reproduces the problem

Using never as a return type misrepresents the block as not being executed even when it is possible or certain that it will be executed.

https://phpstan.org/r/da650b46-598a-4859-a252-993257924c92

https://3v4l.org/uagEJ#v8.1.12

This is also true for static methods of the class:

https://phpstan.org/r/d0b781ff-1b54-43e8-99cc-9fc4c2e362cb

Expected output

No error reports

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

I was able to fix 5 defects today by using PHPStan. Very nice tool!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions