Skip to content

Call to function constant() on a separate line has no effect. #9564

@steevanb

Description

@steevanb

Bug report

Hi,

With this code, phpstan report the error Call to function constant() on a separate line has no effect.:

try {
    constant('FOO');
} catch (\Error) {
}

But it should not report an error because constant() can throw an exception when the constant is not found, so we can call constant() without assigning it's return to a variable, just to know if the constant exists.

Code snippet that reproduces the problem

https://phpstan.org/r/0ef2088f-142b-404b-9bb2-a1a0bb7ae01e

Expected output

No error

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions