Skip to content

Access to undefined property with null coalesce  #4559

@bytestream

Description

@bytestream

Bug report

This may duplicate other issues as there are a few null coalescing issues logged but the issue here seems different based on the reproducers in those issues.

The if in the reproducer below causes PHPStan to output Access to an undefined property object::$message.. If you remove ->code from the if then there are no errors i.e.:

if (isset($response->error)) {
	echo $response->error->message ?? '';
}

Code snippet that reproduces the problem

https://phpstan.org/r/b8e9d9e3-73bd-4d8b-a041-41224ecff481

Expected output

No errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions