diff --git a/composer.json b/composer.json index 0e8c0a2..0d8ab9f 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "name": "Jeroen Versteeg" } ], - "version": "1.0.3", + "version": "1.0.4", "autoload": { "psr-4": { "AlisQI\\TwigQI\\": "src/" diff --git a/composer.lock b/composer.lock index 930739a..06e1ff7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4280e65f565d4ec649c5fadfd0cc1040", + "content-hash": "18c90c86ffa11e1f5f312e5b4108fb8f", "packages": [ { "name": "doctrine/deprecations", diff --git a/src/Inspection/BadArgumentCountInMacroCall.php b/src/Inspection/BadArgumentCountInMacroCall.php index 9a7d0a6..45171f3 100644 --- a/src/Inspection/BadArgumentCountInMacroCall.php +++ b/src/Inspection/BadArgumentCountInMacroCall.php @@ -7,7 +7,7 @@ use AlisQI\TwigQI\Helper\NodeLocation; use Twig\Environment; use Twig\Node\Expression\MacroReferenceExpression; -use Twig\Node\Expression\NameExpression; +use Twig\Node\Expression\Variable\ContextVariable; use Twig\Node\MacroNode; use Twig\Node\Node; use Twig\NodeVisitor\NodeVisitorInterface; @@ -47,8 +47,8 @@ public function enterNode(Node $node, Environment $env): Node ]; } - // add 'varargs' to signature if it's used anywhere (i.e., there's a NameExpression that uses it) - if ($this->hasVarArgsNameExpressionDescendant($node)) { + // add 'varargs' to signature if it's used anywhere (i.e., there's a ContextVariable that uses it) + if ($this->hasVarArgsContextVariableDescendant($node)) { $signature[] = ['name' => MacroNode::VARARGS_NAME, 'required' => false]; } @@ -114,16 +114,16 @@ public function getPriority(): int return 0; } - private function hasVarArgsNameExpressionDescendant(Node $node): bool { + private function hasVarArgsContextVariableDescendant(Node $node): bool { if ( - $node instanceof NameExpression && + $node instanceof ContextVariable && $node->getAttribute('name') === MacroNode::VARARGS_NAME ) { return true; } foreach ($node as $childNode) { - if ($this->hasVarArgsNameExpressionDescendant($childNode)) { + if ($this->hasVarArgsContextVariableDescendant($childNode)) { return true; } } diff --git a/src/Inspection/InvalidConstant.php b/src/Inspection/InvalidConstant.php index 5f18de6..ff529df 100644 --- a/src/Inspection/InvalidConstant.php +++ b/src/Inspection/InvalidConstant.php @@ -8,7 +8,7 @@ use Twig\Environment; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\FunctionExpression; -use Twig\Node\Expression\NameExpression; +use Twig\Node\Expression\Variable\ContextVariable; use Twig\Node\Node; use Twig\NodeVisitor\NodeVisitorInterface; @@ -75,7 +75,7 @@ private function checkConstantAndObject(Node $constant, Node $name): ?string return 'first argument must be string'; } - if (!$name instanceof NameExpression) { + if (!$name instanceof ContextVariable) { return 'second argument must be a variable name'; } diff --git a/src/Inspection/InvalidDotOperation.php b/src/Inspection/InvalidDotOperation.php index 1d6cf1d..879ce70 100644 --- a/src/Inspection/InvalidDotOperation.php +++ b/src/Inspection/InvalidDotOperation.php @@ -11,7 +11,7 @@ use Twig\Environment; use Twig\Node\Expression\ArrowFunctionExpression; use Twig\Node\Expression\GetAttrExpression; -use Twig\Node\Expression\NameExpression; +use Twig\Node\Expression\Variable\ContextVariable; use Twig\Node\ForNode; use Twig\Node\MacroNode; use Twig\Node\ModuleNode; @@ -73,7 +73,7 @@ public function enterNode(Node $node, Environment $env): Node if ( $node instanceof GetAttrExpression && $node->getAttribute('type') !== Template::ARRAY_CALL && - ($nameNode = $node->getNode('node')) instanceof NameExpression + ($nameNode = $node->getNode('node')) instanceof ContextVariable ) { $location = new NodeLocation($node); $name = $nameNode->getAttribute('name'); @@ -188,7 +188,7 @@ private function extractScopedVariableTypes(ArrowFunctionExpression|ForNode|SetN $keyType = $valueType = 'mixed'; - if (($seqNode = $node->getNode('seq')) instanceof NameExpression) { + if (($seqNode = $node->getNode('seq')) instanceof ContextVariable) { $seqName = $seqNode->getAttribute('name'); if ((null !== $seqType = $this->getCurrentVariableTypeCollector()->getDeclaredType($seqName))) { diff --git a/src/Inspection/RequiredMacroArgumentAfterOptional.php b/src/Inspection/RequiredMacroArgumentAfterOptional.php index 7b22ad2..b33f619 100644 --- a/src/Inspection/RequiredMacroArgumentAfterOptional.php +++ b/src/Inspection/RequiredMacroArgumentAfterOptional.php @@ -6,8 +6,6 @@ use AlisQI\TwigQI\Helper\NodeLocation; use Twig\Environment; -use Twig\Node\Expression\MethodCallExpression; -use Twig\Node\Expression\NameExpression; use Twig\Node\MacroNode; use Twig\Node\Node; use Twig\NodeVisitor\NodeVisitorInterface; diff --git a/src/Inspection/UndeclaredVariableInMacro.php b/src/Inspection/UndeclaredVariableInMacro.php index 2d82742..c150ad7 100644 --- a/src/Inspection/UndeclaredVariableInMacro.php +++ b/src/Inspection/UndeclaredVariableInMacro.php @@ -6,7 +6,7 @@ use Twig\Environment; use Twig\Node\Expression\ArrowFunctionExpression; -use Twig\Node\Expression\NameExpression; +use Twig\Node\Expression\Variable\ContextVariable; use Twig\Node\ForNode; use Twig\Node\MacroNode; use Twig\Node\Node; @@ -44,7 +44,7 @@ public function enterNode(Node $node, Environment $env): Node if ( $this->currentMacro && - $node instanceof NameExpression + $node instanceof ContextVariable ) { $this->checkVariableIsDeclared($node); } @@ -102,7 +102,7 @@ private function getDeclaredVariablesFor(Node $node): array return $variables; } - private function checkVariableIsDeclared(NameExpression $node): void + private function checkVariableIsDeclared(ContextVariable $node): void { $variableName = $node->getAttribute('name');