@@ -83,8 +83,8 @@ |
||
83 | 83 | |
84 | 84 | $files = new RecursiveIteratorIterator |
85 | 85 | ( |
86 | - new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
|
87 | - RecursiveIteratorIterator::CHILD_FIRST |
|
86 | + new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
|
87 | + RecursiveIteratorIterator::CHILD_FIRST |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | foreach ($files as $fileinfo) { |
@@ -85,8 +85,7 @@ discard block |
||
85 | 85 | return unlink($source); |
86 | 86 | } |
87 | 87 | |
88 | - $files = new RecursiveIteratorIterator |
|
89 | - ( |
|
88 | + $files = new RecursiveIteratorIterator( |
|
90 | 89 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
91 | 90 | RecursiveIteratorIterator::CHILD_FIRST |
92 | 91 | ); |
@@ -136,7 +135,7 @@ discard block |
||
136 | 135 | /** |
137 | 136 | * Allows to dereference char |
138 | 137 | */ |
139 | - $__FILE__ = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc. |
|
138 | + $__FILE__ = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__); // remove file protocols such as "phar://" etc. |
|
140 | 139 | $prefix = $__FILE__[0] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : ''; |
141 | 140 | return $prefix . implode(DIRECTORY_SEPARATOR, $absolutes); |
142 | 141 | } |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | { |
140 | 140 | try { |
141 | 141 | $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
142 | - 'host' => "127.0.0.1", |
|
143 | - 'port' => 8888, |
|
144 | - 'password' => '', |
|
145 | - 'timeout' => 2000, |
|
142 | + 'host' => "127.0.0.1", |
|
143 | + 'port' => 8888, |
|
144 | + 'password' => '', |
|
145 | + 'timeout' => 2000, |
|
146 | 146 | ]; |
147 | 147 | |
148 | 148 | $host = $server[ 'host' ]; |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * using hardcoded offset of pair key-value :-( |
184 | 184 | */ |
185 | 185 | $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ])) |
186 | - ->setRawData($info) |
|
187 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
188 | - ->setSize($this->instance->dbsize()); |
|
186 | + ->setRawData($info) |
|
187 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
188 | + ->setSize($this->instance->dbsize()); |
|
189 | 189 | |
190 | 190 | return $stat; |
191 | 191 | } |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | protected function driverConnect() |
139 | 139 | { |
140 | 140 | try { |
141 | - $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
|
141 | + $server = isset($this->config['ssdb']) ? $this->config['ssdb'] : [ |
|
142 | 142 | 'host' => "127.0.0.1", |
143 | 143 | 'port' => 8888, |
144 | 144 | 'password' => '', |
145 | 145 | 'timeout' => 2000, |
146 | 146 | ]; |
147 | 147 | |
148 | - $host = $server[ 'host' ]; |
|
149 | - $port = isset($server[ 'port' ]) ? (int) $server[ 'port' ] : 8888; |
|
150 | - $password = isset($server[ 'password' ]) ? $server[ 'password' ] : ''; |
|
151 | - $timeout = !empty($server[ 'timeout' ]) ? (int) $server[ 'timeout' ] : 2000; |
|
148 | + $host = $server['host']; |
|
149 | + $port = isset($server['port']) ? (int) $server['port'] : 8888; |
|
150 | + $password = isset($server['password']) ? $server['password'] : ''; |
|
151 | + $timeout = !empty($server['timeout']) ? (int) $server['timeout'] : 2000; |
|
152 | 152 | $this->instance = new SimpleSSDB($host, $port, $timeout); |
153 | 153 | if (!empty($password)) { |
154 | 154 | $this->instance->auth($password); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * Data returned by Ssdb are very poorly formatted |
183 | 183 | * using hardcoded offset of pair key-value :-( |
184 | 184 | */ |
185 | - $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ])) |
|
185 | + $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[2], $info[6])) |
|
186 | 186 | ->setRawData($info) |
187 | 187 | ->setData(implode(', ', array_keys($this->itemInstances))) |
188 | 188 | ->setSize($this->instance->dbsize()); |
@@ -74,9 +74,9 @@ |
||
74 | 74 | */ |
75 | 75 | public function __call($name, $args) |
76 | 76 | { |
77 | - if(method_exists($this->instance, $name)){ |
|
77 | + if (method_exists($this->instance, $name)) { |
|
78 | 78 | return call_user_func_array([$this->instance, $name], $args); |
79 | - }else{ |
|
79 | + } else { |
|
80 | 80 | throw new \BadMethodCallException(sprintf('Method %s does not exists', $name)); |
81 | 81 | } |
82 | 82 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | { |
77 | 77 | if(method_exists($this->instance, $name)){ |
78 | 78 | return call_user_func_array([$this->instance, $name], $args); |
79 | - }else{ |
|
79 | + } else{ |
|
80 | 80 | throw new \BadMethodCallException(sprintf('Method %s does not exists', $name)); |
81 | 81 | } |
82 | 82 | } |
@@ -159,9 +159,9 @@ |
||
159 | 159 | public function driverPreWrap(ExtendedCacheItemInterface $item) |
160 | 160 | { |
161 | 161 | $wrap = [ |
162 | - self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
163 | - self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
164 | - self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
162 | + self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
163 | + self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
164 | + self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
165 | 165 | ]; |
166 | 166 | |
167 | 167 | if($this->config['itemDetailedDate']){ |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | { |
73 | 73 | if(isset($this->config[$optionName])){ |
74 | 74 | return $this->config[$optionName]; |
75 | - }else{ |
|
75 | + } else{ |
|
76 | 76 | return null; |
77 | 77 | } |
78 | 78 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * reuse it else set a new Date |
150 | 150 | */ |
151 | 151 | $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
152 | - }else{ |
|
152 | + } else{ |
|
153 | 153 | $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
154 | 154 | $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
155 | 155 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if (is_array($config_name)) { |
54 | 54 | $this->config = array_merge($this->config, $config_name); |
55 | 55 | } else { |
56 | - $this->config[ $config_name ] = $value; |
|
56 | + $this->config[$config_name] = $value; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getConfigOption($optionName) |
73 | 73 | { |
74 | - if(isset($this->config[$optionName])){ |
|
74 | + if (isset($this->config[$optionName])) { |
|
75 | 75 | return $this->config[$optionName]; |
76 | - }else{ |
|
76 | + } else { |
|
77 | 77 | return null; |
78 | 78 | } |
79 | 79 | } |
@@ -143,16 +143,16 @@ discard block |
||
143 | 143 | self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
144 | 144 | ]; |
145 | 145 | |
146 | - if($this->config['itemDetailedDate']){ |
|
147 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = new \DateTime(); |
|
146 | + if ($this->config['itemDetailedDate']) { |
|
147 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = new \DateTime(); |
|
148 | 148 | /** |
149 | 149 | * If the creation date exists |
150 | 150 | * reuse it else set a new Date |
151 | 151 | */ |
152 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
|
153 | - }else{ |
|
154 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
|
155 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
|
152 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate() ?: new \DateTime(); |
|
153 | + } else { |
|
154 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = null; |
|
155 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = null; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | return $wrap; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function driverUnwrapData(array $wrapper) |
166 | 166 | { |
167 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
167 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function driverUnwrapTags(array $wrapper) |
175 | 175 | { |
176 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
176 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function driverUnwrapEdate(array $wrapper) |
185 | 185 | { |
186 | - return $wrapper[ self::DRIVER_EDATE_WRAPPER_INDEX ]; |
|
186 | + return $wrapper[self::DRIVER_EDATE_WRAPPER_INDEX]; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function driverUnwrapCdate(array $wrapper) |
194 | 194 | { |
195 | - return $wrapper[ self::DRIVER_CDATE_WRAPPER_INDEX ]; |
|
195 | + return $wrapper[self::DRIVER_CDATE_WRAPPER_INDEX]; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function driverUnwrapMdate(array $wrapper) |
204 | 204 | { |
205 | - return $wrapper[ self::DRIVER_MDATE_WRAPPER_INDEX ]; |
|
205 | + return $wrapper[self::DRIVER_MDATE_WRAPPER_INDEX]; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * on tags item, it can leads |
228 | 228 | * to an infinite recursive calls |
229 | 229 | */ |
230 | - if(strpos($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX ) === 0){ |
|
230 | + if (strpos($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX) === 0) { |
|
231 | 231 | throw new phpFastCacheLogicException('Trying to set tag(s) to an Tag item index: ' . $item->getKey()); |
232 | 232 | } |
233 | 233 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | foreach ($tagsItems as $tagsItem) { |
271 | 271 | $data = (array) $tagsItem->get(); |
272 | 272 | |
273 | - unset($data[ $item->getKey() ]); |
|
273 | + unset($data[$item->getKey()]); |
|
274 | 274 | $tagsItem->set($data); |
275 | 275 | |
276 | 276 | /** |
@@ -27,7 +27,7 @@ |
||
27 | 27 | return true; |
28 | 28 | } else if (constant($CONSTANT_NAME) !== $driverName) { |
29 | 29 | trigger_error('Memcache collision detected, you used both Memcache and Memcached driver in your script, this may leads to unexpected behaviours', |
30 | - E_USER_WARNING); |
|
30 | + E_USER_WARNING); |
|
31 | 31 | |
32 | 32 | return false; |
33 | 33 | } |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`"); |
163 | 163 | $stm->execute(); |
164 | 164 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
165 | - if (!isset($row[ 'db' ])) { |
|
165 | + if (!isset($row['db'])) { |
|
166 | 166 | $db = 1; |
167 | - } elseif ($row[ 'db' ] <= 1) { |
|
167 | + } elseif ($row['db'] <= 1) { |
|
168 | 168 | $db = 1; |
169 | 169 | } else { |
170 | - $db = $row[ 'db' ]; |
|
170 | + $db = $row['db']; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // check file size |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | ':keyword' => $keyword, |
190 | 190 | ]); |
191 | 191 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
192 | - if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
|
193 | - $db = $row[ 'db' ]; |
|
192 | + if (isset($row['db']) && $row['db'] != '') { |
|
193 | + $db = $row['db']; |
|
194 | 194 | } else { |
195 | 195 | /* |
196 | 196 | * Insert new to Indexing |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | /** |
222 | 222 | * init instant |
223 | 223 | */ |
224 | - if (!isset($this->instance[ $instant ])) { |
|
224 | + if (!isset($this->instance[$instant])) { |
|
225 | 225 | // check DB Files ready or not |
226 | 226 | $createTable = false; |
227 | 227 | if (!file_exists($this->SqliteDir . '/db' . $instant) || $reset == true) { |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | $this->initDB($PDO); |
235 | 235 | } |
236 | 236 | |
237 | - $this->instance[ $instant ] = $PDO; |
|
237 | + $this->instance[$instant] = $PDO; |
|
238 | 238 | unset($PDO); |
239 | 239 | |
240 | 240 | } |
241 | 241 | |
242 | - return $this->instance[ $instant ]; |
|
242 | + return $this->instance[$instant]; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * Check for Cross-Driver type confusion |
254 | 254 | */ |
255 | 255 | if ($item instanceof Item) { |
256 | - $skipExisting = isset($this->config[ 'skipExisting' ]) ? $this->config[ 'skipExisting' ] : false; |
|
256 | + $skipExisting = isset($this->config['skipExisting']) ? $this->config['skipExisting'] : false; |
|
257 | 257 | $toWrite = true; |
258 | 258 | |
259 | 259 | // check in cache first |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - if (isset($row[ 'object' ])) { |
|
333 | - return $this->decode($row[ 'object' ]); |
|
332 | + if (isset($row['object'])) { |
|
333 | + return $this->decode($row['object']); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | return null; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE); |
155 | 155 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
156 | - PDO::ERRMODE_EXCEPTION); |
|
156 | + PDO::ERRMODE_EXCEPTION); |
|
157 | 157 | |
158 | 158 | if ($createTable == true) { |
159 | 159 | $this->initIndexing($PDO); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | // look for keyword |
189 | 189 | $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); |
190 | 190 | $stm->execute([ |
191 | - ':keyword' => $keyword, |
|
191 | + ':keyword' => $keyword, |
|
192 | 192 | ]); |
193 | 193 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
194 | 194 | if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | $db = $this->currentDB; |
201 | 201 | $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); |
202 | 202 | $stm->execute([ |
203 | - ':keyword' => $keyword, |
|
204 | - ':db' => $db, |
|
203 | + ':keyword' => $keyword, |
|
204 | + ':db' => $db, |
|
205 | 205 | ]); |
206 | 206 | } |
207 | 207 | |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | if ($toWrite == true) { |
273 | 273 | try { |
274 | 274 | $stm = $this->getDb($item->getKey()) |
275 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
275 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
276 | 276 | $stm->execute([ |
277 | - ':keyword' => $item->getKey(), |
|
278 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
279 | - ':exp' => time() + $item->getTtl(), |
|
277 | + ':keyword' => $item->getKey(), |
|
278 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
279 | + ':exp' => time() + $item->getTtl(), |
|
280 | 280 | ]); |
281 | 281 | |
282 | 282 | return true; |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | |
285 | 285 | try { |
286 | 286 | $stm = $this->getDb($item->getKey(), true) |
287 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
287 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
288 | 288 | $stm->execute([ |
289 | - ':keyword' => $item->getKey(), |
|
290 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
291 | - ':exp' => time() + $item->getTtl(), |
|
289 | + ':keyword' => $item->getKey(), |
|
290 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
291 | + ':exp' => time() + $item->getTtl(), |
|
292 | 292 | ]); |
293 | 293 | } catch (PDOException $e) { |
294 | 294 | return false; |
@@ -310,20 +310,20 @@ discard block |
||
310 | 310 | { |
311 | 311 | try { |
312 | 312 | $stm = $this->getDb($item->getKey()) |
313 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
313 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
314 | 314 | $stm->execute([ |
315 | - ':keyword' => $item->getKey(), |
|
316 | - ':U' => time(), |
|
315 | + ':keyword' => $item->getKey(), |
|
316 | + ':U' => time(), |
|
317 | 317 | ]); |
318 | 318 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
319 | 319 | |
320 | 320 | } catch (PDOException $e) { |
321 | 321 | try { |
322 | 322 | $stm = $this->getDb($item->getKey(), true) |
323 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
323 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
324 | 324 | $stm->execute([ |
325 | - ':keyword' => $item->getKey(), |
|
326 | - ':U' => time(), |
|
325 | + ':keyword' => $item->getKey(), |
|
326 | + ':U' => time(), |
|
327 | 327 | ]); |
328 | 328 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
329 | 329 | } catch (PDOException $e) { |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | if ($item instanceof Item) { |
352 | 352 | try { |
353 | 353 | $stm = $this->getDb($item->getKey()) |
354 | - //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
355 | - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
354 | + //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
355 | + ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
356 | 356 | |
357 | 357 | return $stm->execute([ |
358 | 358 | // ':id' => $row[ 'id' ], |
359 | - ':keyword' => $item->getKey(), |
|
360 | - ':U' => time(), |
|
359 | + ':keyword' => $item->getKey(), |
|
360 | + ':U' => time(), |
|
361 | 361 | ]); |
362 | 362 | } catch (PDOException $e) { |
363 | 363 | return false; |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
209 | - * @param $keyword |
|
209 | + * @param string $keyword |
|
210 | 210 | * @param bool $reset |
211 | 211 | * @return PDO |
212 | 212 | */ |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | /** |
245 | 245 | * @param \Psr\Cache\CacheItemInterface $item |
246 | - * @return mixed |
|
246 | + * @return boolean |
|
247 | 247 | * @throws phpFastCacheInvalidArgumentException |
248 | 248 | */ |
249 | 249 | protected function driverWrite(CacheItemInterface $item) |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct() |
23 | 23 | { |
24 | - $this->instances =& CacheManager::getInternalInstances(); |
|
24 | + $this->instances = & CacheManager::getInternalInstances(); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | */ |
30 | 30 | protected function getGenericCallback() |
31 | 31 | { |
32 | - return function($method, $args){ |
|
32 | + return function($method, $args) { |
|
33 | 33 | $getterMethod = (strpos($method, 'get') === 0); |
34 | 34 | $return = false; |
35 | 35 | |
36 | - if($getterMethod){ |
|
36 | + if ($getterMethod) { |
|
37 | 37 | $return = []; |
38 | 38 | } |
39 | 39 | |
40 | 40 | foreach ($this->instances as $instance) |
41 | 41 | { |
42 | 42 | $reflectionMethod = new \ReflectionMethod(get_class($instance), $method); |
43 | - if($getterMethod){ |
|
44 | - $return[ $instance->getDriverName() ] = $reflectionMethod->invokeArgs($instance, $args); |
|
45 | - }else{ |
|
43 | + if ($getterMethod) { |
|
44 | + $return[$instance->getDriverName()] = $reflectionMethod->invokeArgs($instance, $args); |
|
45 | + } else { |
|
46 | 46 | $result = $reflectionMethod->invokeArgs($instance, $args); |
47 | - if($result !== false){ |
|
47 | + if ($result !== false) { |
|
48 | 48 | $return = $result; |
49 | 49 | } |
50 | 50 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | $reflectionMethod = new \ReflectionMethod(get_class($instance), $method); |
57 | 57 | if($getterMethod){ |
58 | 58 | $return[ $instance->getDriverName() ] = $reflectionMethod->invokeArgs($instance, $args); |
59 | - }else{ |
|
59 | + } else{ |
|
60 | 60 | $result = $reflectionMethod->invokeArgs($instance, $args); |
61 | 61 | if($result !== false){ |
62 | 62 | $return = $result; |
@@ -46,6 +46,6 @@ |
||
46 | 46 | }); |
47 | 47 | |
48 | 48 | if ((!defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && class_exists('Composer\Autoload\ClassLoader')) { |
49 | - trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
|
49 | + trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
|
50 | 50 | E_USER_WARNING); |
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * Register Autoload |
20 | 20 | */ |
21 | -spl_autoload_register(function ($entity) { |
|
21 | +spl_autoload_register(function($entity) { |
|
22 | 22 | $module = explode('\\', $entity, 2); |
23 | - if (!in_array($module[ 0 ], ['phpFastCache', 'Psr'])) { |
|
23 | + if (!in_array($module[0], ['phpFastCache', 'Psr'])) { |
|
24 | 24 | /** |
25 | 25 | * Not a part of phpFastCache file |
26 | 26 | * then we return here. |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | if (is_readable($path)) { |
33 | 33 | require_once $path; |
34 | - }else{ |
|
34 | + } else { |
|
35 | 35 | trigger_error('Cannot locate the Psr/Cache files', E_USER_ERROR); |
36 | 36 | } |
37 | 37 | return; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | if (is_readable($path)) { |
42 | 42 | require_once $path; |
43 | - }else{ |
|
43 | + } else { |
|
44 | 44 | trigger_error('Cannot locate the Psr/SimpleCache files', E_USER_ERROR); |
45 | 45 | } |
46 | 46 | return; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | if (is_readable($path)) { |
33 | 33 | require_once $path; |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | trigger_error('Cannot locate the Psr/Cache files', E_USER_ERROR); |
36 | 36 | } |
37 | 37 | return; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | if (is_readable($path)) { |
42 | 42 | require_once $path; |
43 | - }else{ |
|
43 | + } else{ |
|
44 | 44 | trigger_error('Cannot locate the Psr/SimpleCache files', E_USER_ERROR); |
45 | 45 | } |
46 | 46 | return; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | protected function driverRead(CacheItemInterface $item) |
85 | 85 | { |
86 | 86 | $key = md5($item->getKey()); |
87 | - if(isset($this->staticStack[$key])){ |
|
87 | + if (isset($this->staticStack[$key])) { |
|
88 | 88 | return $this->staticStack[$key]; |
89 | 89 | } |
90 | 90 | return null; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | if ($item instanceof Item) { |
104 | 104 | $key = md5($item->getKey()); |
105 | - if(isset($this->staticStack[$key])){ |
|
105 | + if (isset($this->staticStack[$key])) { |
|
106 | 106 | unset($this->staticStack[$key]); |
107 | 107 | return true; |
108 | 108 | } |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | { |
31 | 31 | use DriverBaseTrait; |
32 | 32 | |
33 | - /** |
|
34 | - * @var array |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var array |
|
35 | + */ |
|
36 | 36 | protected $staticStack = []; |
37 | 37 | |
38 | 38 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | $key = md5($item->getKey()); |
88 | 88 | if(isset($this->staticStack[$key])){ |
89 | - return $this->staticStack[$key]; |
|
89 | + return $this->staticStack[$key]; |
|
90 | 90 | } |
91 | 91 | return null; |
92 | 92 | } |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | * Check for Cross-Driver type confusion |
103 | 103 | */ |
104 | 104 | if ($item instanceof Item) { |
105 | - $key = md5($item->getKey()); |
|
106 | - if(isset($this->staticStack[$key])){ |
|
107 | - unset($this->staticStack[$key]); |
|
108 | - return true; |
|
109 | - } |
|
110 | - return false; |
|
105 | + $key = md5($item->getKey()); |
|
106 | + if(isset($this->staticStack[$key])){ |
|
107 | + unset($this->staticStack[$key]); |
|
108 | + return true; |
|
109 | + } |
|
110 | + return false; |
|
111 | 111 | } else { |
112 | 112 | throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected'); |
113 | 113 | } |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function driverClear() |
120 | 120 | { |
121 | - unset($this->staticStack); |
|
122 | - $this->staticStack = []; |
|
123 | - return true; |
|
121 | + unset($this->staticStack); |
|
122 | + $this->staticStack = []; |
|
123 | + return true; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | { |
145 | 145 | $stat = new DriverStatistic(); |
146 | 146 | $stat->setInfo('[Memstatic] A memory static driver') |
147 | - ->setSize(mb_strlen(serialize($this->staticStack))) |
|
148 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
149 | - ->setRawData($this->staticStack); |
|
147 | + ->setSize(mb_strlen(serialize($this->staticStack))) |
|
148 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
149 | + ->setRawData($this->staticStack); |
|
150 | 150 | |
151 | 151 | return $stat; |
152 | 152 | } |