@@ -24,13 +24,6 @@ class PropertyInfoCacheExtractor implements PropertyInfoExtractorInterface, Prop
24
24
{
25
25
private $ propertyInfoExtractor ;
26
26
private $ cacheItemPool ;
27
-
28
- /**
29
- * A cache of property information, first keyed by the method called and
30
- * then by the serialized method arguments.
31
- *
32
- * @var array
33
- */
34
27
private $ arrayCache = [];
35
28
36
29
public function __construct (PropertyInfoExtractorInterface $ propertyInfoExtractor , CacheItemPoolInterface $ cacheItemPool )
@@ -110,34 +103,22 @@ private function extract(string $method, array $arguments)
110
103
}
111
104
112
105
// Calling rawurlencode escapes special characters not allowed in PSR-6's keys
113
- $ encodedMethod = rawurlencode ($ method );
114
- if (\array_key_exists ($ encodedMethod , $ this ->arrayCache ) && \array_key_exists ($ serializedArguments , $ this ->arrayCache [$ encodedMethod ])) {
115
- return $ this ->arrayCache [$ encodedMethod ][$ serializedArguments ];
106
+ $ key = rawurlencode ($ method .'. ' .$ serializedArguments );
107
+
108
+ if (\array_key_exists ($ key , $ this ->arrayCache )) {
109
+ return $ this ->arrayCache [$ key ];
116
110
}
117
111
118
- $ item = $ this ->cacheItemPool ->getItem ($ encodedMethod );
112
+ $ item = $ this ->cacheItemPool ->getItem ($ key );
119
113
120
- $ data = $ item ->get ();
121
114
if ($ item ->isHit ()) {
122
- $ this ->arrayCache [$ encodedMethod ] = $ data [$ encodedMethod ];
123
- // Only match if the specific arguments have been cached.
124
- if (\array_key_exists ($ serializedArguments , $ data [$ encodedMethod ])) {
125
- return $ this ->arrayCache [$ encodedMethod ][$ serializedArguments ];
126
- }
127
- }
128
-
129
- // It's possible that the method has been called, but with different
130
- // arguments, in which case $data will already be initialized.
131
- if (!$ data ) {
132
- $ data = [];
115
+ return $ this ->arrayCache [$ key ] = $ item ->get ();
133
116
}
134
117
135
118
$ value = $ this ->propertyInfoExtractor ->{$ method }(...$ arguments );
136
- $ data [$ encodedMethod ][$ serializedArguments ] = $ value ;
137
- $ this ->arrayCache [$ encodedMethod ][$ serializedArguments ] = $ value ;
138
- $ item ->set ($ data );
119
+ $ item ->set ($ value );
139
120
$ this ->cacheItemPool ->save ($ item );
140
121
141
- return $ this ->arrayCache [$ encodedMethod ][ $ serializedArguments ] ;
122
+ return $ this ->arrayCache [$ key ] = $ value ;
142
123
}
143
124
}
0 commit comments