@@ -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']){ |
@@ -273,7 +273,7 @@ |
||
273 | 273 | |
274 | 274 | if (!is_dir($path)) { |
275 | 275 | throw new phpFastCacheDriverException("Can't read PATH:" . $path, 94); |
276 | - }else{ |
|
276 | + } else{ |
|
277 | 277 | $size = Directory::dirSize($path); |
278 | 278 | } |
279 | 279 |
@@ -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 | /** |
@@ -13,9 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | namespace phpFastCache\Core\Pool; |
15 | 15 | |
16 | -use phpFastCache\Exceptions\phpFastCacheDriverException; |
|
17 | 16 | use phpFastCache\Core\Item\ExtendedCacheItemInterface; |
18 | -use phpFastCache\Util\Directory; |
|
19 | 17 | |
20 | 18 | |
21 | 19 | /** |
@@ -26,7 +26,6 @@ discard block |
||
26 | 26 | public $tmp = []; |
27 | 27 | |
28 | 28 | /** |
29 | - * @param bool $skip_create_path |
|
30 | 29 | * @param $config |
31 | 30 | * @return string |
32 | 31 | * @throws phpFastCacheIOException |
@@ -135,7 +134,7 @@ discard block |
||
135 | 134 | } |
136 | 135 | |
137 | 136 | /** |
138 | - * @param $keyword |
|
137 | + * @param string|false $keyword |
|
139 | 138 | * @param bool $skip |
140 | 139 | * @return string |
141 | 140 | * @throws phpFastCacheIOException |
@@ -181,7 +180,7 @@ discard block |
||
181 | 180 | |
182 | 181 | /** |
183 | 182 | * @param $filename |
184 | - * @return mixed |
|
183 | + * @return string |
|
185 | 184 | */ |
186 | 185 | protected static function cleanFileName($filename) |
187 | 186 | { |
@@ -196,7 +195,7 @@ discard block |
||
196 | 195 | } |
197 | 196 | |
198 | 197 | /** |
199 | - * @param $path |
|
198 | + * @param string $path |
|
200 | 199 | * @param bool $create |
201 | 200 | * @throws phpFastCacheIOException |
202 | 201 | */ |
@@ -230,7 +229,7 @@ discard block |
||
230 | 229 | |
231 | 230 | |
232 | 231 | /** |
233 | - * @param $file |
|
232 | + * @param string $file |
|
234 | 233 | * @return string |
235 | 234 | * @throws phpFastCacheIOException |
236 | 235 | */ |
@@ -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); |
@@ -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); |
@@ -273,7 +273,7 @@ |
||
273 | 273 | |
274 | 274 | if (!is_dir($path)) { |
275 | 275 | throw new phpFastCacheDriverException("Can't read PATH:" . $path, 94); |
276 | - }else{ |
|
276 | + } else{ |
|
277 | 277 | $size = Directory::dirSize($path); |
278 | 278 | } |
279 | 279 |
@@ -16,13 +16,11 @@ |
||
16 | 16 | |
17 | 17 | use PDO; |
18 | 18 | use PDOException; |
19 | -use phpFastCache\Core\Item\ExtendedCacheItemInterface; |
|
20 | 19 | use phpFastCache\Core\Pool\DriverBaseTrait; |
21 | 20 | use phpFastCache\Core\Pool\ExtendedCacheItemPoolInterface; |
22 | 21 | use phpFastCache\Core\Pool\IO\IOHelperTrait; |
23 | 22 | use phpFastCache\Entities\driverStatistic; |
24 | 23 | use phpFastCache\Exceptions\phpFastCacheDriverCheckException; |
25 | -use phpFastCache\Exceptions\phpFastCacheDriverException; |
|
26 | 24 | use phpFastCache\Exceptions\phpFastCacheIOException; |
27 | 25 | use phpFastCache\Util\Directory; |
28 | 26 | use Psr\Cache\CacheItemInterface; |