Skip to content

Not null Array shape property compared to null should report an error #11609

@momala454

Description

@momala454

Bug report

/** @param object{hello: string, world?: string} $a */
	public function sayHello(object $a, string $b): void
	{
		if ($a->hello !== null) { // should report notIdentical.alwaysTrue 
			echo 'hello';
		}
		if (isset($a->world)) { // shouldn't report any error
			echo 'world';
		}
		if ($b !== null) {
			echo 'b';
		}
	}

Code snippet that reproduces the problem

https://phpstan.org/r/21f33e86-5af2-4456-97dc-33360189e805

Expected output

The comparison of hello which is never null should give an error, like the comparison of $b to null
The comparison of $a->world problem is tracked on #11424

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

yes :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions