@@ -29,7 +29,7 @@ class CacheCollector extends DataCollector
2929 /**
3030 * @var \Phpfastcache\Bundle\Service\Phpfastcache
3131 */
32- private $ cache ;
32+ private $ phpfastcache ;
3333
3434 /**
3535 * @var array
@@ -39,11 +39,11 @@ class CacheCollector extends DataCollector
3939 /**
4040 * CacheCollector constructor.
4141 *
42- * @param \Phpfastcache\Bundle\Service\Phpfastcache $cache
42+ * @param \Phpfastcache\Bundle\Service\Phpfastcache $phpfastcache
4343 */
44- public function __construct (Phpfastcache $ cache )
44+ public function __construct (Phpfastcache $ phpfastcache )
4545 {
46- $ this ->cache = $ cache ;
46+ $ this ->phpfastcache = $ phpfastcache ;
4747 }
4848
4949 /**
@@ -59,7 +59,7 @@ public function collect(Request $request, Response $response, \Exception $except
5959 $ driverUsed = [];
6060
6161 /** @var $cache */
62- foreach ($ this ->cache ->getInstances () as $ instanceName => $ cache ) {
62+ foreach ($ this ->phpfastcache ->getInstances () as $ instanceName => $ cache ) {
6363 if ($ cache ->getStats ()->getSize ()) {
6464 $ size += $ cache ->getStats ()->getSize ();
6565 }
@@ -91,109 +91,109 @@ public function collect(Request $request, Response $response, \Exception $except
9191 'namespacePath (deprecated) ' => CacheManager::getNamespacePath (),
9292 ],
9393 '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 ' ],
9696 ],
9797 ];
9898 }
9999
100100 /**
101- * @return mixed
101+ * @return array
102102 */
103- public function getStats ()
103+ public function getStats (): array
104104 {
105- return $ this ->data [ 'stats ' ];
105+ return $ this ->data [ 'stats ' ] ?? [] ;
106106 }
107107
108108 /**
109- * @return mixed
109+ * @return array
110110 */
111- public function getInstances ()
111+ public function getInstances (): array
112112 {
113113 return $ this ->data [ 'instances ' ];
114114 }
115115
116116 /**
117- * @return mixed
117+ * @return array
118118 */
119- public function getDriverUsed ()
119+ public function getDriverUsed (): array
120120 {
121- return $ this ->data [ 'driverUsed ' ];
121+ return $ this ->data [ 'driverUsed ' ] ?? [] ;
122122 }
123123
124124 /**
125- * @return mixed
125+ * @return array
126126 */
127- public function getHits ()
127+ public function getHits (): array
128128 {
129- return $ this ->data [ 'hits ' ];
129+ return $ this ->data [ 'hits ' ] ?? [] ;
130130 }
131131
132132 /**
133- * @return mixed
133+ * @return int
134134 */
135- public function getSize ()
135+ public function getSize (): int
136136 {
137- return $ this ->data [ 'size ' ];
137+ return $ this ->data [ 'size ' ] ?? 0 ;
138138 }
139139
140140 /**
141- * @return mixed
141+ * @return array
142142 */
143- public function getCoreConfig ()
143+ public function getCoreConfig (): array
144144 {
145- return $ this ->data [ 'coreConfig ' ];
145+ return $ this ->data [ 'coreConfig ' ] ?? [] ;
146146 }
147147
148148 /**
149- * @return mixed
149+ * @return array
150150 */
151- public function getProjectConfig ()
151+ public function getProjectConfig (): array
152152 {
153- return $ this ->data [ 'projectConfig ' ];
153+ return $ this ->data [ 'projectConfig ' ] ?? [] ;
154154 }
155155
156156 /**
157- * @return mixed
157+ * @return string
158158 */
159- public function getApiVersion ()
159+ public function getApiVersion (): string
160160 {
161161 return $ this ->data [ 'apiVersion ' ];
162162 }
163163
164164 /**
165- * @return mixed
165+ * @return string
166166 */
167- public function getPfcVersion ()
167+ public function getPfcVersion (): string
168168 {
169169 return $ this ->data [ 'pfcVersion ' ];
170170 }
171171
172172 /**
173- * @return mixed
173+ * @return string
174174 */
175- public function getBundleVersion ()
175+ public function getBundleVersion (): string
176176 {
177177 return $ this ->data [ 'bundleVersion ' ];
178178 }
179179
180180 /**
181- * @return mixed
181+ * @return string
182182 */
183- public function getApiChangelog ()
183+ public function getApiChangelog (): string
184184 {
185- return $ this ->data [ 'apiChangelog ' ];
185+ return $ this ->data [ 'apiChangelog ' ] ?? '' ;
186186 }
187187
188188 /**
189189 * @param string $blockName
190190 * @param array $cacheBlock
191191 * @return $this
192192 */
193- public function setTwigCacheBlock ($ blockName , array $ cacheBlock )
193+ public function setTwigCacheBlock ($ blockName , array $ cacheBlock ): self
194194 {
195195 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 );
197197 }else {
198198 $ this ->twig_cache_blocks [$ blockName ] = $ cacheBlock ;
199199 }
@@ -205,21 +205,25 @@ public function setTwigCacheBlock($blockName, array $cacheBlock)
205205 /**
206206 * @return array
207207 */
208- public function getTwigCacheBlocks ()
208+ public function getTwigCacheBlocks (): array
209209 {
210- return $ this ->data [ 'twigCacheBlocks ' ];
210+ return $ this ->data [ 'twigCacheBlocks ' ] ?? [] ;
211211 }
212212
213213 /**
214- * @return string
214+ * @inheritdoc
215215 */
216- public function getName ()
216+ public function getName (): string
217217 {
218218 return 'phpfastcache ' ;
219219 }
220220
221+ /**
222+ * @inheritdoc
223+ */
221224 public function reset ()
222225 {
223- // TODO: Implement reset() method.
226+ $ this ->data = [];
227+ $ this ->twig_cache_blocks = [];
224228 }
225229}
0 commit comments