Skip to content

Commit 2b384aa

Browse files
Add test
1 parent a3612cb commit 2b384aa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/PHPStan/Rules/Api/data/instanceof-type.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace ApiInstanceofType;
44

55
use PHPStan\Type\Generic\GenericObjectType;
6+
use PHPStan\Type\SimultaneousTypeTraverser;
67
use PHPStan\Type\Type;
78
use PHPStan\Type\TypeTraverser;
89
use PHPStan\Type\TypeWithClassName;
@@ -40,6 +41,15 @@ public function doFoo($a, Type $type)
4041
if ($a instanceof GenericObjectType) {
4142

4243
}
44+
45+
$type = SimultaneousTypeTraverser::map($type, $type, function (Type $left, Type $right, callable $traverse): Type {
46+
if ($left instanceof TypeWithClassName) {
47+
return $left;
48+
}
49+
50+
return $traverse($left, $right);
51+
});
52+
4353
}
4454

4555
}

0 commit comments

Comments
 (0)