@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | if (is_array($config_name)) { |
| 53 | 53 | $this->config = array_merge($this->config, $config_name); |
| 54 | 54 | } else { |
| 55 | - $this->config[ $config_name ] = $value; |
|
| 55 | + $this->config[$config_name] = $value; |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -164,16 +164,16 @@ discard block |
||
| 164 | 164 | self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
| 165 | 165 | ]; |
| 166 | 166 | |
| 167 | - if($this->config['itemDetailedDate']){ |
|
| 168 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = new \DateTime(); |
|
| 167 | + if ($this->config['itemDetailedDate']) { |
|
| 168 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = new \DateTime(); |
|
| 169 | 169 | /** |
| 170 | 170 | * If the creation date exists |
| 171 | 171 | * reuse it else set a new Date |
| 172 | 172 | */ |
| 173 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
|
| 174 | - }else{ |
|
| 175 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
|
| 176 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
|
| 173 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate() ?: new \DateTime(); |
|
| 174 | + } else { |
|
| 175 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = null; |
|
| 176 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = null; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | return $wrap; |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function driverUnwrapData(array $wrapper) |
| 187 | 187 | { |
| 188 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
| 188 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function driverUnwrapTags(array $wrapper) |
| 196 | 196 | { |
| 197 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
| 197 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function driverUnwrapEdate(array $wrapper) |
| 206 | 206 | { |
| 207 | - return $wrapper[ self::DRIVER_EDATE_WRAPPER_INDEX ]; |
|
| 207 | + return $wrapper[self::DRIVER_EDATE_WRAPPER_INDEX]; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function driverUnwrapCdate(array $wrapper) |
| 215 | 215 | { |
| 216 | - return $wrapper[ self::DRIVER_CDATE_WRAPPER_INDEX ]; |
|
| 216 | + return $wrapper[self::DRIVER_CDATE_WRAPPER_INDEX]; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function driverUnwrapMdate(array $wrapper) |
| 225 | 225 | { |
| 226 | - return $wrapper[ self::DRIVER_MDATE_WRAPPER_INDEX ]; |
|
| 226 | + return $wrapper[self::DRIVER_MDATE_WRAPPER_INDEX]; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * on tags item, it can leads |
| 249 | 249 | * to an infinite recursive calls |
| 250 | 250 | */ |
| 251 | - if(strpos($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX ) === 0){ |
|
| 251 | + if (strpos($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX) === 0) { |
|
| 252 | 252 | throw new \LogicException('Trying to set tag(s) to an Tag item index: ' . $item->getKey()); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | foreach ($tagsItems as $tagsItem) { |
| 292 | 292 | $data = (array) $tagsItem->get(); |
| 293 | 293 | |
| 294 | - unset($data[ $item->getKey() ]); |
|
| 294 | + unset($data[$item->getKey()]); |
|
| 295 | 295 | $tagsItem->set($data); |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -35,30 +35,30 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | $tmp_dir = rtrim(ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(), '\\/') . DIRECTORY_SEPARATOR . 'phpfastcache'; |
| 37 | 37 | |
| 38 | - if (!isset($this->config[ 'path' ]) || $this->config[ 'path' ] == '') { |
|
| 38 | + if (!isset($this->config['path']) || $this->config['path'] == '') { |
|
| 39 | 39 | if (self::isPHPModule()) { |
| 40 | 40 | $path = $tmp_dir; |
| 41 | 41 | } else { |
| 42 | - $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../'; |
|
| 43 | - $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . 'PathSeekerTrait.php/'; |
|
| 42 | + $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../'; |
|
| 43 | + $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . 'PathSeekerTrait.php/'; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if ($this->config[ 'path' ] != '') { |
|
| 47 | - $path = $this->config[ 'path' ]; |
|
| 46 | + if ($this->config['path'] != '') { |
|
| 47 | + $path = $this->config['path']; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | } else { |
| 51 | - $path = $this->config[ 'path' ]; |
|
| 51 | + $path = $this->config['path']; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | if ($getBasePath === true) { |
| 55 | 55 | return $path; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
| 58 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
| 59 | 59 | if (!$securityKey || $securityKey === 'auto') { |
| 60 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
| 61 | - $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
| 60 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
| 61 | + $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
| 62 | 62 | } else { |
| 63 | 63 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
| 64 | 64 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $full_pathx = md5($full_path); |
| 75 | 75 | |
| 76 | 76 | |
| 77 | - if (!isset($this->tmp[ $full_pathx ])) { |
|
| 77 | + if (!isset($this->tmp[$full_pathx])) { |
|
| 78 | 78 | |
| 79 | 79 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
| 80 | 80 | if (!@file_exists($full_path)) { |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $this->tmp[ $full_pathx ] = true; |
|
| 102 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
| 101 | + $this->tmp[$full_pathx] = true; |
|
| 102 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | return realpath($full_path); |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | public function setChmodAuto() |
| 174 | 174 | { |
| 175 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
| 175 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
| 176 | 176 | return 0777; |
| 177 | 177 | } else { |
| 178 | - return $this->config[ 'default_chmod' ]; |
|
| 178 | + return $this->config['default_chmod']; |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | if ($create === true) { |
| 206 | 206 | if (!is_writable($path)) { |
| 207 | 207 | try { |
| 208 | - if(!chmod($path, 0777)){ |
|
| 208 | + if (!chmod($path, 0777)) { |
|
| 209 | 209 | throw new phpFastCacheIOException('Chmod failed on : ' . $path); |
| 210 | 210 | } |
| 211 | 211 | } catch (phpFastCacheIOException $e) { |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | $this->eventManager->dispatch('CacheWriteFileOnDisk', $this, $file, $secureFileManipulation); |
| 275 | 275 | |
| 276 | - if($secureFileManipulation){ |
|
| 276 | + if ($secureFileManipulation) { |
|
| 277 | 277 | $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5( |
| 278 | 278 | str_shuffle(uniqid($this->getDriverName(), false)) |
| 279 | 279 | . str_shuffle(uniqid($this->getDriverName(), false)) |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | flock($f, LOCK_UN); |
| 286 | 286 | fclose($f); |
| 287 | 287 | |
| 288 | - if(!rename($tmpFilename, $file)){ |
|
| 288 | + if (!rename($tmpFilename, $file)) { |
|
| 289 | 289 | throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file)); |
| 290 | 290 | } |
| 291 | - }else{ |
|
| 291 | + } else { |
|
| 292 | 292 | $f = fopen($file, 'w+'); |
| 293 | 293 | $octetWritten = fwrite($f, $data); |
| 294 | 294 | fclose($f); |