Skip to content

Ignore logical operand values when used as shorthand if #7270

@goulashsoup

Description

@goulashsoup

Bug report

Logical operations can be used as standalone statements, therefore as shorthand if:

Code snippet that reproduces the problem

$ifTrue && $obj->setVal();

PHPStan erroneously expects these operations to be used as evaluated values, not as standalone statements.

Only booleans are allowed in &&, void given on the right side.
Right side of && is always false.

https://phpstan.org/r/b03ddbd5-bc16-45e3-8ffa-5f971cf0f72f

Expected output

The operation should be ignored or only report an error if one part will NEVER be executed.

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