Skip to content

Commit fc7e0ca

Browse files
committed
Drop inClassLike property
1 parent 687c50d commit fc7e0ca

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/Parser/VariadicMethodsVisitor.php

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ final class VariadicMethodsVisitor extends NodeVisitorAbstract
2121

2222
private ?string $inNamespace = null;
2323

24-
private ?string $inClassLike = null;
25-
2624
/** @var array<string> */
2725
private array $classStack = [];
2826

@@ -41,7 +39,6 @@ public function beforeTraverse(array $nodes): ?array
4139
$this->variadicMethods = [];
4240
$this->inNamespace = null;
4341
$this->classStack = [];
44-
$this->inClassLike = null;
4542
$this->inMethod = null;
4643
$this->anonymousClassIndex = 0;
4744

@@ -66,25 +63,27 @@ public function enterNode(Node $node): ?Node
6663
}
6764

6865
$this->classStack[] = $className;
69-
$this->inClassLike = $this->inNamespace !== null ? $this->inNamespace . '\\' . implode('\\', $this->classStack) : implode('\\', $this->classStack);
70-
$this->variadicMethods[$this->inClassLike] ??= [];
66+
$inClassLike = $this->inNamespace !== null ? $this->inNamespace . '\\' . implode('\\', $this->classStack) : implode('\\', $this->classStack);
67+
$this->variadicMethods[$inClassLike] ??= [];
7168
}
7269

73-
if ($this->inClassLike !== null && $node instanceof ClassMethod) {
70+
if ($this->classStack !== [] && $node instanceof ClassMethod) {
7471
$this->inMethod = $node->name->name;
7572
}
7673

7774
if (
78-
$this->inClassLike !== null
75+
$this->classStack !== []
7976
&& $this->inMethod !== null
8077
&& $node instanceof Node\Expr\FuncCall
8178
&& $node->name instanceof Name
8279
&& in_array((string) $node->name, ParametersAcceptor::VARIADIC_FUNCTIONS, true)
8380
) {
84-
if (!array_key_exists($this->inMethod, $this->variadicMethods[$this->inClassLike])) {
85-
$this->variadicMethods[$this->inClassLike][$this->inMethod] = TrinaryLogic::createYes();
81+
$inClassLike = $this->inNamespace !== null ? $this->inNamespace . '\\' . implode('\\', $this->classStack) : implode('\\', $this->classStack);
82+
83+
if (!array_key_exists($this->inMethod, $this->variadicMethods[$inClassLike])) {
84+
$this->variadicMethods[$inClassLike][$this->inMethod] = TrinaryLogic::createYes();
8685
} else {
87-
$this->variadicMethods[$this->inClassLike][$this->inMethod]->and(TrinaryLogic::createYes());
86+
$this->variadicMethods[$inClassLike][$this->inMethod]->and(TrinaryLogic::createYes());
8887
}
8988

9089
}
@@ -96,20 +95,16 @@ public function leaveNode(Node $node): ?Node
9695
{
9796
if (
9897
$node instanceof ClassMethod
99-
&& $this->inClassLike !== null
98+
&& $this->classStack !== []
10099
) {
101-
$this->variadicMethods[$this->inClassLike][$node->name->name] ??= TrinaryLogic::createNo();
100+
$inClassLike = $this->inNamespace !== null ? $this->inNamespace . '\\' . implode('\\', $this->classStack) : implode('\\', $this->classStack);
101+
102+
$this->variadicMethods[$inClassLike][$node->name->name] ??= TrinaryLogic::createNo();
102103
$this->inMethod = null;
103104
}
104105

105106
if ($node instanceof Node\Stmt\ClassLike) {
106107
array_pop($this->classStack);
107-
108-
if ($this->classStack !== []) {
109-
$this->inClassLike = $this->inNamespace !== null ? $this->inNamespace . '\\' . implode('\\', $this->classStack) : implode('\\', $this->classStack);
110-
} else {
111-
$this->inClassLike = null;
112-
}
113108
}
114109

115110
if ($node instanceof Node\Stmt\Namespace_ && $node->name !== null) {

0 commit comments

Comments
 (0)