@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $status = 0; |
17 | 17 | echo "Testing EventManager\n"; |
18 | 18 | |
19 | -EventManager::getInstance()->onCacheSaveItem(function(ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item){ |
|
20 | - if($item->get() === 1000){ |
|
19 | +EventManager::getInstance()->onCacheSaveItem(function(ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item) { |
|
20 | + if ($item->get() === 1000) { |
|
21 | 21 | $item->increment(337); |
22 | 22 | } |
23 | 23 | }); |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | $cacheInstance->save($item); |
31 | 31 | |
32 | 32 | |
33 | -if($cacheInstance->getItem($cacheKey)->get() === 1337){ |
|
33 | +if ($cacheInstance->getItem($cacheKey)->get() === 1337) { |
|
34 | 34 | echo "[PASS] The dispatched event executed the custom callback to alter to item.\n"; |
35 | -}else{ |
|
35 | +} else { |
|
36 | 36 | echo "[FAIL] The dispatched event did not worked well, the expected value '1337', got '" . (int) $cacheInstance->getItem($cacheKey)->get() . "'\n"; |
37 | 37 | $status = 1; |
38 | 38 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | if (!class_exists('phpFastCache\CacheManager')) { |
16 | 16 | echo "[FAIL] Autoload failed to find the CacheManager\n"; |
17 | 17 | $status = 255; |
18 | -}else{ |
|
18 | +} else{ |
|
19 | 19 | echo "[PASS] Autoload successfully found the CacheManager\n"; |
20 | 20 | } |
21 | 21 |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | protected static function cleanFileName($filename) |
187 | 187 | { |
188 | 188 | $regex = [ |
189 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
190 | - '/\.$/', |
|
191 | - '/^\./', |
|
189 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
190 | + '/\.$/', |
|
191 | + '/^\./', |
|
192 | 192 | ]; |
193 | 193 | $replace = ['-', '', '']; |
194 | 194 | |
@@ -277,7 +277,7 @@ discard block |
||
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)) |
280 | - )); |
|
280 | + )); |
|
281 | 281 | |
282 | 282 | $f = fopen($tmpFilename, 'w+'); |
283 | 283 | flock($f, LOCK_EX); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | - * @param $keyword |
|
133 | + * @param string|false $keyword |
|
134 | 134 | * @param bool $skip |
135 | 135 | * @return string |
136 | 136 | * @throws phpFastCacheIOException |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | /** |
178 | 178 | * @param $filename |
179 | - * @return mixed |
|
179 | + * @return string |
|
180 | 180 | */ |
181 | 181 | protected static function cleanFileName($filename) |
182 | 182 | { |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
194 | - * @param $path |
|
194 | + * @param string $path |
|
195 | 195 | * @param bool $create |
196 | 196 | * @throws phpFastCacheIOException |
197 | 197 | */ |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | |
227 | 227 | /** |
228 | - * @param $file |
|
228 | + * @param string $file |
|
229 | 229 | * @return string |
230 | 230 | * @throws phpFastCacheIOException |
231 | 231 | */ |
@@ -34,26 +34,26 @@ discard block |
||
34 | 34 | { |
35 | 35 | $tmp_dir = rtrim(ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(), '\\/') . DIRECTORY_SEPARATOR . 'phpfastcache'; |
36 | 36 | |
37 | - if (!isset($this->config[ 'path' ]) || $this->config[ 'path' ] == '') { |
|
37 | + if (!isset($this->config['path']) || $this->config['path'] == '') { |
|
38 | 38 | if (self::isPHPModule()) { |
39 | 39 | $path = $tmp_dir; |
40 | 40 | } else { |
41 | - $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../'; |
|
42 | - $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . 'PathSeekerTrait.php/'; |
|
41 | + $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../'; |
|
42 | + $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . 'PathSeekerTrait.php/'; |
|
43 | 43 | } |
44 | 44 | |
45 | - if ($this->config[ 'path' ] != '') { |
|
46 | - $path = $this->config[ 'path' ]; |
|
45 | + if ($this->config['path'] != '') { |
|
46 | + $path = $this->config['path']; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | } else { |
50 | - $path = $this->config[ 'path' ]; |
|
50 | + $path = $this->config['path']; |
|
51 | 51 | } |
52 | 52 | |
53 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
53 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
54 | 54 | if (!$securityKey || $securityKey === 'auto') { |
55 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
56 | - $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
55 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
56 | + $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
57 | 57 | } else { |
58 | 58 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
59 | 59 | } |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | return $full_path; |
73 | 73 | } |
74 | 74 | |
75 | - if (!isset($this->tmp[ $full_pathx ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
75 | + if (!isset($this->tmp[$full_pathx]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
76 | 76 | if (!@file_exists($full_path)) { |
77 | 77 | @mkdir($full_path, $this->setChmodAuto(), true); |
78 | - }else if (!@is_writable($full_path)) { |
|
78 | + } else if (!@is_writable($full_path)) { |
|
79 | 79 | @chmod($full_path, $this->setChmodAuto()); |
80 | 80 | } |
81 | 81 | |
82 | - if ($this->config[ 'autoTmpFallback' ] && !@is_writable($full_path)) { |
|
82 | + if ($this->config['autoTmpFallback'] && !@is_writable($full_path)) { |
|
83 | 83 | /** |
84 | 84 | * Switch back to tmp dir |
85 | 85 | * again if the path is not writable |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | throw new phpFastCacheIOException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!'); |
94 | 94 | } |
95 | 95 | |
96 | - $this->tmp[ $full_pathx ] = true; |
|
97 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
96 | + $this->tmp[$full_pathx] = true; |
|
97 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return realpath($full_path); |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function setChmodAuto() |
169 | 169 | { |
170 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
170 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
171 | 171 | return 0777; |
172 | 172 | } else { |
173 | - return $this->config[ 'default_chmod' ]; |
|
173 | + return $this->config['default_chmod']; |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | if ($create === true) { |
201 | 201 | if (!is_writable($path)) { |
202 | 202 | try { |
203 | - if(!chmod($path, 0777)){ |
|
203 | + if (!chmod($path, 0777)) { |
|
204 | 204 | throw new phpFastCacheIOException('Chmod failed on : ' . $path); |
205 | 205 | } |
206 | 206 | } catch (phpFastCacheIOException $e) { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | */ |
269 | 269 | $this->eventManager->dispatch('CacheWriteFileOnDisk', $this, $file, $secureFileManipulation); |
270 | 270 | |
271 | - if($secureFileManipulation){ |
|
271 | + if ($secureFileManipulation) { |
|
272 | 272 | $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5( |
273 | 273 | str_shuffle(uniqid($this->getDriverName(), false)) |
274 | 274 | . str_shuffle(uniqid($this->getDriverName(), false)) |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | flock($f, LOCK_UN); |
281 | 281 | fclose($f); |
282 | 282 | |
283 | - if(!rename($tmpFilename, $file)){ |
|
283 | + if (!rename($tmpFilename, $file)) { |
|
284 | 284 | throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file)); |
285 | 285 | } |
286 | - }else{ |
|
286 | + } else { |
|
287 | 287 | $f = fopen($file, 'w+'); |
288 | 288 | $octetWritten = fwrite($f, $data); |
289 | 289 | fclose($f); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if (!isset($this->tmp[ $full_pathx ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
76 | 76 | if (!@file_exists($full_path)) { |
77 | 77 | @mkdir($full_path, $this->setChmodAuto(), true); |
78 | - }else if (!@is_writable($full_path)) { |
|
78 | + } else if (!@is_writable($full_path)) { |
|
79 | 79 | @chmod($full_path, $this->setChmodAuto()); |
80 | 80 | } |
81 | 81 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | if(!rename($tmpFilename, $file)){ |
284 | 284 | throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file)); |
285 | 285 | } |
286 | - }else{ |
|
286 | + } else{ |
|
287 | 287 | $f = fopen($file, 'w+'); |
288 | 288 | $octetWritten = fwrite($f, $data); |
289 | 289 | fclose($f); |