Skip to content

Commit 3c5ff39

Browse files
committed
add ObjectValue to exceptions
1 parent e5922fc commit 3c5ff39

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

app/Parsers/ArrayCreationExpressionParser.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Contexts\AbstractContext;
66
use App\Contexts\ArrayValue;
7+
use App\Contexts\ObjectValue;
78
use Microsoft\PhpParser\MissingToken;
89
use Microsoft\PhpParser\Node;
910
use Microsoft\PhpParser\Node\Expression\ArrayCreationExpression;
@@ -16,14 +17,14 @@ class ArrayCreationExpressionParser extends AbstractParser
1617
*/
1718
protected AbstractContext $context;
1819

19-
private function isParentNode(Node $node, string $nodeClass): bool
20+
private function isParentNode(Node $node, array $nodeClasses): bool
2021
{
2122
if ($node->getParent() !== null) {
22-
if ($node->getParent() instanceof $nodeClass) {
23+
if (collect($nodeClasses)->contains(get_class($node->getParent()))) {
2324
return true;
2425
}
2526

26-
return $this->isParentNode($node->getParent(), $nodeClass);
27+
return $this->isParentNode($node->getParent(), $nodeClasses);
2728
}
2829

2930
return false;
@@ -33,8 +34,8 @@ public function parse(ArrayCreationExpression $node)
3334
{
3435
// If array is inside a method, for example Validator::validate(['
3536
// then we need to ignore findable for ArrayValue because
36-
// priority is given to App\Contexts\MethodCall
37-
if (!$this->isParentNode($node, CallExpression::class)) {
37+
// priority is given to App\Contexts\MethodCall or App\Contexts\ObjectValue
38+
if (!$this->isParentNode($node, [CallExpression::class, ObjectValue::class])) {
3839
$this->context->findable = true;
3940
}
4041

0 commit comments

Comments
 (0)