@@ -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; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
| 212 | - * @param $keyword |
|
| 212 | + * @param string $keyword |
|
| 213 | 213 | * @param bool $reset |
| 214 | 214 | * @return PDO |
| 215 | 215 | */ |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * @param \Psr\Cache\CacheItemInterface $item |
| 249 | - * @return mixed |
|
| 249 | + * @return boolean |
|
| 250 | 250 | * @throws \InvalidArgumentException |
| 251 | 251 | */ |
| 252 | 252 | protected function driverWrite(CacheItemInterface $item) |
@@ -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; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * @return int|bool Return size in octet or false if no information available |
|
| 55 | + * @return string Return size in octet or false if no information available |
|
| 56 | 56 | */ |
| 57 | 57 | public function getSize() |
| 58 | 58 | { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * @return mixed |
|
| 63 | + * @return string |
|
| 64 | 64 | */ |
| 65 | 65 | public function getData() |
| 66 | 66 | { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * @param $info |
|
| 71 | + * @param string $info |
|
| 72 | 72 | * @return $this |
| 73 | 73 | */ |
| 74 | 74 | public function setInfo($info) |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * @param \Psr\Cache\CacheItemInterface $item |
| 60 | - * @return mixed |
|
| 60 | + * @return boolean |
|
| 61 | 61 | * @throws \InvalidArgumentException |
| 62 | 62 | */ |
| 63 | 63 | public function driverWrite(CacheItemInterface $item) |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | protected function driverRead(CacheItemInterface $item) |
| 80 | 80 | { |
| 81 | 81 | return [ |
| 82 | - self::DRIVER_DATA_WRAPPER_INDEX => true, |
|
| 83 | - self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
| 84 | - self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), |
|
| 82 | + self::DRIVER_DATA_WRAPPER_INDEX => true, |
|
| 83 | + self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
| 84 | + self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), |
|
| 85 | 85 | ]; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | $stat = new driverStatistic(); |
| 133 | 133 | $stat->setInfo('[Devtrue] A void info string') |
| 134 | - ->setSize(0) |
|
| 135 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 136 | - ->setRawData(true); |
|
| 134 | + ->setSize(0) |
|
| 135 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 136 | + ->setRawData(true); |
|
| 137 | 137 | |
| 138 | 138 | return $stat; |
| 139 | 139 | } |
@@ -133,8 +133,8 @@ |
||
| 133 | 133 | $stats = (array) zend_shm_cache_info(); |
| 134 | 134 | return (new driverStatistic()) |
| 135 | 135 | ->setData(implode(', ', array_keys($this->namespaces))) |
| 136 | - ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.",$stats[ 'items_total' ])) |
|
| 136 | + ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total'])) |
|
| 137 | 137 | ->setRawData($stats) |
| 138 | - ->setSize($stats[ 'memory_total' ]); |
|
| 138 | + ->setSize($stats['memory_total']); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | \ No newline at end of file |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | } else { |
| 84 | 84 | $item->setHit(true); |
| 85 | 85 | } |
| 86 | - }else{ |
|
| 86 | + } else{ |
|
| 87 | 87 | $item->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ])); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -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 | } |
@@ -84,13 +84,13 @@ |
||
| 84 | 84 | if(is_callable($arguments[0])){ |
| 85 | 85 | if(isset($arguments[1]) && is_string($arguments[0])){ |
| 86 | 86 | $this->events[$name][$arguments[1]] = $arguments[0]; |
| 87 | - }else { |
|
| 87 | + } else { |
|
| 88 | 88 | $this->events[$name][] = $arguments[0]; |
| 89 | 89 | } |
| 90 | - }else{ |
|
| 90 | + } else{ |
|
| 91 | 91 | throw new \InvalidArgumentException(sprintf('Expected Callable, got "%s"', gettype($arguments[0]))); |
| 92 | 92 | } |
| 93 | - }else{ |
|
| 93 | + } else{ |
|
| 94 | 94 | throw new \BadMethodCallException('An event must start with "on" such as "onCacheGetItem"'); |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | public function dispatch($eventName, ...$args) |
| 67 | 67 | { |
| 68 | 68 | $eventName = 'on' . ucfirst($eventName); |
| 69 | - if(array_key_exists($eventName, $this->events)){ |
|
| 70 | - foreach ($this->events[ $eventName ] as $event) { |
|
| 69 | + if (array_key_exists($eventName, $this->events)) { |
|
| 70 | + foreach ($this->events[$eventName] as $event) { |
|
| 71 | 71 | call_user_func_array($event, $args); |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -81,17 +81,17 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function __call($name, $arguments) |
| 83 | 83 | { |
| 84 | - if(strpos($name, 'on') === 0){ |
|
| 85 | - if(is_callable($arguments[0])){ |
|
| 86 | - if(isset($arguments[1]) && is_string($arguments[0])){ |
|
| 84 | + if (strpos($name, 'on') === 0) { |
|
| 85 | + if (is_callable($arguments[0])) { |
|
| 86 | + if (isset($arguments[1]) && is_string($arguments[0])) { |
|
| 87 | 87 | $this->events[$name][$arguments[1]] = $arguments[0]; |
| 88 | - }else { |
|
| 88 | + } else { |
|
| 89 | 89 | $this->events[$name][] = $arguments[0]; |
| 90 | 90 | } |
| 91 | - }else{ |
|
| 91 | + } else { |
|
| 92 | 92 | throw new \InvalidArgumentException(sprintf('Expected Callable, got "%s"', gettype($arguments[0]))); |
| 93 | 93 | } |
| 94 | - }else{ |
|
| 94 | + } else { |
|
| 95 | 95 | throw new \BadMethodCallException('An event must start with "on" such as "onCacheGetItem"'); |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function unbindEventCallback($eventName, $callbackName) |
| 105 | 105 | { |
| 106 | - if(isset($this->events[$eventName][$callbackName])){ |
|
| 106 | + if (isset($this->events[$eventName][$callbackName])) { |
|
| 107 | 107 | unset($this->events[$eventName][$callbackName]); |
| 108 | 108 | return true; |
| 109 | 109 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * @param \Psr\Cache\CacheItemInterface $item |
| 63 | - * @return mixed |
|
| 63 | + * @return boolean |
|
| 64 | 64 | * @throws \InvalidArgumentException |
| 65 | 65 | */ |
| 66 | 66 | protected function driverWrite(CacheItemInterface $item) |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | /** |
| 147 | 147 | * @param string $optionName |
| 148 | 148 | * @param mixed $optionValue |
| 149 | - * @return bool |
|
| 149 | + * @return boolean|null |
|
| 150 | 150 | * @throws \InvalidArgumentException |
| 151 | 151 | */ |
| 152 | 152 | public static function isValidOption($optionName, $optionValue) |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * @return array |
|
| 177 | + * @return string[] |
|
| 178 | 178 | */ |
| 179 | 179 | public static function getValidOptions() |
| 180 | 180 | { |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | - * @return array |
|
| 185 | + * @return string[] |
|
| 186 | 186 | */ |
| 187 | 187 | public static function getRequiredOptions() |
| 188 | 188 | { |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | return $tmp_dir; |
| 98 | 98 | } |
| 99 | 99 | return $full_path; |
| 100 | - }else{ |
|
| 100 | + } else{ |
|
| 101 | 101 | if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
| 102 | 102 | if (!@file_exists($full_path)) { |
| 103 | 103 | @mkdir($full_path, $this->setChmodAuto(), true); |
| 104 | - }else if (!@is_writable($full_path)) { |
|
| 104 | + } else if (!@is_writable($full_path)) { |
|
| 105 | 105 | @chmod($full_path, $this->setChmodAuto()); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | if(!rename($tmpFilename, $file)){ |
| 313 | 313 | throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file)); |
| 314 | 314 | } |
| 315 | - }else{ |
|
| 315 | + } else{ |
|
| 316 | 316 | $f = fopen($file, 'w+'); |
| 317 | 317 | $octetWritten = fwrite($f, $data); |
| 318 | 318 | fclose($f); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | - * @param $keyword |
|
| 133 | + * @param false|string $keyword |
|
| 134 | 134 | * @param bool $skip |
| 135 | 135 | * @return string |
| 136 | 136 | * @throws phpFastCacheIOException |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | /** |
| 199 | 199 | * @param $filename |
| 200 | - * @return mixed |
|
| 200 | + * @return string |
|
| 201 | 201 | */ |
| 202 | 202 | protected static function cleanFileName($filename) |
| 203 | 203 | { |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | - * @param $path |
|
| 215 | + * @param string $path |
|
| 216 | 216 | * @param bool $create |
| 217 | 217 | * @throws phpFastCacheIOException |
| 218 | 218 | */ |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | - * @param $file |
|
| 252 | + * @param string $file |
|
| 253 | 253 | * @return string |
| 254 | 254 | * @throws phpFastCacheIOException |
| 255 | 255 | */ |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | protected static function cleanFileName($filename) |
| 203 | 203 | { |
| 204 | 204 | $regex = [ |
| 205 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 206 | - '/\.$/', |
|
| 207 | - '/^\./', |
|
| 205 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 206 | + '/\.$/', |
|
| 207 | + '/^\./', |
|
| 208 | 208 | ]; |
| 209 | 209 | $replace = ['-', '', '']; |
| 210 | 210 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5( |
| 297 | 297 | str_shuffle(uniqid($this->getDriverName(), false)) |
| 298 | 298 | . str_shuffle(uniqid($this->getDriverName(), false)) |
| 299 | - )); |
|
| 299 | + )); |
|
| 300 | 300 | |
| 301 | 301 | $f = fopen($tmpFilename, 'w+'); |
| 302 | 302 | flock($f, LOCK_EX); |
@@ -338,11 +338,11 @@ discard block |
||
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | $stat->setData(implode(', ', array_keys($this->itemInstances))) |
| 341 | - ->setRawData([ |
|
| 341 | + ->setRawData([ |
|
| 342 | 342 | 'tmp' => $this->tmp |
| 343 | - ]) |
|
| 344 | - ->setSize(Directory::dirSize($path)) |
|
| 345 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
| 343 | + ]) |
|
| 344 | + ->setSize(Directory::dirSize($path)) |
|
| 345 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
| 346 | 346 | |
| 347 | 347 | return $stat; |
| 348 | 348 | } |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | * Calculate the security key |
| 52 | 52 | */ |
| 53 | 53 | { |
| 54 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
| 54 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
| 55 | 55 | if (!$securityKey || $securityKey === 'auto') { |
| 56 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
| 57 | - $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
| 56 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
| 57 | + $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
| 58 | 58 | } else { |
| 59 | 59 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
| 60 | 60 | } |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR; |
| 75 | 75 | |
| 76 | - if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) { |
|
| 76 | + if (empty($this->config['path']) || !is_string($this->config['path'])) { |
|
| 77 | 77 | $path = $tmp_dir; |
| 78 | 78 | } else { |
| 79 | - $path = rtrim($this->config[ 'path' ], '/') . DIRECTORY_SEPARATOR; |
|
| 79 | + $path = rtrim($this->config['path'], '/') . DIRECTORY_SEPARATOR; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $path_suffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName(); |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | * return the temp dir |
| 92 | 92 | */ |
| 93 | 93 | if ($readonly === true) { |
| 94 | - if($this->config[ 'autoTmpFallback' ] && (!@file_exists($full_path) || !@is_writable($full_path))){ |
|
| 94 | + if ($this->config['autoTmpFallback'] && (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 95 | 95 | return $full_path_tmp; |
| 96 | 96 | } |
| 97 | 97 | return $full_path; |
| 98 | - }else{ |
|
| 99 | - if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 98 | + } else { |
|
| 99 | + if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 100 | 100 | if (!@file_exists($full_path)) { |
| 101 | 101 | @mkdir($full_path, $this->getDefaultChmod(), true); |
| 102 | - }else if (!@is_writable($full_path)) { |
|
| 103 | - if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config[ 'autoTmpFallback' ]) |
|
| 102 | + } else if (!@is_writable($full_path)) { |
|
| 103 | + if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config['autoTmpFallback']) |
|
| 104 | 104 | { |
| 105 | 105 | /** |
| 106 | 106 | * Switch back to tmp dir |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | throw new phpFastCacheIOException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!'); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $this->tmp[ $full_path_hash ] = $full_path; |
|
| 126 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
| 125 | + $this->tmp[$full_path_hash] = $full_path; |
|
| 126 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | protected function getDefaultChmod() |
| 182 | 182 | { |
| 183 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
| 183 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
| 184 | 184 | return 0777; |
| 185 | 185 | } else { |
| 186 | - return $this->config[ 'default_chmod' ]; |
|
| 186 | + return $this->config['default_chmod']; |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | if ($create === true) { |
| 214 | 214 | if (!is_writable($path)) { |
| 215 | 215 | try { |
| 216 | - if(!chmod($path, 0777)){ |
|
| 216 | + if (!chmod($path, 0777)) { |
|
| 217 | 217 | throw new phpFastCacheIOException('Chmod failed on : ' . $path); |
| 218 | 218 | } |
| 219 | 219 | } catch (phpFastCacheIOException $e) { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | $this->eventManager->dispatch('CacheWriteFileOnDisk', $this, $file, $secureFileManipulation); |
| 286 | 286 | |
| 287 | - if($secureFileManipulation){ |
|
| 287 | + if ($secureFileManipulation) { |
|
| 288 | 288 | $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5( |
| 289 | 289 | str_shuffle(uniqid($this->getDriverName(), false)) |
| 290 | 290 | . str_shuffle(uniqid($this->getDriverName(), false)) |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | flock($f, LOCK_UN); |
| 297 | 297 | fclose($f); |
| 298 | 298 | |
| 299 | - if(!rename($tmpFilename, $file)){ |
|
| 299 | + if (!rename($tmpFilename, $file)) { |
|
| 300 | 300 | throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file)); |
| 301 | 301 | } |
| 302 | - }else{ |
|
| 302 | + } else { |
|
| 303 | 303 | $f = fopen($file, 'w+'); |
| 304 | 304 | $octetWritten = fwrite($f, $data); |
| 305 | 305 | fclose($f); |
@@ -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; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | flock($f, LOCK_UN); |
| 120 | 120 | fclose($f); |
| 121 | 121 | rename($tmpFilename, $file); |
| 122 | - }else{ |
|
| 122 | + } else{ |
|
| 123 | 123 | $f = fopen($file, 'w+'); |
| 124 | 124 | $octetWritten = fwrite($f, $data); |
| 125 | 125 | fclose($f); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * reuse it else set a new Date |
| 209 | 209 | */ |
| 210 | 210 | $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
| 211 | - }else{ |
|
| 211 | + } else{ |
|
| 212 | 212 | $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
| 213 | 213 | $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
| 214 | 214 | } |