Skip to content

Commit d0120d7

Browse files
committed
Do not skip specifying virtual nodes
1 parent 5cb3070 commit d0120d7

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/Analyser/TypeSpecifier.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use PhpParser\Node\Expr\StaticPropertyFetch;
2020
use PhpParser\Node\Name;
2121
use PhpParser\PrettyPrinter\Standard;
22-
use PHPStan\Node\VirtualNode;
2322
use PHPStan\Reflection\ReflectionProvider;
2423
use PHPStan\ShouldNotHappenException;
2524
use PHPStan\TrinaryLogic;
@@ -1009,7 +1008,7 @@ public function create(
10091008
?Expr $rootExpr = null,
10101009
): SpecifiedTypes
10111010
{
1012-
if ($expr instanceof Instanceof_ || $expr instanceof Expr\List_ || $expr instanceof VirtualNode) {
1011+
if ($expr instanceof Instanceof_ || $expr instanceof Expr\List_) {
10131012
return new SpecifiedTypes([], [], false, [], $rootExpr);
10141013
}
10151014

src/Node/Printer/Printer.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
namespace PHPStan\Node\Printer;
44

55
use PhpParser\PrettyPrinter\Standard;
6+
use PHPStan\Node\Expr\GetIterableKeyTypeExpr;
7+
use PHPStan\Node\Expr\GetIterableValueTypeExpr;
8+
use PHPStan\Node\Expr\GetOffsetValueTypeExpr;
9+
use PHPStan\Node\Expr\OriginalPropertyTypeExpr;
10+
use PHPStan\Node\Expr\SetOffsetValueTypeExpr;
611
use PHPStan\Node\Expr\TypeExpr;
712
use PHPStan\Type\VerbosityLevel;
813
use function sprintf;
@@ -15,4 +20,29 @@ protected function pPHPStan_Node_TypeExpr(TypeExpr $expr): string // phpcs:ignor
1520
return sprintf('__phpstanType(%s)', $expr->getExprType()->describe(VerbosityLevel::precise()));
1621
}
1722

23+
protected function pPHPStan_Node_GetOffsetValueTypeExpr(GetOffsetValueTypeExpr $expr): string // phpcs:ignore
24+
{
25+
return sprintf('__phpstanGetOffsetValueType(%s, %s)', $this->p($expr->getVar()), $this->p($expr->getDim()));
26+
}
27+
28+
protected function pPHPStan_Node_GetIterableValueTypeExpr(GetIterableValueTypeExpr $expr): string // phpcs:ignore
29+
{
30+
return sprintf('__phpstanGetIterableValueType(%s)', $this->p($expr->getExpr()));
31+
}
32+
33+
protected function pPHPStan_Node_GetIterableKeyTypeExpr(GetIterableKeyTypeExpr $expr): string // phpcs:ignore
34+
{
35+
return sprintf('__phpstanGetIterableKeyType(%s)', $this->p($expr->getExpr()));
36+
}
37+
38+
protected function pPHPStan_Node_OriginalPropertyTypeExpr(OriginalPropertyTypeExpr $expr): string // phpcs:ignore
39+
{
40+
return sprintf('__phpstanOriginalPropertyType(%s)', $this->p($expr->getPropertyFetch()));
41+
}
42+
43+
protected function pPHPStan_Node_SetOffsetValueTypeExpr(SetOffsetValueTypeExpr $expr): string // phpcs:ignore
44+
{
45+
return sprintf('__phpstanSetOffsetValueType(%s, %s, %s)', $this->p($expr->getVar()), $expr->getDim() !== null ? $this->p($expr->getDim()) : 'null', $this->p($expr->getValue()));
46+
}
47+
1848
}

0 commit comments

Comments
 (0)