Skip to content

False positives for exception expression #3919

Closed
@Chi-teck

Description

@Chi-teck

Describe the bug

Since PHP 8.0 expressions can now throw exceptions.
So the code below is valid. However, it triggers Squiz.PHP.NonExecutableCode.Unreachable warning.

Code sample

$input = TRUE;
$input ?: throw new \RuntimeException('Error.');
echo 'The code was executed';

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions