4
4
5
5
use App \Contexts \AbstractContext ;
6
6
use App \Contexts \ArrayValue ;
7
+ use App \Contexts \ObjectValue ;
7
8
use Microsoft \PhpParser \MissingToken ;
8
9
use Microsoft \PhpParser \Node ;
9
10
use Microsoft \PhpParser \Node \Expression \ArrayCreationExpression ;
@@ -16,14 +17,14 @@ class ArrayCreationExpressionParser extends AbstractParser
16
17
*/
17
18
protected AbstractContext $ context ;
18
19
19
- private function isParentNode (Node $ node , string $ nodeClass ): bool
20
+ private function isParentNode (Node $ node , array $ nodeClasses ): bool
20
21
{
21
22
if ($ node ->getParent () !== null ) {
22
- if ($ node ->getParent () instanceof $ nodeClass ) {
23
+ if (collect ( $ nodeClasses )-> contains ( get_class ( $ node ->getParent ())) ) {
23
24
return true ;
24
25
}
25
26
26
- return $ this ->isParentNode ($ node ->getParent (), $ nodeClass );
27
+ return $ this ->isParentNode ($ node ->getParent (), $ nodeClasses );
27
28
}
28
29
29
30
return false ;
@@ -33,8 +34,8 @@ public function parse(ArrayCreationExpression $node)
33
34
{
34
35
// If array is inside a method, for example Validator::validate(['
35
36
// 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] )) {
38
39
$ this ->context ->findable = true ;
39
40
}
40
41
0 commit comments