Skip to content

Declaration of multiple class properties in a single line with the nullable operator #2886

@brosland

Description

@brosland

Bug report

Hello, I have a problem with the declaration of multiple class properties in a single line with the nullable operator. The problem is that phpstan see only the first defined property as nullable. Others are not nullable so phpstan reports a lot of bugs related to that. It is possible that the problem is direct in the class reflection.

Tested with:
phpstan: 0.12.7
php: 7.4.1
docker image: php:7.4.1-apache-buster

Code snippet that reproduces the problem

https://phpstan.org/r/eaf8a8d9-8f73-4d82-bb5c-64d3fef30def

Expected output

This snippet of code should be without any errors at the level 8.
Instead of that there are 2 reports:

Line 16: Property CreateStatementRequest::$endDate (DateTimeImmutable) does not accept DateTimeImmutable|null.

Line 40: Strict comparison using === between DateTimeImmutable and null will always evaluate to false.

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