1: | <?php declare(strict_types = 1); |
2: | |
3: | namespace PHPStan\Node\Printer; |
4: | |
5: | use PhpParser\PrettyPrinter\Standard; |
6: | use PHPStan\DependencyInjection\AutowiredService; |
7: | use PHPStan\Node\Expr\AlwaysRememberedExpr; |
8: | use PHPStan\Node\Expr\ExistingArrayDimFetch; |
9: | use PHPStan\Node\Expr\GetIterableKeyTypeExpr; |
10: | use PHPStan\Node\Expr\GetIterableValueTypeExpr; |
11: | use PHPStan\Node\Expr\GetOffsetValueTypeExpr; |
12: | use PHPStan\Node\Expr\OriginalPropertyTypeExpr; |
13: | use PHPStan\Node\Expr\ParameterVariableOriginalValueExpr; |
14: | use PHPStan\Node\Expr\PropertyInitializationExpr; |
15: | use PHPStan\Node\Expr\SetExistingOffsetValueTypeExpr; |
16: | use PHPStan\Node\Expr\SetOffsetValueTypeExpr; |
17: | use PHPStan\Node\Expr\TypeExpr; |
18: | use PHPStan\Node\Expr\UnsetOffsetExpr; |
19: | use PHPStan\Node\IssetExpr; |
20: | use PHPStan\Type\VerbosityLevel; |
21: | use function sprintf; |
22: | |
23: | |
24: | |
25: | |
26: | #[AutowiredService(as: Printer::class)] |
27: | final class Printer extends Standard |
28: | { |
29: | |
30: | protected function pPHPStan_Node_TypeExpr(TypeExpr $expr): string |
31: | { |
32: | return sprintf('__phpstanType(%s)', $expr->getExprType()->describe(VerbosityLevel::precise())); |
33: | } |
34: | |
35: | protected function pPHPStan_Node_GetOffsetValueTypeExpr(GetOffsetValueTypeExpr $expr): string |
36: | { |
37: | return sprintf('__phpstanGetOffsetValueType(%s, %s)', $this->p($expr->getVar()), $this->p($expr->getDim())); |
38: | } |
39: | |
40: | protected function pPHPStan_Node_UnsetOffsetExpr(UnsetOffsetExpr $expr): string |
41: | { |
42: | return sprintf('__phpstanUnsetOffset(%s, %s)', $this->p($expr->getVar()), $this->p($expr->getDim())); |
43: | } |
44: | |
45: | protected function pPHPStan_Node_GetIterableValueTypeExpr(GetIterableValueTypeExpr $expr): string |
46: | { |
47: | return sprintf('__phpstanGetIterableValueType(%s)', $this->p($expr->getExpr())); |
48: | } |
49: | |
50: | protected function pPHPStan_Node_GetIterableKeyTypeExpr(GetIterableKeyTypeExpr $expr): string |
51: | { |
52: | return sprintf('__phpstanGetIterableKeyType(%s)', $this->p($expr->getExpr())); |
53: | } |
54: | |
55: | protected function pPHPStan_Node_ExistingArrayDimFetch(ExistingArrayDimFetch $expr): string |
56: | { |
57: | return sprintf('__phpstanExistingArrayDimFetch(%s, %s)', $this->p($expr->getVar()), $this->p($expr->getDim())); |
58: | } |
59: | |
60: | protected function pPHPStan_Node_OriginalPropertyTypeExpr(OriginalPropertyTypeExpr $expr): string |
61: | { |
62: | return sprintf('__phpstanOriginalPropertyType(%s)', $this->p($expr->getPropertyFetch())); |
63: | } |
64: | |
65: | protected function pPHPStan_Node_SetOffsetValueTypeExpr(SetOffsetValueTypeExpr $expr): string |
66: | { |
67: | return sprintf('__phpstanSetOffsetValueType(%s, %s, %s)', $this->p($expr->getVar()), $expr->getDim() !== null ? $this->p($expr->getDim()) : 'null', $this->p($expr->getValue())); |
68: | } |
69: | |
70: | protected function pPHPStan_Node_SetExistingOffsetValueTypeExpr(SetExistingOffsetValueTypeExpr $expr): string |
71: | { |
72: | return sprintf('__phpstanSetExistingOffsetValueType(%s, %s, %s)', $this->p($expr->getVar()), $this->p($expr->getDim()), $this->p($expr->getValue())); |
73: | } |
74: | |
75: | protected function pPHPStan_Node_AlwaysRememberedExpr(AlwaysRememberedExpr $expr): string |
76: | { |
77: | return sprintf('__phpstanRembered(%s)', $this->p($expr->getExpr())); |
78: | } |
79: | |
80: | protected function pPHPStan_Node_PropertyInitializationExpr(PropertyInitializationExpr $expr): string |
81: | { |
82: | return sprintf('__phpstanPropertyInitialization(%s)', $expr->getPropertyName()); |
83: | } |
84: | |
85: | protected function pPHPStan_Node_ParameterVariableOriginalValueExpr(ParameterVariableOriginalValueExpr $expr): string |
86: | { |
87: | return sprintf('__phpstanParameterVariableOriginalValue(%s)', $expr->getVariableName()); |
88: | } |
89: | |
90: | protected function pPHPStan_Node_IssetExpr(IssetExpr $expr): string |
91: | { |
92: | return sprintf('__phpstanIssetExpr(%s)', $this->p($expr->getExpr())); |
93: | } |
94: | |
95: | } |
96: | |