@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | |
95 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
95 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
96 | 96 | } else { |
97 | 97 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
98 | 98 | } |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | |
109 | 109 | if ($document) { |
110 | 110 | return [ |
111 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
112 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
113 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
111 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->bin), |
|
112 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_TIME_WRAPPER_INDEX]->sec), |
|
113 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->bin), |
|
114 | 114 | ]; |
115 | 115 | } else { |
116 | 116 | return null; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | if ($item instanceof Item) { |
131 | 131 | $deletionResult = (array) $this->getCollection()->remove(['_id' => $item->getKey()], ["w" => 1]); |
132 | 132 | |
133 | - return (int) $deletionResult[ 'ok' ] === 1 && !$deletionResult[ 'err' ]; |
|
133 | + return (int) $deletionResult['ok'] === 1 && !$deletionResult['err']; |
|
134 | 134 | } else { |
135 | 135 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
136 | 136 | } |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | if ($this->instance instanceof MongodbClient) { |
155 | 155 | throw new LogicException('Already connected to Mongodb server'); |
156 | 156 | } else { |
157 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
158 | - $port = isset($server[ 'port' ]) ? $server[ 'port' ] : '27017'; |
|
159 | - $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : 3; |
|
160 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
161 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
157 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
158 | + $port = isset($server['port']) ? $server['port'] : '27017'; |
|
159 | + $timeout = isset($server['timeout']) ? $server['timeout'] : 3; |
|
160 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
161 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
162 | 162 | |
163 | 163 | |
164 | 164 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | { |
192 | 192 | $document = $this->getCollection()->findOne(['_id' => $item->getKey()], [self::DRIVER_TIME_WRAPPER_INDEX /*'d', 'e'*/]); |
193 | 193 | if ($document) { |
194 | - return $document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec >= time(); |
|
194 | + return $document[self::DRIVER_TIME_WRAPPER_INDEX]->sec >= time(); |
|
195 | 195 | } else { |
196 | 196 | return null; |
197 | 197 | } |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | ]); |
222 | 222 | |
223 | 223 | $stats = (new driverStatistic()) |
224 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
225 | - ->setSize((int) $collStats[ 'size' ]) |
|
224 | + ->setInfo('MongoDB version ' . $serverStatus['version'] . ', Uptime (in days): ' . round($serverStatus['uptime'] / 86400, 1) . "\n For more information see RawData.") |
|
225 | + ->setSize((int) $collStats['size']) |
|
226 | 226 | ->setData(implode(', ', array_keys($this->itemInstances))) |
227 | 227 | ->setRawData([ |
228 | 228 | 'serverStatus' => $serverStatus, |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | |
139 | 139 | |
140 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
140 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
141 | 141 | //$port = isset($server[ 'port' ]) ? $server[ 'port' ] : '11211'; |
142 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
143 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
144 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
142 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
143 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
144 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
145 | 145 | [ |
146 | 146 | 'bucket' => 'default', |
147 | 147 | 'password' => '', |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password); |
152 | 152 | |
153 | 153 | foreach ($buckets as $bucket) { |
154 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
155 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
154 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
155 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function getBucket() |
164 | 164 | { |
165 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
165 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
174 | 174 | { |
175 | 175 | if (!array_key_exists($bucketName, $this->bucketInstances)) { |
176 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
176 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
177 | 177 | } else { |
178 | 178 | throw new \LogicException('A bucket instance with this name already exists.'); |
179 | 179 | } |
@@ -212,6 +212,6 @@ discard block |
||
212 | 212 | ->setSize($info['basicStats']['diskUsed']) |
213 | 213 | ->setRawData($info) |
214 | 214 | ->setData(implode(', ', array_keys($this->itemInstances))) |
215 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
215 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, 1) . "\n For more information see RawData."); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | \ No newline at end of file |
@@ -81,8 +81,7 @@ |
||
81 | 81 | return unlink($source); |
82 | 82 | } |
83 | 83 | |
84 | - $files = new RecursiveIteratorIterator |
|
85 | - ( |
|
84 | + $files = new RecursiveIteratorIterator( |
|
86 | 85 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
87 | 86 | RecursiveIteratorIterator::CHILD_FIRST |
88 | 87 | ); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'fallback' => 'files', //Fall back when old driver is not support |
57 | 57 | 'securityKey' => 'auto', |
58 | 58 | 'htaccess' => true, |
59 | - 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
59 | + 'path' => '', // if not set will be the value of sys_get_temp_dir() |
|
60 | 60 | "limited_memory_each_object" => 4096, // maximum size (bytes) of object store in memory |
61 | 61 | "compress_data" => false, // compress stored data, if the backend supports it |
62 | 62 | ]; |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | $instance = crc32($driver . serialize($config)); |
85 | - if (!isset(self::$instances[ $instance ])) { |
|
85 | + if (!isset(self::$instances[$instance])) { |
|
86 | 86 | $class = self::getNamespacePath() . $driver . '\Driver'; |
87 | - self::$instances[ $instance ] = new $class($config); |
|
87 | + self::$instances[$instance] = new $class($config); |
|
88 | 88 | } else { |
89 | 89 | // trigger_error('[' . $driver . '] Calling CacheManager::getInstance for already instanced drivers is a bad practice and have a significant impact on performances. |
90 | 90 | // See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
91 | 91 | } |
92 | 92 | |
93 | - return self::$instances[ $instance ]; |
|
93 | + return self::$instances[$instance]; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public static function __callStatic($name, $arguments) |
125 | 125 | { |
126 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
126 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
127 | 127 | |
128 | 128 | return self::getInstance($name, $options); |
129 | 129 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | if (is_array($name)) { |
166 | 166 | self::$config = array_merge(self::$config, $name); |
167 | 167 | } else { |
168 | - self::$config[ $name ] = $value; |
|
168 | + self::$config[$name] = $value; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key))); |
75 | 75 | } |
76 | 76 | |
77 | - return $this->itemInstances[ $key ]; |
|
77 | + return $this->itemInstances[$key]; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function setItem(CacheItemInterface $item) |
86 | 86 | { |
87 | 87 | if ($this->getClassNamespace() . '\\Item' === get_class($item)) { |
88 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
88 | + $this->itemInstances[$item->getKey()] = $item; |
|
89 | 89 | |
90 | 90 | return $this; |
91 | 91 | } else { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $collection = []; |
104 | 104 | foreach ($keys as $key) { |
105 | - $collection[ $key ] = $this->getItem($key); |
|
105 | + $collection[$key] = $this->getItem($key); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | return $collection; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | { |
144 | 144 | if ($this->hasItem($key) && $this->driverDelete($this->getItem($key))) { |
145 | 145 | CacheManager::$WriteHits++; |
146 | - unset($this->itemInstances[ $key ]); |
|
146 | + unset($this->itemInstances[$key]); |
|
147 | 147 | |
148 | 148 | return true; |
149 | 149 | } |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | public function save(CacheItemInterface $item) |
178 | 178 | { |
179 | 179 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
180 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
180 | + $this->itemInstances[$item->getKey()] = $item; |
|
181 | 181 | } |
182 | - if($this->driverWrite($item) && $this->driverWriteTags($item)) |
|
182 | + if ($this->driverWrite($item) && $this->driverWriteTags($item)) |
|
183 | 183 | { |
184 | 184 | CacheManager::$WriteHits++; |
185 | 185 | return true; |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | public function saveDeferred(CacheItemInterface $item) |
196 | 196 | { |
197 | 197 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
198 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
198 | + $this->itemInstances[$item->getKey()] = $item; |
|
199 | 199 | } |
200 | 200 | |
201 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
201 | + return $this->deferredList[$item->getKey()] = $item; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | foreach ($this->deferredList as $key => $item) { |
212 | 212 | $result = $this->save($item); |
213 | 213 | if ($return !== false) { |
214 | - unset($this->deferredList[ $key ]); |
|
214 | + unset($this->deferredList[$key]); |
|
215 | 215 | $return = $result; |
216 | 216 | } |
217 | 217 | } |
@@ -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 |