1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Node;
4:
5: use Override;
6: use PhpParser\Node\Arg;
7: use PhpParser\Node\ArgPlaceholder;
8: use PhpParser\Node\Expr;
9: use PhpParser\Node\Identifier;
10: use PhpParser\Node\VariadicPlaceholder;
11: use PHPStan\Node\Printer\ExprPrinter;
12: use PHPStan\Turbo\ReferencedByTurboExtension;
13:
14: /**
15: * @api
16: */
17: #[ReferencedByTurboExtension(key: 'methodCallableNode')]
18: final class MethodCallableNode extends Expr implements VirtualNode
19: {
20:
21: public function __construct(
22: private Expr $var,
23: private Identifier|Expr $name,
24: private Expr\MethodCall $originalNode,
25: )
26: {
27: // the original's printed expression key must not become this node's
28: $attributes = $originalNode->getAttributes();
29: unset($attributes[ExprPrinter::ATTRIBUTE_CACHE_KEY]);
30: parent::__construct($attributes);
31: }
32:
33: public function getVar(): Expr
34: {
35: return $this->var;
36: }
37:
38: /**
39: * @return Expr|Identifier
40: */
41: public function getName()
42: {
43: return $this->name;
44: }
45:
46: public function getOriginalNode(): Expr\MethodCall
47: {
48: return $this->originalNode;
49: }
50:
51: /**
52: * The arguments of the call: bound arguments, `?` placeholders and the `...` placeholder.
53: *
54: * @return array<Arg|ArgPlaceholder|VariadicPlaceholder>
55: */
56: public function getArgs(): array
57: {
58: return $this->originalNode->getRawArgs();
59: }
60:
61: #[Override]
62: public function getType(): string
63: {
64: return 'PHPStan_Node_MethodCallableNode';
65: }
66:
67: /**
68: * @return string[]
69: */
70: #[Override]
71: public function getSubNodeNames(): array
72: {
73: return [];
74: }
75:
76: }
77: