Skip to content

Wrong assumption about the return value of json_last_error() #2863

@svservices

Description

@svservices

Bug report

PHPStan version: 0.12.5

Description

Script is calling json_decode() on two different strings and converts any json_last_error() to exceptions.
PHPStan complains the return value of the second json_last_error() will always be JSON_ERROR_NONE

Code snippet that reproduces the problem

https://phpstan.org/r/eb3d5718-e882-4912-a5cf-b0389ccae809

Provided sample script confirms this is wrong, because it actually throws the second exception:
https://3v4l.org/nndZP

Expected output

no issue reported

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions