@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @param \Psr\Cache\CacheItemInterface $item |
160 | - * @return mixed |
|
160 | + * @return boolean |
|
161 | 161 | * @throws \InvalidArgumentException |
162 | 162 | */ |
163 | 163 | public function save(CacheItemInterface $item) |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * @return mixed|null |
|
178 | + * @return boolean |
|
179 | 179 | * @throws \InvalidArgumentException |
180 | 180 | */ |
181 | 181 | public function commit() |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key))); |
75 | 75 | } |
76 | 76 | |
77 | - return $this->itemInstances[ $key ]; |
|
77 | + return $this->itemInstances[$key]; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function setItem(CacheItemInterface $item) |
86 | 86 | { |
87 | 87 | if ($this->getClassNamespace() . '\\Item' === get_class($item)) { |
88 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
88 | + $this->itemInstances[$item->getKey()] = $item; |
|
89 | 89 | |
90 | 90 | return $this; |
91 | 91 | } else { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $collection = []; |
104 | 104 | foreach ($keys as $key) { |
105 | - $collection[ $key ] = $this->getItem($key); |
|
105 | + $collection[$key] = $this->getItem($key); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | return $collection; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | { |
144 | 144 | if ($this->hasItem($key) && $this->driverDelete($this->getItem($key))) { |
145 | 145 | CacheManager::$WriteHits++; |
146 | - unset($this->itemInstances[ $key ]); |
|
146 | + unset($this->itemInstances[$key]); |
|
147 | 147 | |
148 | 148 | return true; |
149 | 149 | } |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | public function save(CacheItemInterface $item) |
178 | 178 | { |
179 | 179 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
180 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
180 | + $this->itemInstances[$item->getKey()] = $item; |
|
181 | 181 | } |
182 | - if($this->driverWrite($item) && $this->driverWriteTags($item)) |
|
182 | + if ($this->driverWrite($item) && $this->driverWriteTags($item)) |
|
183 | 183 | { |
184 | 184 | CacheManager::$WriteHits++; |
185 | 185 | return true; |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | public function saveDeferred(CacheItemInterface $item) |
196 | 196 | { |
197 | 197 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
198 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
198 | + $this->itemInstances[$item->getKey()] = $item; |
|
199 | 199 | } |
200 | 200 | |
201 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
201 | + return $this->deferredList[$item->getKey()] = $item; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | foreach ($this->deferredList as $key => $item) { |
212 | 212 | $result = $this->save($item); |
213 | 213 | if ($return !== false) { |
214 | - unset($this->deferredList[ $key ]); |
|
214 | + unset($this->deferredList[$key]); |
|
215 | 215 | $return = $result; |
216 | 216 | } |
217 | 217 | } |
@@ -128,7 +128,7 @@ |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * @return bool |
|
131 | + * @return boolean|null |
|
132 | 132 | */ |
133 | 133 | public function driverConnect() |
134 | 134 | { |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
143 | 143 | $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
144 | 144 | $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
145 | - [ |
|
145 | + [ |
|
146 | 146 | 'bucket' => 'default', |
147 | 147 | 'password' => '', |
148 | - ], |
|
148 | + ], |
|
149 | 149 | ]; |
150 | 150 | |
151 | 151 | $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password); |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | { |
210 | 210 | $info = $this->getBucket()->manager()->info(); |
211 | 211 | return (new driverStatistic()) |
212 | - ->setSize($info['basicStats']['diskUsed']) |
|
213 | - ->setRawData($info) |
|
214 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
215 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
212 | + ->setSize($info['basicStats']['diskUsed']) |
|
213 | + ->setRawData($info) |
|
214 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
215 | + ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | \ No newline at end of file |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | |
139 | 139 | |
140 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
140 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
141 | 141 | //$port = isset($server[ 'port' ]) ? $server[ 'port' ] : '11211'; |
142 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
143 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
144 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
142 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
143 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
144 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
145 | 145 | [ |
146 | 146 | 'bucket' => 'default', |
147 | 147 | 'password' => '', |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password); |
152 | 152 | |
153 | 153 | foreach ($buckets as $bucket) { |
154 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
155 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
154 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
155 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function getBucket() |
164 | 164 | { |
165 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
165 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
174 | 174 | { |
175 | 175 | if (!array_key_exists($bucketName, $this->bucketInstances)) { |
176 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
176 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
177 | 177 | } else { |
178 | 178 | throw new \LogicException('A bucket instance with this name already exists.'); |
179 | 179 | } |
@@ -212,6 +212,6 @@ discard block |
||
212 | 212 | ->setSize($info['basicStats']['diskUsed']) |
213 | 213 | ->setRawData($info) |
214 | 214 | ->setData(implode(', ', array_keys($this->itemInstances))) |
215 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
215 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, 1) . "\n For more information see RawData."); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | \ No newline at end of file |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @param \Psr\Cache\CacheItemInterface $item |
56 | - * @return mixed |
|
56 | + * @return boolean |
|
57 | 57 | * @throws \InvalidArgumentException |
58 | 58 | */ |
59 | 59 | public function driverWrite(CacheItemInterface $item) |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | /** |
114 | 114 | * @param \Psr\Cache\CacheItemInterface $item |
115 | - * @return bool |
|
115 | + * @return boolean|null |
|
116 | 116 | * @throws \InvalidArgumentException |
117 | 117 | */ |
118 | 118 | public function driverIsHit(CacheItemInterface $item) |
@@ -140,8 +140,8 @@ |
||
140 | 140 | { |
141 | 141 | $stat = new driverStatistic(); |
142 | 142 | $stat->setInfo('A void info string') |
143 | - ->setSize(1337) |
|
144 | - ->setData('A void data string'); |
|
143 | + ->setSize(1337) |
|
144 | + ->setData('A void data string'); |
|
145 | 145 | |
146 | 146 | return $stat; |
147 | 147 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @param \Psr\Cache\CacheItemInterface $item |
56 | - * @return mixed |
|
56 | + * @return boolean |
|
57 | 57 | * @throws \InvalidArgumentException |
58 | 58 | */ |
59 | 59 | public function driverWrite(CacheItemInterface $item) |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @param $key |
73 | - * @return mixed |
|
73 | + * @return boolean |
|
74 | 74 | */ |
75 | 75 | public function driverRead($key) |
76 | 76 | { |
@@ -140,8 +140,8 @@ |
||
140 | 140 | { |
141 | 141 | $stat = new driverStatistic(); |
142 | 142 | $stat->setInfo('A void info string') |
143 | - ->setSize(1337) |
|
144 | - ->setData('A void data string'); |
|
143 | + ->setSize(1337) |
|
144 | + ->setData('A void data string'); |
|
145 | 145 | |
146 | 146 | return $stat; |
147 | 147 | } |
@@ -14,7 +14,6 @@ |
||
14 | 14 | |
15 | 15 | namespace phpFastCache\Drivers\Files; |
16 | 16 | |
17 | -use phpFastCache\Cache\ExtendedCacheItemInterface; |
|
18 | 17 | use phpFastCache\Core\DriverAbstract; |
19 | 18 | use phpFastCache\Core\PathSeekerTrait; |
20 | 19 | use phpFastCache\Core\StandardPsr6StructureTrait; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @param \Psr\Cache\CacheItemInterface $item |
58 | - * @return mixed |
|
58 | + * @return boolean|null |
|
59 | 59 | * @throws \InvalidArgumentException |
60 | 60 | */ |
61 | 61 | public function driverWrite(CacheItemInterface $item) |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | /** |
212 | 212 | * @param string $optionName |
213 | 213 | * @param mixed $optionValue |
214 | - * @return bool |
|
214 | + * @return boolean|null |
|
215 | 215 | * @throws \InvalidArgumentException |
216 | 216 | */ |
217 | 217 | public static function isValidOption($optionName, $optionValue) |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | } |
241 | 241 | /** |
242 | - * @return array |
|
242 | + * @return string[] |
|
243 | 243 | */ |
244 | 244 | public static function getValidOptions() |
245 | 245 | { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
250 | - * @return array |
|
250 | + * @return string[] |
|
251 | 251 | */ |
252 | 252 | public static function getRequiredOptions() |
253 | 253 | { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /* |
77 | 77 | * Skip if Existing Caching in Options |
78 | 78 | */ |
79 | - if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true && file_exists($file_path)) { |
|
79 | + if (isset($option['skipExisting']) && $option['skipExisting'] == true && file_exists($file_path)) { |
|
80 | 80 | $content = $this->readfile($file_path); |
81 | 81 | $old = $this->decode($content); |
82 | 82 | $toWrite = false; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | public static function isValidOption($optionName, $optionValue) |
223 | 223 | { |
224 | 224 | parent::isValidOption($optionName, $optionValue); |
225 | - switch($optionName) |
|
225 | + switch ($optionName) |
|
226 | 226 | { |
227 | 227 | case 'path': |
228 | 228 | return is_string($optionValue); |
@@ -254,9 +254,9 @@ |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | $stat->setData(implode(', ', array_keys($this->itemInstances))) |
257 | - ->setRawData([]) |
|
258 | - ->setSize(Directory::dirSize($path)) |
|
259 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
257 | + ->setRawData([]) |
|
258 | + ->setSize(Directory::dirSize($path)) |
|
259 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
260 | 260 | |
261 | 261 | return $stat; |
262 | 262 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * @return bool |
|
131 | + * @return boolean|null |
|
132 | 132 | */ |
133 | 133 | public function driverConnect() |
134 | 134 | { |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
297 | - * @return mixed|null |
|
297 | + * @return boolean |
|
298 | 298 | * @throws \InvalidArgumentException |
299 | 299 | */ |
300 | 300 | public function commit() |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
136 | 136 | if (count($servers) < 1) { |
137 | 137 | $servers = [ |
138 | - ['127.0.0.1', 11211], |
|
138 | + ['127.0.0.1', 11211], |
|
139 | 139 | ]; |
140 | 140 | } |
141 | 141 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | } else { |
188 | 188 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', |
189 | - gettype($key))); |
|
189 | + gettype($key))); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | return $this->itemInstances[ $key ]; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | return $this; |
206 | 206 | } else { |
207 | 207 | throw new \InvalidArgumentException(sprintf('Invalid Item Class "%s" for this driver.', |
208 | - get_class($item))); |
|
208 | + get_class($item))); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function driverConnect() |
134 | 134 | { |
135 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
135 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
136 | 136 | if (count($servers) < 1) { |
137 | 137 | $servers = [ |
138 | 138 | ['127.0.0.1', 11211], |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | foreach ($servers as $server) { |
143 | 143 | try { |
144 | - if (!$this->instance->addServer($server[ 0 ], $server[ 1 ])) { |
|
144 | + if (!$this->instance->addServer($server[0], $server[1])) { |
|
145 | 145 | $this->fallback = true; |
146 | 146 | } |
147 | 147 | } catch (\Exception $e) { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | gettype($key))); |
190 | 190 | } |
191 | 191 | |
192 | - return $this->itemInstances[ $key ]; |
|
192 | + return $this->itemInstances[$key]; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | public function setItem(CacheItemInterface $item) |
201 | 201 | { |
202 | 202 | if (__NAMESPACE__ . '\\Item' === get_class($item)) { |
203 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
203 | + $this->itemInstances[$item->getKey()] = $item; |
|
204 | 204 | |
205 | 205 | return $this; |
206 | 206 | } else { |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | { |
219 | 219 | $collection = []; |
220 | 220 | foreach ($keys as $key) { |
221 | - $collection[ $key ] = $this->getItem($key); |
|
221 | + $collection[$key] = $this->getItem($key); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | return $collection; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | */ |
291 | 291 | public function saveDeferred(CacheItemInterface $item) |
292 | 292 | { |
293 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
293 | + return $this->deferredList[$item->getKey()] = $item; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | foreach ($this->deferredList as $key => $item) { |
304 | 304 | $result = $this->driverWrite($item); |
305 | 305 | if ($return !== false) { |
306 | - unset($this->deferredList[ $key ]); |
|
306 | + unset($this->deferredList[$key]); |
|
307 | 307 | $return = $result; |
308 | 308 | } |
309 | 309 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @param \Psr\Cache\CacheItemInterface $item |
70 | - * @return mixed |
|
70 | + * @return boolean |
|
71 | 71 | * @throws \InvalidArgumentException |
72 | 72 | */ |
73 | 73 | public function driverWrite(CacheItemInterface $item) |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | - * @return bool |
|
145 | + * @return boolean|null |
|
146 | 146 | * @throws MongoConnectionException |
147 | 147 | * @throws LogicException |
148 | 148 | */ |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | /** |
183 | 183 | * @param \Psr\Cache\CacheItemInterface $item |
184 | - * @return bool |
|
184 | + * @return boolean|null |
|
185 | 185 | * @throws \InvalidArgumentException |
186 | 186 | */ |
187 | 187 | public function driverIsHit(CacheItemInterface $item) |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | if ($item instanceof Item) { |
79 | 79 | try { |
80 | 80 | $result = (array) $this->getCollection()->update( |
81 | - ['_id' => $item->getKey()], |
|
82 | - [ |
|
81 | + ['_id' => $item->getKey()], |
|
82 | + [ |
|
83 | 83 | '$set' => [ |
84 | - self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : new MongoDate(time())), |
|
85 | - self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
86 | - self::DRIVER_TAGS_WRAPPER_INDEX => new MongoBinData($this->encode($item->getTags()), MongoBinData::BYTE_ARRAY), |
|
84 | + self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : new MongoDate(time())), |
|
85 | + self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
86 | + self::DRIVER_TAGS_WRAPPER_INDEX => new MongoBinData($this->encode($item->getTags()), MongoBinData::BYTE_ARRAY), |
|
87 | 87 | ], |
88 | - ], |
|
89 | - ['upsert' => true, 'multiple' => false] |
|
88 | + ], |
|
89 | + ['upsert' => true, 'multiple' => false] |
|
90 | 90 | ); |
91 | 91 | } catch (MongoCursorException $e) { |
92 | 92 | return false; |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | |
109 | 109 | if ($document) { |
110 | 110 | return [ |
111 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
112 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
113 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
111 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
112 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
113 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
114 | 114 | ]; |
115 | 115 | } else { |
116 | 116 | return null; |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | * @todo make an url builder |
166 | 166 | */ |
167 | 167 | $this->instance = $this->instance ?: (new MongodbClient('mongodb://' . |
168 | - ($username ?: '') . |
|
169 | - ($password ? ":{$password}" : '') . |
|
170 | - ($username ? '@' : '') . "{$host}" . |
|
171 | - ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]))->phpFastCache; |
|
168 | + ($username ?: '') . |
|
169 | + ($password ? ":{$password}" : '') . |
|
170 | + ($username ? '@' : '') . "{$host}" . |
|
171 | + ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]))->phpFastCache; |
|
172 | 172 | // $this->instance->Cache->createIndex([self::DRIVER_TIME_WRAPPER_INDEX => 1], ['expireAfterSeconds' => 0]); |
173 | 173 | } |
174 | 174 | } |
@@ -209,25 +209,25 @@ discard block |
||
209 | 209 | public function getStats() |
210 | 210 | { |
211 | 211 | $serverStatus = $this->getCollection()->db->command([ |
212 | - 'serverStatus' => 1, |
|
213 | - 'recordStats' => 0, |
|
214 | - 'repl' => 0, |
|
215 | - 'metrics' => 0, |
|
212 | + 'serverStatus' => 1, |
|
213 | + 'recordStats' => 0, |
|
214 | + 'repl' => 0, |
|
215 | + 'metrics' => 0, |
|
216 | 216 | ]); |
217 | 217 | |
218 | 218 | $collStats = $this->getCollection()->db->command([ |
219 | - 'collStats' => 'Cache', |
|
220 | - 'verbose' => true, |
|
219 | + 'collStats' => 'Cache', |
|
220 | + 'verbose' => true, |
|
221 | 221 | ]); |
222 | 222 | |
223 | 223 | $stats = (new driverStatistic()) |
224 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
225 | - ->setSize((int) $collStats[ 'size' ]) |
|
226 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
227 | - ->setRawData([ |
|
224 | + ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
225 | + ->setSize((int) $collStats[ 'size' ]) |
|
226 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
227 | + ->setRawData([ |
|
228 | 228 | 'serverStatus' => $serverStatus, |
229 | 229 | 'collStats' => $collStats, |
230 | - ]); |
|
230 | + ]); |
|
231 | 231 | |
232 | 232 | return $stats; |
233 | 233 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | |
95 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
95 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
96 | 96 | } else { |
97 | 97 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
98 | 98 | } |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | |
109 | 109 | if ($document) { |
110 | 110 | return [ |
111 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
112 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
113 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
111 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->bin), |
|
112 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_TIME_WRAPPER_INDEX]->sec), |
|
113 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->bin), |
|
114 | 114 | ]; |
115 | 115 | } else { |
116 | 116 | return null; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | if ($item instanceof Item) { |
131 | 131 | $deletionResult = (array) $this->getCollection()->remove(['_id' => $item->getKey()], ["w" => 1]); |
132 | 132 | |
133 | - return (int) $deletionResult[ 'ok' ] === 1 && !$deletionResult[ 'err' ]; |
|
133 | + return (int) $deletionResult['ok'] === 1 && !$deletionResult['err']; |
|
134 | 134 | } else { |
135 | 135 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
136 | 136 | } |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | if ($this->instance instanceof MongodbClient) { |
155 | 155 | throw new LogicException('Already connected to Mongodb server'); |
156 | 156 | } else { |
157 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
158 | - $port = isset($server[ 'port' ]) ? $server[ 'port' ] : '27017'; |
|
159 | - $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : 3; |
|
160 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
161 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
157 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
158 | + $port = isset($server['port']) ? $server['port'] : '27017'; |
|
159 | + $timeout = isset($server['timeout']) ? $server['timeout'] : 3; |
|
160 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
161 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
162 | 162 | |
163 | 163 | |
164 | 164 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | { |
192 | 192 | $document = $this->getCollection()->findOne(['_id' => $item->getKey()], [self::DRIVER_TIME_WRAPPER_INDEX /*'d', 'e'*/]); |
193 | 193 | if ($document) { |
194 | - return $document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec >= time(); |
|
194 | + return $document[self::DRIVER_TIME_WRAPPER_INDEX]->sec >= time(); |
|
195 | 195 | } else { |
196 | 196 | return null; |
197 | 197 | } |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | ]); |
222 | 222 | |
223 | 223 | $stats = (new driverStatistic()) |
224 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
225 | - ->setSize((int) $collStats[ 'size' ]) |
|
224 | + ->setInfo('MongoDB version ' . $serverStatus['version'] . ', Uptime (in days): ' . round($serverStatus['uptime'] / 86400, 1) . "\n For more information see RawData.") |
|
225 | + ->setSize((int) $collStats['size']) |
|
226 | 226 | ->setData(implode(', ', array_keys($this->itemInstances))) |
227 | 227 | ->setRawData([ |
228 | 228 | 'serverStatus' => $serverStatus, |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
214 | - * @param $keyword |
|
214 | + * @param string $keyword |
|
215 | 215 | * @param bool $reset |
216 | 216 | * @return PDO |
217 | 217 | */ |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | /** |
250 | 250 | * @param \Psr\Cache\CacheItemInterface $item |
251 | - * @return mixed |
|
251 | + * @return boolean |
|
252 | 252 | * @throws \InvalidArgumentException |
253 | 253 | */ |
254 | 254 | public function driverWrite(CacheItemInterface $item) |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
402 | - * @return bool |
|
402 | + * @return boolean|null |
|
403 | 403 | */ |
404 | 404 | public function driverConnect() |
405 | 405 | { |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`"); |
167 | 167 | $stm->execute(); |
168 | 168 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
169 | - if (!isset($row[ 'db' ])) { |
|
169 | + if (!isset($row['db'])) { |
|
170 | 170 | $db = 1; |
171 | - } elseif ($row[ 'db' ] <= 1) { |
|
171 | + } elseif ($row['db'] <= 1) { |
|
172 | 172 | $db = 1; |
173 | 173 | } else { |
174 | - $db = $row[ 'db' ]; |
|
174 | + $db = $row['db']; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | // check file size |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | ':keyword' => $keyword, |
194 | 194 | ]); |
195 | 195 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
196 | - if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
|
197 | - $db = $row[ 'db' ]; |
|
196 | + if (isset($row['db']) && $row['db'] != '') { |
|
197 | + $db = $row['db']; |
|
198 | 198 | } else { |
199 | 199 | /* |
200 | 200 | * Insert new to Indexing |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | /** |
226 | 226 | * init instant |
227 | 227 | */ |
228 | - if (!isset($this->instance[ $instant ])) { |
|
228 | + if (!isset($this->instance[$instant])) { |
|
229 | 229 | // check DB Files ready or not |
230 | 230 | $createTable = false; |
231 | 231 | if (!file_exists($this->SqliteDir . '/db' . $instant) || $reset == true) { |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | $this->initDB($PDO); |
239 | 239 | } |
240 | 240 | |
241 | - $this->instance[ $instant ] = $PDO; |
|
241 | + $this->instance[$instant] = $PDO; |
|
242 | 242 | unset($PDO); |
243 | 243 | |
244 | 244 | } |
245 | 245 | |
246 | - return $this->instance[ $instant ]; |
|
246 | + return $this->instance[$instant]; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * Check for Cross-Driver type confusion |
258 | 258 | */ |
259 | 259 | if ($item instanceof Item) { |
260 | - $skipExisting = isset($this->config[ 'skipExisting' ]) ? $this->config[ 'skipExisting' ] : false; |
|
260 | + $skipExisting = isset($this->config['skipExisting']) ? $this->config['skipExisting'] : false; |
|
261 | 261 | $toWrite = true; |
262 | 262 | |
263 | 263 | // check in cache first |
@@ -333,18 +333,18 @@ discard block |
||
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | - if (isset($row[ 'id' ])) { |
|
336 | + if (isset($row['id'])) { |
|
337 | 337 | /** |
338 | 338 | * @var $item ExtendedCacheItemInterface |
339 | 339 | */ |
340 | - $item = $this->decode($row[ 'object' ]); |
|
340 | + $item = $this->decode($row['object']); |
|
341 | 341 | if ($item instanceof ExtendedCacheItemInterface && $item->isExpired()) { |
342 | 342 | $this->driverDelete($item); |
343 | 343 | |
344 | 344 | return null; |
345 | 345 | } |
346 | 346 | |
347 | - return $this->decode($row[ 'object' ]); |
|
347 | + return $this->decode($row['object']); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | return null; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | ':U' => time(), |
435 | 435 | ]); |
436 | 436 | $data = $stm->fetch(PDO::FETCH_ASSOC); |
437 | - if ($data[ 'total' ] >= 1) { |
|
437 | + if ($data['total'] >= 1) { |
|
438 | 438 | return true; |
439 | 439 | } else { |
440 | 440 | return false; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE); |
153 | 153 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
154 | - PDO::ERRMODE_EXCEPTION); |
|
154 | + PDO::ERRMODE_EXCEPTION); |
|
155 | 155 | |
156 | 156 | if ($createTable == true) { |
157 | 157 | $this->initIndexing($PDO); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | // look for keyword |
187 | 187 | $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); |
188 | 188 | $stm->execute([ |
189 | - ':keyword' => $keyword, |
|
189 | + ':keyword' => $keyword, |
|
190 | 190 | ]); |
191 | 191 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
192 | 192 | if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | $db = $this->currentDB; |
199 | 199 | $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); |
200 | 200 | $stm->execute([ |
201 | - ':keyword' => $keyword, |
|
202 | - ':db' => $db, |
|
201 | + ':keyword' => $keyword, |
|
202 | + ':db' => $db, |
|
203 | 203 | ]); |
204 | 204 | } |
205 | 205 | |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | if ($toWrite == true) { |
271 | 271 | try { |
272 | 272 | $stm = $this->getDb($item->getKey()) |
273 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
273 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
274 | 274 | $stm->execute([ |
275 | - ':keyword' => $item->getKey(), |
|
276 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
277 | - ':exp' => time() + $item->getTtl(), |
|
275 | + ':keyword' => $item->getKey(), |
|
276 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
277 | + ':exp' => time() + $item->getTtl(), |
|
278 | 278 | ]); |
279 | 279 | |
280 | 280 | return true; |
@@ -282,11 +282,11 @@ discard block |
||
282 | 282 | |
283 | 283 | try { |
284 | 284 | $stm = $this->getDb($item->getKey(), true) |
285 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
285 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
286 | 286 | $stm->execute([ |
287 | - ':keyword' => $item->getKey(), |
|
288 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
289 | - ':exp' => time() + $item->getTtl(), |
|
287 | + ':keyword' => $item->getKey(), |
|
288 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
289 | + ':exp' => time() + $item->getTtl(), |
|
290 | 290 | ]); |
291 | 291 | } catch (PDOException $e) { |
292 | 292 | return false; |
@@ -308,20 +308,20 @@ discard block |
||
308 | 308 | { |
309 | 309 | try { |
310 | 310 | $stm = $this->getDb($key) |
311 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
311 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
312 | 312 | $stm->execute([ |
313 | - ':keyword' => $key, |
|
314 | - ':U' => time(), |
|
313 | + ':keyword' => $key, |
|
314 | + ':U' => time(), |
|
315 | 315 | ]); |
316 | 316 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
317 | 317 | |
318 | 318 | } catch (PDOException $e) { |
319 | 319 | try { |
320 | 320 | $stm = $this->getDb($key, true) |
321 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
321 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
322 | 322 | $stm->execute([ |
323 | - ':keyword' => $key, |
|
324 | - ':U' => time(), |
|
323 | + ':keyword' => $key, |
|
324 | + ':U' => time(), |
|
325 | 325 | ]); |
326 | 326 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
327 | 327 | } catch (PDOException $e) { |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | if ($item instanceof Item) { |
360 | 360 | try { |
361 | 361 | $stm = $this->getDb($item->getKey()) |
362 | - //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
363 | - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
362 | + //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
363 | + ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
364 | 364 | |
365 | 365 | return $stm->execute([ |
366 | 366 | // ':id' => $row[ 'id' ], |
367 | - ':keyword' => $item->getKey(), |
|
368 | - ':U' => time(), |
|
367 | + ':keyword' => $item->getKey(), |
|
368 | + ':U' => time(), |
|
369 | 369 | ]); |
370 | 370 | } catch (PDOException $e) { |
371 | 371 | return false; |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | * @todo: Check expiration time here |
424 | 424 | */ |
425 | 425 | $stm = $this->getDb($item->getKey()) |
426 | - ->prepare("SELECT COUNT(`id`) as `total` FROM `caching` WHERE (`keyword`=:keyword) AND (`exp` <= :U) "); |
|
426 | + ->prepare("SELECT COUNT(`id`) as `total` FROM `caching` WHERE (`keyword`=:keyword) AND (`exp` <= :U) "); |
|
427 | 427 | $stm->execute([ |
428 | - ':keyword' => $item->getKey(), |
|
429 | - ':U' => time(), |
|
428 | + ':keyword' => $item->getKey(), |
|
429 | + ':U' => time(), |
|
430 | 430 | ]); |
431 | 431 | $data = $stm->fetch(PDO::FETCH_ASSOC); |
432 | 432 | if ($data[ 'total' ] >= 1) { |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | } |
460 | 460 | |
461 | 461 | $stat->setData(implode(', ', array_keys($this->itemInstances))) |
462 | - ->setRawData([]) |
|
463 | - ->setSize(Directory::dirSize($path)) |
|
464 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
462 | + ->setRawData([]) |
|
463 | + ->setSize(Directory::dirSize($path)) |
|
464 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
465 | 465 | |
466 | 466 | return $stat; |
467 | 467 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | return; |
28 | 28 | } else if (strpos($entity, 'Psr\Cache') === 0) { |
29 | 29 | trigger_error('If you cannot use <b>composer</b>, you have to include manually the Psr\\Cache interfaces.<br />See: https://github.com/php-fig/cache/tree/master/src<br /> Called ' . $entity, |
30 | - E_USER_ERROR); |
|
30 | + E_USER_ERROR); |
|
31 | 31 | |
32 | 32 | return; |
33 | 33 | } |
@@ -42,5 +42,5 @@ discard block |
||
42 | 42 | |
43 | 43 | if (class_exists('Composer\Autoload\ClassLoader')) { |
44 | 44 | trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
45 | - E_USER_WARNING); |
|
45 | + E_USER_WARNING); |
|
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -17,9 +17,9 @@ |
||
17 | 17 | /** |
18 | 18 | * Register Autoload |
19 | 19 | */ |
20 | -spl_autoload_register(function ($entity) { |
|
20 | +spl_autoload_register(function($entity) { |
|
21 | 21 | $module = explode('\\', $entity, 2); |
22 | - if (!in_array($module[ 0 ], ['phpFastCache', 'Psr'])) { |
|
22 | + if (!in_array($module[0], ['phpFastCache', 'Psr'])) { |
|
23 | 23 | /** |
24 | 24 | * Not a part of phpFastCache file |
25 | 25 | * then we return here. |