1 | <?php |
||
26 | class SymfonyCache implements CacheAdapterInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var RouterInterface |
||
30 | */ |
||
31 | protected $router; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $cacheDir; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $token; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $types; |
||
47 | |||
48 | /** |
||
49 | * @var bool |
||
50 | */ |
||
51 | protected $phpCodeCacheEnabled; |
||
52 | |||
53 | /** |
||
54 | * @var array |
||
55 | */ |
||
56 | protected $servers; |
||
57 | |||
58 | /** |
||
59 | * @var array |
||
60 | */ |
||
61 | protected $timeouts; |
||
62 | |||
63 | /** |
||
64 | * Constructor. |
||
65 | * |
||
66 | * NEXT_MAJOR: make the timeouts argument mandatory |
||
67 | * |
||
68 | * @param RouterInterface $router A router instance |
||
69 | * @param Filesystem $filesystem A Symfony Filesystem component instance |
||
70 | * @param string $cacheDir A Symfony cache directory |
||
71 | * @param string $token A token to clear the related cache |
||
72 | * @param bool $phpCodeCacheEnabled If true, will clear OPcache code cache |
||
73 | * @param array $types A cache types array |
||
74 | * @param array $servers An array of servers |
||
75 | * @param array $timeouts An array of timeout options |
||
76 | */ |
||
77 | public function __construct(RouterInterface $router, Filesystem $filesystem, $cacheDir, $token, $phpCodeCacheEnabled, array $types, array $servers, array $timeouts = []) |
||
97 | |||
98 | /** |
||
99 | * {@inheritdoc} |
||
100 | */ |
||
101 | public function flushAll() |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | * |
||
109 | * @throws \InvalidArgumentException |
||
110 | */ |
||
111 | public function flush(array $keys = ['all']) |
||
161 | |||
162 | /** |
||
163 | * Symfony cache action. |
||
164 | * |
||
165 | * @param string $token A Sonata symfony cache token |
||
166 | * @param string $type A cache type to invalidate (doctrine, translations, twig, ...) |
||
167 | * |
||
168 | * @return Response |
||
169 | * |
||
170 | * @throws AccessDeniedHttpException if token is invalid |
||
171 | * @throws \RuntimeException if specified type is not in allowed types list |
||
172 | */ |
||
173 | public function cacheAction($token, $type) |
||
201 | |||
202 | /** |
||
203 | * {@inheritdoc} |
||
204 | */ |
||
205 | public function has(array $keys) |
||
209 | |||
210 | /** |
||
211 | * {@inheritdoc} |
||
212 | */ |
||
213 | public function set(array $keys, $data, $ttl = 84600, array $contextualKeys = []) |
||
217 | |||
218 | /** |
||
219 | * {@inheritdoc} |
||
220 | */ |
||
221 | public function get(array $keys) |
||
225 | |||
226 | /** |
||
227 | * {@inheritdoc} |
||
228 | */ |
||
229 | public function isContextual() |
||
233 | |||
234 | /** |
||
235 | * Returns URL with given token used for cache invalidation. |
||
236 | * |
||
237 | * @param string $type |
||
238 | * |
||
239 | * @return string |
||
240 | */ |
||
241 | protected function getUrl($type) |
||
248 | |||
249 | /** |
||
250 | * Clears code cache with PHP OPcache. |
||
251 | */ |
||
252 | protected function clearPHPCodeCache() |
||
262 | } |
||
263 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.