@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | protected static function cleanFileName($filename) |
161 | 161 | { |
162 | 162 | $regex = [ |
163 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
164 | - '/\.$/', |
|
165 | - '/^\./', |
|
163 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
164 | + '/\.$/', |
|
165 | + '/^\./', |
|
166 | 166 | ]; |
167 | 167 | $replace = ['-', '', '']; |
168 | 168 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | chmod($path, 0777); |
183 | 183 | } catch (phpFastCacheDriverException $e) { |
184 | 184 | throw new phpFastCacheDriverException('PLEASE CHMOD ' . $path . ' - 0777 OR ANY WRITABLE PERMISSION!', |
185 | - 92); |
|
185 | + 92); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 |
@@ -25,7 +25,6 @@ discard block |
||
25 | 25 | public $tmp = []; |
26 | 26 | |
27 | 27 | /** |
28 | - * @param bool $skip_create_path |
|
29 | 28 | * @param $config |
30 | 29 | * @return string |
31 | 30 | * @throws \Exception |
@@ -118,7 +117,7 @@ discard block |
||
118 | 117 | } |
119 | 118 | |
120 | 119 | /** |
121 | - * @param $keyword |
|
120 | + * @param string|false $keyword |
|
122 | 121 | * @param bool $skip |
123 | 122 | * @return string |
124 | 123 | * @throws phpFastCacheDriverException |
@@ -165,7 +164,7 @@ discard block |
||
165 | 164 | |
166 | 165 | /** |
167 | 166 | * @param $filename |
168 | - * @return mixed |
|
167 | + * @return string |
|
169 | 168 | */ |
170 | 169 | protected static function cleanFileName($filename) |
171 | 170 | { |
@@ -180,7 +179,7 @@ discard block |
||
180 | 179 | } |
181 | 180 | |
182 | 181 | /** |
183 | - * @param $path |
|
182 | + * @param string $path |
|
184 | 183 | * @param bool $create |
185 | 184 | * @throws \Exception |
186 | 185 | */ |
@@ -34,32 +34,32 @@ discard block |
||
34 | 34 | { |
35 | 35 | $tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(); |
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__, '/') . '/'; |
|
41 | + $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../'; |
|
42 | + $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . '/'; |
|
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 | - if($getBasePath === true) |
|
53 | + if ($getBasePath === true) |
|
54 | 54 | { |
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 | - $securityKey = $this->config[ 'securityKey' ]; |
|
60 | + $securityKey = $this->config['securityKey']; |
|
61 | 61 | if ($securityKey == 'auto' || $securityKey == '') { |
62 | - $securityKey = isset($_SERVER[ 'HTTP_HOST' ]) ? preg_replace('/^www./', '', strtolower($_SERVER[ 'HTTP_HOST' ])) : "default"; |
|
62 | + $securityKey = isset($_SERVER['HTTP_HOST']) ? preg_replace('/^www./', '', strtolower($_SERVER['HTTP_HOST'])) : "default"; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | if ($securityKey != '') { |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | |
69 | 69 | $securityKey = $this->cleanFileName($securityKey); |
70 | 70 | |
71 | - $full_path = rtrim($path, '/') .'/' . $securityKey; |
|
71 | + $full_path = rtrim($path, '/') . '/' . $securityKey; |
|
72 | 72 | $full_pathx = md5($full_path); |
73 | 73 | |
74 | 74 | |
75 | - if (!isset($this->tmp[ $full_pathx ])) { |
|
75 | + if (!isset($this->tmp[$full_pathx])) { |
|
76 | 76 | |
77 | 77 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
78 | 78 | if (!@file_exists($full_path)) { |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - $this->tmp[ $full_pathx ] = true; |
|
100 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
99 | + $this->tmp[$full_pathx] = true; |
|
100 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | return realpath($full_path); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | $path = $this->getFileDir(); |
144 | 144 | |
145 | - if($keyword === false) |
|
145 | + if ($keyword === false) |
|
146 | 146 | { |
147 | 147 | return $path; |
148 | 148 | } |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function setChmodAuto() |
173 | 173 | { |
174 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
174 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
175 | 175 | return 0777; |
176 | 176 | } else { |
177 | - return $this->config[ 'default_chmod' ]; |
|
177 | + return $this->config['default_chmod']; |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | public function removeTag($tagName) |
350 | 350 | { |
351 | 351 | if (($key = array_search($tagName, $this->tags)) !== false) { |
352 | - unset($this->tags[ $key ]); |
|
352 | + unset($this->tags[$key]); |
|
353 | 353 | $this->removedTags[] = $tagName; |
354 | 354 | } |
355 | 355 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | final public function __debugInfo() |
393 | 393 | { |
394 | 394 | $info = get_object_vars($this); |
395 | - $info[ 'driver' ] = 'object(' . get_class($info[ 'driver' ]) . ')'; |
|
395 | + $info['driver'] = 'object(' . get_class($info['driver']) . ')'; |
|
396 | 396 | |
397 | 397 | return (array) $info; |
398 | 398 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function driverConnect() |
128 | 128 | { |
129 | - $server = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : [ |
|
129 | + $server = isset($this->config['redis']) ? $this->config['redis'] : [ |
|
130 | 130 | 'host' => '127.0.0.1', |
131 | 131 | 'port' => '6379', |
132 | 132 | 'password' => '', |
@@ -134,32 +134,32 @@ discard block |
||
134 | 134 | ]; |
135 | 135 | |
136 | 136 | $config = [ |
137 | - 'host' => $server[ 'host' ], |
|
137 | + 'host' => $server['host'], |
|
138 | 138 | ]; |
139 | 139 | |
140 | - $port = isset($server[ 'port' ]) ? $server[ 'port' ] : ''; |
|
140 | + $port = isset($server['port']) ? $server['port'] : ''; |
|
141 | 141 | if ($port != '') { |
142 | - $config[ 'port' ] = $port; |
|
142 | + $config['port'] = $port; |
|
143 | 143 | } |
144 | 144 | |
145 | - $password = isset($server[ 'password' ]) ? $server[ 'password' ] : ''; |
|
145 | + $password = isset($server['password']) ? $server['password'] : ''; |
|
146 | 146 | if ($password != '') { |
147 | - $config[ 'password' ] = $password; |
|
147 | + $config['password'] = $password; |
|
148 | 148 | } |
149 | 149 | |
150 | - $database = isset($server[ 'database' ]) ? $server[ 'database' ] : ''; |
|
150 | + $database = isset($server['database']) ? $server['database'] : ''; |
|
151 | 151 | if ($database != '') { |
152 | - $config[ 'database' ] = $database; |
|
152 | + $config['database'] = $database; |
|
153 | 153 | } |
154 | 154 | |
155 | - $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : ''; |
|
155 | + $timeout = isset($server['timeout']) ? $server['timeout'] : ''; |
|
156 | 156 | if ($timeout != '') { |
157 | - $config[ 'timeout' ] = $timeout; |
|
157 | + $config['timeout'] = $timeout; |
|
158 | 158 | } |
159 | 159 | |
160 | - $read_write_timeout = isset($server[ 'read_write_timeout' ]) ? $server[ 'read_write_timeout' ] : ''; |
|
160 | + $read_write_timeout = isset($server['read_write_timeout']) ? $server['read_write_timeout'] : ''; |
|
161 | 161 | if ($read_write_timeout != '') { |
162 | - $config[ 'read_write_timeout' ] = $read_write_timeout; |
|
162 | + $config['read_write_timeout'] = $read_write_timeout; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $this->instance = new PredisClient($config); |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | public function driverConnect() |
128 | 128 | { |
129 | 129 | $server = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : [ |
130 | - 'host' => '127.0.0.1', |
|
131 | - 'port' => '6379', |
|
132 | - 'password' => '', |
|
133 | - 'database' => '', |
|
130 | + 'host' => '127.0.0.1', |
|
131 | + 'port' => '6379', |
|
132 | + 'password' => '', |
|
133 | + 'database' => '', |
|
134 | 134 | ]; |
135 | 135 | |
136 | 136 | $config = [ |
137 | - 'host' => $server[ 'host' ], |
|
137 | + 'host' => $server[ 'host' ], |
|
138 | 138 | ]; |
139 | 139 | |
140 | 140 | $port = isset($server[ 'port' ]) ? $server[ 'port' ] : ''; |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | public function getStats() |
197 | 197 | { |
198 | 198 | return (new driverStatistic()) |
199 | - ->setRawData($this->instance->info()) |
|
200 | - ->setSize(0) |
|
201 | - ->setInfo(''); |
|
199 | + ->setRawData($this->instance->info()) |
|
200 | + ->setSize(0) |
|
201 | + ->setInfo(''); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | \ No newline at end of file |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->instance = new MemcacheSoftware(); |
53 | 53 | $this->driverConnect(); |
54 | 54 | |
55 | - if (array_key_exists('compress_data', $config) && $config[ 'compress_data' ] === true) { |
|
55 | + if (array_key_exists('compress_data', $config) && $config['compress_data'] === true) { |
|
56 | 56 | $this->memcacheFlags = MEMCACHE_COMPRESSED; |
57 | 57 | } |
58 | 58 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function driverConnect() |
132 | 132 | { |
133 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
133 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
134 | 134 | if (count($servers) < 1) { |
135 | 135 | $servers = [ |
136 | 136 | ['127.0.0.1', 11211], |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | foreach ($servers as $server) { |
141 | 141 | try { |
142 | - if (!$this->instance->addserver($server[ 0 ], $server[ 1 ])) { |
|
142 | + if (!$this->instance->addserver($server[0], $server[1])) { |
|
143 | 143 | $this->fallback = true; |
144 | 144 | } |
145 | 145 | } catch (\Exception $e) { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
132 | 132 | if (count($servers) < 1) { |
133 | 133 | $servers = [ |
134 | - ['127.0.0.1', 11211], |
|
134 | + ['127.0.0.1', 11211], |
|
135 | 135 | ]; |
136 | 136 | } |
137 | 137 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | $stats = (array) $this->instance->getstats(); |
179 | 179 | $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
180 | 180 | return (new driverStatistic()) |
181 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
182 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
183 | - ->setRawData($stats) |
|
184 | - ->setSize($stats['bytes']); |
|
181 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
182 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
183 | + ->setRawData($stats) |
|
184 | + ->setSize($stats['bytes']); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | \ No newline at end of file |
@@ -122,11 +122,11 @@ |
||
122 | 122 | } else { |
123 | 123 | $this->instance = $this->instance ?: new RedisClient(); |
124 | 124 | |
125 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
126 | - $port = isset($this->config[ 'port' ]) ? (int) $this->config[ 'port' ] : '6379'; |
|
127 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
128 | - $database = isset($this->config[ 'database' ]) ? $this->config[ 'database' ] : ''; |
|
129 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : ''; |
|
125 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
126 | + $port = isset($this->config['port']) ? (int) $this->config['port'] : '6379'; |
|
127 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
128 | + $database = isset($this->config['database']) ? $this->config['database'] : ''; |
|
129 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : ''; |
|
130 | 130 | |
131 | 131 | if (!$this->instance->connect($host, (int) $port, (int) $timeout)) { |
132 | 132 | return false; |
@@ -175,9 +175,9 @@ |
||
175 | 175 | $info = $this->instance->info(); |
176 | 176 | $date = (new \DateTime())->setTimestamp(time() - $info['uptime_in_seconds']); |
177 | 177 | return (new driverStatistic()) |
178 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
179 | - ->setRawData($info) |
|
180 | - ->setSize($info['used_memory']) |
|
181 | - ->setInfo(sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", $info['redis_version'], $date->format(DATE_RFC2822))); |
|
178 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
179 | + ->setRawData($info) |
|
180 | + ->setSize($info['used_memory']) |
|
181 | + ->setInfo(sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", $info['redis_version'], $date->format(DATE_RFC2822))); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | \ No newline at end of file |
@@ -42,7 +42,7 @@ |
||
42 | 42 | $this->driver->setItem($this); |
43 | 43 | } else { |
44 | 44 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', |
45 | - gettype($key))); |
|
45 | + gettype($key))); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $keyword = self::PREFIX . $item->getKey(); |
80 | 80 | $v = json_encode($this->driverPreWrap($item)); |
81 | 81 | |
82 | - if (isset($this->config[ 'limited_memory_each_object' ]) && strlen($v) > $this->config[ 'limited_memory_each_object' ]) { |
|
82 | + if (isset($this->config['limited_memory_each_object']) && strlen($v) > $this->config['limited_memory_each_object']) { |
|
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | // return null if no caching |
101 | 101 | // return value if in caching |
102 | 102 | $keyword = self::PREFIX . $key; |
103 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ], true)) : false; |
|
103 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword], true)) : false; |
|
104 | 104 | |
105 | 105 | if ($x == false) { |
106 | 106 | return null; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | { |
122 | 122 | $this->driverConnect(); |
123 | 123 | $keyword = self::PREFIX . $key; |
124 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ])->t) : false; |
|
124 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword])->t) : false; |
|
125 | 125 | |
126 | 126 | return $x ? $x - time() : $x; |
127 | 127 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | if ($item instanceof Item) { |
140 | 140 | $this->driverConnect(); |
141 | 141 | $keyword = self::PREFIX . $item->getKey(); |
142 | - $_COOKIE[ $keyword ] = null; |
|
142 | + $_COOKIE[$keyword] = null; |
|
143 | 143 | |
144 | 144 | return @setcookie($keyword, null, -10); |
145 | 145 | } else { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $this->driverConnect(); |
157 | 157 | foreach ($_COOKIE as $keyword => $value) { |
158 | 158 | if (strpos($keyword, self::PREFIX) !== false) { |
159 | - $_COOKIE[ $keyword ] = null; |
|
159 | + $_COOKIE[$keyword] = null; |
|
160 | 160 | $result = @setcookie($keyword, null, -10); |
161 | 161 | if ($return !== false) { |
162 | 162 | $return = $result; |
@@ -128,7 +128,7 @@ |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * @return bool |
|
131 | + * @return boolean|null |
|
132 | 132 | */ |
133 | 133 | public function driverConnect() |
134 | 134 | { |
@@ -176,9 +176,9 @@ |
||
176 | 176 | public function getStats() |
177 | 177 | { |
178 | 178 | return (new driverStatistic()) |
179 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
180 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($this->getLeveldbFile())) |
|
181 | - ->setSize(Directory::dirSize($this->getLeveldbFile())); |
|
179 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
180 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($this->getLeveldbFile())) |
|
181 | + ->setSize(Directory::dirSize($this->getLeveldbFile())); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -140,8 +140,8 @@ |
||
140 | 140 | { |
141 | 141 | $stat = new driverStatistic(); |
142 | 142 | $stat->setInfo('A void info string') |
143 | - ->setSize(1337) |
|
144 | - ->setData('A void data string'); |
|
143 | + ->setSize(1337) |
|
144 | + ->setData('A void data string'); |
|
145 | 145 | |
146 | 146 | return $stat; |
147 | 147 | } |