Skip to content

Using an unsupported PHP feature causes an unclear error message #5265

@ciaranmcnulty

Description

@ciaranmcnulty

I used a nullsafe method call:

return $order->getId()?->asString();

and got the error:

UnrecognizedExpression - src/Application/OrdersService.php:19:16 - Psalm does not understand PhpParser\Node\Expr\NullsafeMethodCalll (see https://psalm.dev/048)

This was because although I was using PHP 8 my project's composer.json defined a lower version. The root cause isn't really clear from the error, and the linked page says "This should never happen."

Possibly these cases could be handled with a more clear error message + linked explanation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions