@@ -35,6 +35,9 @@ class OtherMethodQueryBuilderParser
35
35
/** @var Container */
36
36
private $ container ;
37
37
38
+ /** @var array<string, array<string, list<QueryBuilderType>>> */
39
+ private $ cache = [];
40
+
38
41
public function __construct (bool $ descendIntoOtherMethods , Parser $ parser , Container $ container )
39
42
{
40
43
$ this ->descendIntoOtherMethods = $ descendIntoOtherMethods ;
@@ -51,18 +54,23 @@ public function findQueryBuilderTypesInCalledMethod(Scope $scope, MethodReflecti
51
54
return [];
52
55
}
53
56
57
+ $ methodName = $ methodReflection ->getName ();
54
58
$ fileName = $ methodReflection ->getDeclaringClass ()->getFileName ();
55
59
if ($ fileName === null ) {
56
60
return [];
57
61
}
58
62
63
+ if (isset ($ this ->cache [$ fileName ][$ methodName ])) {
64
+ return $ this ->cache [$ fileName ][$ methodName ];
65
+ }
66
+
59
67
$ nodes = $ this ->parser ->parseFile ($ fileName );
60
68
$ classNode = $ this ->findClassNode ($ methodReflection ->getDeclaringClass ()->getName (), $ nodes );
61
69
if ($ classNode === null ) {
62
70
return [];
63
71
}
64
72
65
- $ methodNode = $ this ->findMethodNode ($ methodReflection -> getName () , $ classNode ->stmts );
73
+ $ methodNode = $ this ->findMethodNode ($ methodName , $ classNode ->stmts );
66
74
if ($ methodNode === null || $ methodNode ->stmts === null ) {
67
75
return [];
68
76
}
@@ -100,6 +108,8 @@ public function findQueryBuilderTypesInCalledMethod(Scope $scope, MethodReflecti
100
108
});
101
109
});
102
110
111
+ $ this ->cache [$ fileName ][$ methodName ] = $ queryBuilderTypes ;
112
+
103
113
return $ queryBuilderTypes ;
104
114
}
105
115
0 commit comments