Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Type/ObjectShapePropertyReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public function getPhpDocType(): Type

public function hasNativeType(): bool
{
return false;
return true;
}

public function getNativeType(): Type
{
return new MixedType();
return $this->type;
}

public function getReadableType(): Type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,16 @@ public function testBug10884(): void
$this->analyse([__DIR__ . '/data/bug-10884.php'], []);
}

public function testBug11609(): void
{
$this->analyse([__DIR__ . '/data/bug-11609.php'], [
[
'Strict comparison using !== between string and null will always evaluate to true.',
16,
],
]);
}

public function testBug3761(): void
{
$this->analyse([__DIR__ . '/data/bug-3761.php'], []);
Expand Down
20 changes: 20 additions & 0 deletions tests/PHPStan/Rules/Comparison/data/bug-11609.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types = 1);

namespace Bug11609;

class HelloWorld
{
/** @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';
}
}
}
Loading