1 | <?php |
||
45 | class GenericCacheAdapter implements CacheAdapterInterface |
||
46 | { |
||
47 | |||
48 | /** |
||
49 | * Trait that provides custom cache adapter functionality. |
||
50 | * |
||
51 | * @var TechDivision\Import\Cache\CacheAdapterTrait |
||
52 | */ |
||
53 | use CacheAdapterTrait; |
||
54 | |||
55 | /** |
||
56 | * The cache for the query results. |
||
57 | * |
||
58 | * @var \Psr\Cache\CacheItemPoolInterface |
||
59 | */ |
||
60 | protected $cache; |
||
61 | |||
62 | /** |
||
63 | * The cache key utility instance. |
||
64 | * |
||
65 | * @var \TechDivision\Import\Utils\CacheKeyUtilInterface |
||
66 | */ |
||
67 | protected $cacheKeyUtil; |
||
68 | |||
69 | /** |
||
70 | * Initialize the cache handler with the passed cache and configuration instances. |
||
71 | * . |
||
72 | * @param \Psr\Cache\CacheItemPoolInterface $cache The cache instance |
||
73 | * @param \TechDivision\Import\Utils\CacheKeyUtilInterface $cacheKeyUtil The cache key utility instance |
||
74 | */ |
||
75 | public function __construct( |
||
84 | |||
85 | /** |
||
86 | * Resolve's the cache key. |
||
87 | * |
||
88 | * @param string $from The cache key to resolve |
||
89 | * |
||
90 | * @return string The resolved reference |
||
91 | */ |
||
92 | protected function resolveReference($from) |
||
109 | |||
110 | /** |
||
111 | * Creates a unique cache key from the passed data. |
||
112 | * |
||
113 | * @param mixed $data The date to create the cache key from |
||
114 | * @param boolean $usePrefix Flag to signal using the prefix or not |
||
115 | * |
||
116 | * @return string The generated cache key |
||
117 | */ |
||
118 | public function cacheKey($data, $usePrefix = true) |
||
122 | |||
123 | /** |
||
124 | * Query whether or not a cache value for the passed cache key is available. |
||
125 | * |
||
126 | * @param string $key The cache key to query for |
||
127 | * |
||
128 | * @return boolean TRUE if the a value is available, else FALSE |
||
129 | */ |
||
130 | public function isCached($key) |
||
141 | |||
142 | /** |
||
143 | * Inversion of the isCached() method. |
||
144 | * |
||
145 | * @param string $key The cache key to query for |
||
146 | * |
||
147 | * @return boolean TRUE if the value is not available, else FALSE |
||
148 | */ |
||
149 | public function notCached($key) |
||
153 | |||
154 | /** |
||
155 | * Add's a cache reference from one key to another. |
||
156 | * |
||
157 | * @param string $from The key to reference from |
||
158 | * @param string $to The key to reference to |
||
159 | * |
||
160 | * @return void |
||
161 | */ |
||
162 | public function addReference($from, $to) |
||
179 | |||
180 | /** |
||
181 | * Add the passed item to the cache. |
||
182 | * |
||
183 | * @param string $key The cache key to use |
||
184 | * @param mixed $value The value that has to be cached |
||
185 | * @param array $references An array with references to add |
||
186 | * @param array $tags An array with tags to add |
||
187 | * @param boolean $override Flag that allows to override an exising cache entry |
||
188 | * @param integer $time The TTL in seconds for the passed item |
||
189 | * |
||
190 | * @return void |
||
191 | */ |
||
192 | public function toCache($key, $value, array $references = array(), array $tags = array(), $override = true, $time = null) |
||
231 | |||
232 | /** |
||
233 | * Returns a new cache item for the passed key |
||
234 | * |
||
235 | * @param string $key The cache key to return the item for |
||
236 | * |
||
237 | * @return mixed The value for the passed key |
||
238 | */ |
||
239 | public function fromCache($key) |
||
243 | |||
244 | /** |
||
245 | * Flush the cache and remove the references. |
||
246 | * |
||
247 | * @return void |
||
248 | */ |
||
249 | public function flushCache() |
||
253 | |||
254 | /** |
||
255 | * Invalidate the cache entries for the passed tags. |
||
256 | * |
||
257 | * @param array $tags The tags to invalidate the cache for |
||
258 | * |
||
259 | * @return void |
||
260 | */ |
||
261 | public function invalidateTags(array $tags) |
||
298 | |||
299 | /** |
||
300 | * Remove the item with the passed key and all its references from the cache. |
||
301 | * |
||
302 | * @param string $key The key of the cache item to Remove |
||
303 | * |
||
304 | * @return void |
||
305 | */ |
||
306 | public function removeCache($key) |
||
325 | } |
||
326 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.