Skip to content

Wrong "If condition is always true" in relation with ?? #7491

@Alkarex

Description

@Alkarex

Bug report

Hello,
PHPStan produces a false positive If condition is always true in relation with ??

Code snippet that reproduces the problem

https://phpstan.org/r/5ac27f4d-2318-4c73-b043-a12cc87553de

Running this script in PHP outputs the else statement, while PHPStan says that the if is always true:

Found World

The same code not in a function does not produce any error, and removing the ?? part also solves the problem.

Expected output

No error

This was found when updating from PHPStan 1.4.x (no bug) to 1.7.14 (bug)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions