Skip to content

Commit 24d7802

Browse files
Fix
1 parent 204e0e3 commit 24d7802

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Type/Symfony/BrowserKitAssertionTraitReturnTypeExtension.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
use PhpParser\Node\Identifier;
88
use PHPStan\Analyser\Scope;
99
use PHPStan\Type\ExpressionTypeResolverExtension;
10+
use PHPStan\Type\NullType;
1011
use PHPStan\Type\ObjectType;
12+
use PHPStan\Type\ObjectWithoutClassType;
1113
use PHPStan\Type\Type;
14+
use PHPStan\Type\TypeCombinator;
15+
use PHPStan\Type\UnionType;
16+
1217
use function count;
1318

1419
final class BrowserKitAssertionTraitReturnTypeExtension implements ExpressionTypeResolverExtension
@@ -22,7 +27,13 @@ public function getType(Expr $expr, Scope $scope): ?Type
2227
if ($this->isSupported($expr, $scope)) {
2328
$args = $expr->getArgs();
2429
if (count($args) > 0) {
25-
return $scope->getType($args[0]->value);
30+
return TypeCombinator::intersect(
31+
$scope->getType($args[0]->value),
32+
new UnionType([
33+
new ObjectType('Symfony\Component\BrowserKit\AbstractBrowser'),
34+
new NullType(),
35+
]),
36+
);
2637
}
2738

2839
return new ObjectType('Symfony\Component\BrowserKit\AbstractBrowser');

0 commit comments

Comments
 (0)