@@ -29,7 +29,7 @@ class CacheCollector extends DataCollector
29
29
/**
30
30
* @var \Phpfastcache\Bundle\Service\Phpfastcache
31
31
*/
32
- private $ cache ;
32
+ private $ phpfastcache ;
33
33
34
34
/**
35
35
* @var array
@@ -39,11 +39,11 @@ class CacheCollector extends DataCollector
39
39
/**
40
40
* CacheCollector constructor.
41
41
*
42
- * @param \Phpfastcache\Bundle\Service\Phpfastcache $cache
42
+ * @param \Phpfastcache\Bundle\Service\Phpfastcache $phpfastcache
43
43
*/
44
- public function __construct (Phpfastcache $ cache )
44
+ public function __construct (Phpfastcache $ phpfastcache )
45
45
{
46
- $ this ->cache = $ cache ;
46
+ $ this ->phpfastcache = $ phpfastcache ;
47
47
}
48
48
49
49
/**
@@ -59,7 +59,7 @@ public function collect(Request $request, Response $response, \Exception $except
59
59
$ driverUsed = [];
60
60
61
61
/** @var $cache */
62
- foreach ($ this ->cache ->getInstances () as $ instanceName => $ cache ) {
62
+ foreach ($ this ->phpfastcache ->getInstances () as $ instanceName => $ cache ) {
63
63
if ($ cache ->getStats ()->getSize ()) {
64
64
$ size += $ cache ->getStats ()->getSize ();
65
65
}
@@ -91,109 +91,109 @@ public function collect(Request $request, Response $response, \Exception $except
91
91
'namespacePath (deprecated) ' => CacheManager::getNamespacePath (),
92
92
],
93
93
'projectConfig ' => [
94
- 'twig_driver ' => $ this ->cache ->getConfig ()['twig_driver ' ],
95
- 'twig_block_debug ' => $ this ->cache ->getConfig ()['twig_block_debug ' ],
94
+ 'twig_driver ' => $ this ->phpfastcache ->getConfig ()['twig_driver ' ],
95
+ 'twig_block_debug ' => $ this ->phpfastcache ->getConfig ()['twig_block_debug ' ],
96
96
],
97
97
];
98
98
}
99
99
100
100
/**
101
- * @return mixed
101
+ * @return array
102
102
*/
103
- public function getStats ()
103
+ public function getStats (): array
104
104
{
105
- return $ this ->data [ 'stats ' ];
105
+ return $ this ->data [ 'stats ' ] ?? [] ;
106
106
}
107
107
108
108
/**
109
- * @return mixed
109
+ * @return array
110
110
*/
111
- public function getInstances ()
111
+ public function getInstances (): array
112
112
{
113
113
return $ this ->data [ 'instances ' ];
114
114
}
115
115
116
116
/**
117
- * @return mixed
117
+ * @return array
118
118
*/
119
- public function getDriverUsed ()
119
+ public function getDriverUsed (): array
120
120
{
121
- return $ this ->data [ 'driverUsed ' ];
121
+ return $ this ->data [ 'driverUsed ' ] ?? [] ;
122
122
}
123
123
124
124
/**
125
- * @return mixed
125
+ * @return array
126
126
*/
127
- public function getHits ()
127
+ public function getHits (): array
128
128
{
129
- return $ this ->data [ 'hits ' ];
129
+ return $ this ->data [ 'hits ' ] ?? [] ;
130
130
}
131
131
132
132
/**
133
- * @return mixed
133
+ * @return int
134
134
*/
135
- public function getSize ()
135
+ public function getSize (): int
136
136
{
137
- return $ this ->data [ 'size ' ];
137
+ return $ this ->data [ 'size ' ] ?? 0 ;
138
138
}
139
139
140
140
/**
141
- * @return mixed
141
+ * @return array
142
142
*/
143
- public function getCoreConfig ()
143
+ public function getCoreConfig (): array
144
144
{
145
- return $ this ->data [ 'coreConfig ' ];
145
+ return $ this ->data [ 'coreConfig ' ] ?? [] ;
146
146
}
147
147
148
148
/**
149
- * @return mixed
149
+ * @return array
150
150
*/
151
- public function getProjectConfig ()
151
+ public function getProjectConfig (): array
152
152
{
153
- return $ this ->data [ 'projectConfig ' ];
153
+ return $ this ->data [ 'projectConfig ' ] ?? [] ;
154
154
}
155
155
156
156
/**
157
- * @return mixed
157
+ * @return string
158
158
*/
159
- public function getApiVersion ()
159
+ public function getApiVersion (): string
160
160
{
161
161
return $ this ->data [ 'apiVersion ' ];
162
162
}
163
163
164
164
/**
165
- * @return mixed
165
+ * @return string
166
166
*/
167
- public function getPfcVersion ()
167
+ public function getPfcVersion (): string
168
168
{
169
169
return $ this ->data [ 'pfcVersion ' ];
170
170
}
171
171
172
172
/**
173
- * @return mixed
173
+ * @return string
174
174
*/
175
- public function getBundleVersion ()
175
+ public function getBundleVersion (): string
176
176
{
177
177
return $ this ->data [ 'bundleVersion ' ];
178
178
}
179
179
180
180
/**
181
- * @return mixed
181
+ * @return string
182
182
*/
183
- public function getApiChangelog ()
183
+ public function getApiChangelog (): string
184
184
{
185
- return $ this ->data [ 'apiChangelog ' ];
185
+ return $ this ->data [ 'apiChangelog ' ] ?? '' ;
186
186
}
187
187
188
188
/**
189
189
* @param string $blockName
190
190
* @param array $cacheBlock
191
191
* @return $this
192
192
*/
193
- public function setTwigCacheBlock ($ blockName , array $ cacheBlock )
193
+ public function setTwigCacheBlock ($ blockName , array $ cacheBlock ): self
194
194
{
195
195
if (isset ($ this ->twig_cache_blocks [$ blockName ])){
196
- $ this ->twig_cache_blocks [$ blockName ] = array_merge ($ this ->twig_cache_blocks [$ blockName ], $ cacheBlock );
196
+ $ this ->twig_cache_blocks [$ blockName ] = \ array_merge ($ this ->twig_cache_blocks [$ blockName ], $ cacheBlock );
197
197
}else {
198
198
$ this ->twig_cache_blocks [$ blockName ] = $ cacheBlock ;
199
199
}
@@ -205,21 +205,25 @@ public function setTwigCacheBlock($blockName, array $cacheBlock)
205
205
/**
206
206
* @return array
207
207
*/
208
- public function getTwigCacheBlocks ()
208
+ public function getTwigCacheBlocks (): array
209
209
{
210
- return $ this ->data [ 'twigCacheBlocks ' ];
210
+ return $ this ->data [ 'twigCacheBlocks ' ] ?? [] ;
211
211
}
212
212
213
213
/**
214
- * @return string
214
+ * @inheritdoc
215
215
*/
216
- public function getName ()
216
+ public function getName (): string
217
217
{
218
218
return 'phpfastcache ' ;
219
219
}
220
220
221
+ /**
222
+ * @inheritdoc
223
+ */
221
224
public function reset ()
222
225
{
223
- // TODO: Implement reset() method.
226
+ $ this ->data = [];
227
+ $ this ->twig_cache_blocks = [];
224
228
}
225
229
}
0 commit comments