1 | <?php |
||
55 | class ArrayCache extends \ArrayObject implements CacheItemPoolInterface |
||
56 | { |
||
57 | |||
58 | /** |
||
59 | * Confirms if the cache contains specified cache item. |
||
60 | * |
||
61 | * Note: This method MAY avoid retrieving the cached value for performance reasons. |
||
62 | * This could result in a race condition with CacheItemInterface::get(). To avoid |
||
63 | * such situation use CacheItemInterface::isHit() instead. |
||
64 | * |
||
65 | * @param string $key The key for which to check existence. |
||
66 | * |
||
67 | * @return boolean True if item exists in the cache, false otherwise. |
||
68 | * @see \Psr\Cache\CacheItemPoolInterface::hasItem() |
||
69 | */ |
||
70 | public function hasItem($key) |
||
74 | |||
75 | /** |
||
76 | * Deletes all items in the pool. |
||
77 | * |
||
78 | * @return boolean TRUE if the pool was successfully cleared. FALSE if there was an error. |
||
79 | * @see \Psr\Cache\CacheItemPoolInterface::clear() |
||
80 | */ |
||
81 | public function clear() |
||
96 | |||
97 | /** |
||
98 | * Persists a cache item immediately. |
||
99 | * |
||
100 | * @param CacheItemInterface $item The cache item to save. |
||
101 | * |
||
102 | * @return boolean TRUE if the item was successfully persisted. FALSE if there was an error. |
||
103 | * @see \Psr\Cache\CacheItemPoolInterface::save() |
||
104 | */ |
||
105 | public function save(CacheItemInterface $item) |
||
110 | |||
111 | /** |
||
112 | * Returns a Cache Item representing the specified key. |
||
113 | * |
||
114 | * This method must always return a CacheItemInterface object, even in case of |
||
115 | * a cache miss. It MUST NOT return null. |
||
116 | * |
||
117 | * @param string $key The key for which to return the corresponding Cache Item. |
||
118 | * |
||
119 | * @return \Psr\Cache\CacheItemInterface The corresponding Cache Item. |
||
120 | * @see \Psr\Cache\CacheItemPoolInterface::getItem() |
||
121 | */ |
||
122 | public function getItem($key) |
||
133 | |||
134 | /** |
||
135 | * Returns a traversable set of cache items. |
||
136 | * |
||
137 | * @param string[] $keys An indexed array of keys of items to retrieve. |
||
138 | * |
||
139 | * @return array|\Traversable A traversable collection of Cache Items keyed by the cache keys of each item. A Cache item will be returned for each key, even if that key is not found. However, if no keys are specified then an empty traversable MUST be returned instead. |
||
140 | * @see \Psr\Cache\CacheItemPoolInterface::getItems() |
||
141 | */ |
||
142 | public function getItems(array $keys = []) |
||
156 | |||
157 | /** |
||
158 | * Removes the item from the pool. |
||
159 | * |
||
160 | * @param string $key The key to delete. |
||
161 | * |
||
162 | * @return boolean TRUE if the item was successfully removed. FALSE if there was an error. |
||
163 | * |
||
164 | * @see \Psr\Cache\CacheItemPoolInterface::deleteItem() |
||
165 | */ |
||
166 | public function deleteItem($key) |
||
171 | |||
172 | /** |
||
173 | * Removes multiple items from the pool. |
||
174 | * |
||
175 | * @param string[] $keys An array of keys that should be removed from the pool. |
||
176 | * |
||
177 | * @return boolean TRUE if the items were successfully removed. False if there was an error. |
||
178 | * @see \Psr\Cache\CacheItemPoolInterface::deleteItems() |
||
179 | */ |
||
180 | public function deleteItems(array $keys) |
||
191 | |||
192 | /** |
||
193 | * Returns new ArrayIterator. |
||
194 | * |
||
195 | * @return \ArrayIterator|\Traversable |
||
196 | */ |
||
197 | public function getIterator() |
||
201 | |||
202 | /** |
||
203 | * Sets a cache item to be persisted later. |
||
204 | * |
||
205 | * @param \Psr\Cache\CacheItemInterface $item The cache item to save. |
||
206 | * |
||
207 | * @return boolean FALSE if the item could not be queued or if a commit was attempted and failed. True otherwise. |
||
208 | * @see \Psr\Cache\CacheItemPoolInterface::saveDeferred() |
||
209 | * @throws \Exception |
||
210 | */ |
||
211 | public function saveDeferred(CacheItemInterface $item) |
||
215 | |||
216 | /** |
||
217 | * Persists any deferred cache items. |
||
218 | * |
||
219 | * @return boolean TRUE if all not-yet-saved items were successfully saved or there were none. FALSE otherwise. |
||
220 | * @see \Psr\Cache\CacheItemPoolInterface::commit() |
||
221 | * @throws \Exception |
||
222 | */ |
||
223 | public function commit() |
||
227 | } |
||
228 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: