@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | $config = isset($this->config[ 'predis' ]) ? $this->config[ 'predis' ] : []; |
| 127 | 127 | |
| 128 | 128 | $this->instance = new PredisClient(array_merge([ |
| 129 | - 'host' => '127.0.0.1', |
|
| 130 | - 'port' => 6379, |
|
| 131 | - 'password' => null, |
|
| 132 | - 'database' => null, |
|
| 129 | + 'host' => '127.0.0.1', |
|
| 130 | + 'port' => 6379, |
|
| 131 | + 'password' => null, |
|
| 132 | + 'database' => null, |
|
| 133 | 133 | ], $config)); |
| 134 | 134 | |
| 135 | 135 | return true; |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | $date = (isset($info['Server'][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info['Server'][ 'uptime_in_seconds' ]) : 'unknown date'); |
| 153 | 153 | |
| 154 | 154 | return (new DriverStatistic()) |
| 155 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 156 | - ->setRawData($info) |
|
| 157 | - ->setSize($size) |
|
| 158 | - ->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.", $version, $date->format(DATE_RFC2822))); |
|
| 155 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 156 | + ->setRawData($info) |
|
| 157 | + ->setSize($size) |
|
| 158 | + ->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.", $version, $date->format(DATE_RFC2822))); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | \ No newline at end of file |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | protected function driverConnect() |
| 125 | 125 | { |
| 126 | - $config = isset($this->config[ 'predis' ]) ? $this->config[ 'predis' ] : []; |
|
| 126 | + $config = isset($this->config['predis']) ? $this->config['predis'] : []; |
|
| 127 | 127 | |
| 128 | 128 | $this->instance = new PredisClient(array_merge([ |
| 129 | 129 | 'host' => '127.0.0.1', |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $info = $this->instance->info(); |
| 150 | 150 | $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
| 151 | 151 | $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
| 152 | - $date = (isset($info['Server'][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info['Server'][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
| 152 | + $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
| 153 | 153 | |
| 154 | 154 | return (new DriverStatistic()) |
| 155 | 155 | ->setData(implode(', ', array_keys($this->itemInstances))) |
@@ -132,12 +132,12 @@ discard block |
||
| 132 | 132 | $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
| 133 | 133 | if (count($servers) < 1) { |
| 134 | 134 | $servers = [ |
| 135 | - [ |
|
| 135 | + [ |
|
| 136 | 136 | 'host' =>'127.0.0.1', |
| 137 | 137 | 'port' => 11211, |
| 138 | 138 | 'sasl_user' => false, |
| 139 | 139 | 'sasl_password' => false |
| 140 | - ], |
|
| 140 | + ], |
|
| 141 | 141 | ]; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
| 175 | 175 | |
| 176 | 176 | return (new DriverStatistic()) |
| 177 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 178 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 179 | - ->setRawData($stats) |
|
| 180 | - ->setSize($stats[ 'bytes' ]); |
|
| 177 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 178 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 179 | + ->setRawData($stats) |
|
| 180 | + ->setSize($stats[ 'bytes' ]); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | \ No newline at end of file |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | } else { |
| 54 | 54 | $this->driverConnect(); |
| 55 | 55 | |
| 56 | - if (array_key_exists('compress_data', $config) && $config[ 'compress_data' ] === true) { |
|
| 56 | + if (array_key_exists('compress_data', $config) && $config['compress_data'] === true) { |
|
| 57 | 57 | $this->memcacheFlags = MEMCACHE_COMPRESSED; |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | protected function driverConnect() |
| 131 | 131 | { |
| 132 | 132 | $this->instance = new MemcacheSoftware(); |
| 133 | - $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
|
| 133 | + $servers = (!empty($this->config['servers']) && is_array($this->config['servers']) ? $this->config['servers'] : []); |
|
| 134 | 134 | if (count($servers) < 1) { |
| 135 | 135 | $servers = [ |
| 136 | 136 | [ |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | if (!$this->instance->addServer($server['host'], $server['port'])) { |
| 148 | 148 | $this->fallback = true; |
| 149 | 149 | } |
| 150 | - if(!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password'])){ |
|
| 151 | - $this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password']); |
|
| 150 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
| 151 | + $this->instance->setSaslAuthData($server['sasl_user'], $server['sasl_password']); |
|
| 152 | 152 | } |
| 153 | 153 | } catch (\Exception $e) { |
| 154 | 154 | $this->fallback = true; |
@@ -168,16 +168,16 @@ discard block |
||
| 168 | 168 | public function getStats() |
| 169 | 169 | { |
| 170 | 170 | $stats = (array) $this->instance->getstats(); |
| 171 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
| 172 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
| 173 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
| 171 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
| 172 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
| 173 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
| 174 | 174 | |
| 175 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
| 175 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
| 176 | 176 | |
| 177 | 177 | return (new DriverStatistic()) |
| 178 | 178 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 179 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 179 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
| 180 | 180 | ->setRawData($stats) |
| 181 | - ->setSize($stats[ 'bytes' ]); |
|
| 181 | + ->setSize($stats['bytes']); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | \ No newline at end of file |
@@ -163,9 +163,9 @@ |
||
| 163 | 163 | $date = (new \DateTime())->setTimestamp(time() - $info[ 'uptime_in_seconds' ]); |
| 164 | 164 | |
| 165 | 165 | return (new DriverStatistic()) |
| 166 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 167 | - ->setRawData($info) |
|
| 168 | - ->setSize($info[ 'used_memory' ]) |
|
| 169 | - ->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))); |
|
| 166 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 167 | + ->setRawData($info) |
|
| 168 | + ->setSize($info[ 'used_memory' ]) |
|
| 169 | + ->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))); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | \ No newline at end of file |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | } else { |
| 127 | 127 | $this->instance = $this->instance ?: new RedisClient(); |
| 128 | 128 | |
| 129 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 130 | - $port = isset($this->config[ 'port' ]) ? (int) $this->config[ 'port' ] : '6379'; |
|
| 131 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 132 | - $database = isset($this->config[ 'database' ]) ? $this->config[ 'database' ] : ''; |
|
| 133 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : ''; |
|
| 129 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 130 | + $port = isset($this->config['port']) ? (int) $this->config['port'] : '6379'; |
|
| 131 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 132 | + $database = isset($this->config['database']) ? $this->config['database'] : ''; |
|
| 133 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : ''; |
|
| 134 | 134 | |
| 135 | 135 | if (!$this->instance->connect($host, (int) $port, (int) $timeout)) { |
| 136 | 136 | return false; |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | // used_memory |
| 162 | 162 | $info = $this->instance->info(); |
| 163 | - $date = (new \DateTime())->setTimestamp(time() - $info[ 'uptime_in_seconds' ]); |
|
| 163 | + $date = (new \DateTime())->setTimestamp(time() - $info['uptime_in_seconds']); |
|
| 164 | 164 | |
| 165 | 165 | return (new DriverStatistic()) |
| 166 | 166 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 167 | 167 | ->setRawData($info) |
| 168 | - ->setSize($info[ 'used_memory' ]) |
|
| 169 | - ->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))); |
|
| 168 | + ->setSize($info['used_memory']) |
|
| 169 | + ->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))); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | \ No newline at end of file |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
| 141 | 141 | $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
| 142 | 142 | $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
| 143 | - [ |
|
| 143 | + [ |
|
| 144 | 144 | 'bucket' => 'default', |
| 145 | 145 | 'password' => '', |
| 146 | - ], |
|
| 146 | + ], |
|
| 147 | 147 | ]; |
| 148 | 148 | |
| 149 | 149 | $this->instance = new CouchbaseClient("couchbase://{$host}", $username, $password); |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | $info = $this->getBucket()->manager()->info(); |
| 194 | 194 | |
| 195 | 195 | return (new DriverStatistic()) |
| 196 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 197 | - ->setRawData($info) |
|
| 198 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 199 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData."); |
|
| 196 | + ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 197 | + ->setRawData($info) |
|
| 198 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 199 | + ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData."); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | \ No newline at end of file |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | } else { |
| 137 | 137 | |
| 138 | 138 | |
| 139 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 140 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 141 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 142 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
| 139 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 140 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 141 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 142 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
| 143 | 143 | [ |
| 144 | 144 | 'bucket' => 'default', |
| 145 | 145 | 'password' => '', |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | $this->instance = new CouchbaseClient("couchbase://{$host}", $username, $password); |
| 150 | 150 | |
| 151 | 151 | foreach ($buckets as $bucket) { |
| 152 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
| 153 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
| 152 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
| 153 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -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 phpFastCacheLogicException('A bucket instance with this name already exists.'); |
| 179 | 179 | } |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | $info = $this->getBucket()->manager()->info(); |
| 194 | 194 | |
| 195 | 195 | return (new DriverStatistic()) |
| 196 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 196 | + ->setSize($info['basicStats']['diskUsed']) |
|
| 197 | 197 | ->setRawData($info) |
| 198 | 198 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 199 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData."); |
|
| 199 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, 1) . "\n For more information see RawData."); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | \ No newline at end of file |
@@ -137,9 +137,9 @@ |
||
| 137 | 137 | $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]); |
| 138 | 138 | |
| 139 | 139 | return (new DriverStatistic()) |
| 140 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 141 | - ->setInfo(sprintf("The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), $stats[ 'num_entries' ])) |
|
| 142 | - ->setRawData($stats) |
|
| 143 | - ->setSize($stats[ 'mem_size' ]); |
|
| 140 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 141 | + ->setInfo(sprintf("The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), $stats[ 'num_entries' ])) |
|
| 142 | + ->setRawData($stats) |
|
| 143 | + ->setSize($stats[ 'mem_size' ]); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | \ No newline at end of file |
@@ -134,12 +134,12 @@ |
||
| 134 | 134 | public function getStats() |
| 135 | 135 | { |
| 136 | 136 | $stats = (array) apcu_cache_info(); |
| 137 | - $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]); |
|
| 137 | + $date = (new \DateTime())->setTimestamp($stats['start_time']); |
|
| 138 | 138 | |
| 139 | 139 | return (new DriverStatistic()) |
| 140 | 140 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 141 | - ->setInfo(sprintf("The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), $stats[ 'num_entries' ])) |
|
| 141 | + ->setInfo(sprintf("The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), $stats['num_entries'])) |
|
| 142 | 142 | ->setRawData($stats) |
| 143 | - ->setSize($stats[ 'mem_size' ]); |
|
| 143 | + ->setSize($stats['mem_size']); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | \ No newline at end of file |
@@ -132,12 +132,12 @@ discard block |
||
| 132 | 132 | $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
| 133 | 133 | if (count($servers) < 1) { |
| 134 | 134 | $servers = [ |
| 135 | - [ |
|
| 135 | + [ |
|
| 136 | 136 | 'host' =>'127.0.0.1', |
| 137 | 137 | 'port' => 11211, |
| 138 | 138 | 'sasl_user' => false, |
| 139 | 139 | 'sasl_password' => false |
| 140 | - ], |
|
| 140 | + ], |
|
| 141 | 141 | ]; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
| 175 | 175 | |
| 176 | 176 | return (new DriverStatistic()) |
| 177 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 178 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 179 | - ->setRawData($stats) |
|
| 180 | - ->setSize($stats[ 'bytes' ]); |
|
| 177 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 178 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 179 | + ->setRawData($stats) |
|
| 180 | + ->setSize($stats[ 'bytes' ]); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | \ No newline at end of file |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | protected function driverConnect() |
| 129 | 129 | { |
| 130 | 130 | $this->instance = new MemcachedSoftware(); |
| 131 | - $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
|
| 131 | + $servers = (!empty($this->config['servers']) && is_array($this->config['servers']) ? $this->config['servers'] : []); |
|
| 132 | 132 | if (count($servers) < 1) { |
| 133 | 133 | $servers = [ |
| 134 | 134 | [ |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | if (!$this->instance->addServer($server['host'], $server['port'])) { |
| 146 | 146 | $this->fallback = true; |
| 147 | 147 | } |
| 148 | - if(!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password'])){ |
|
| 149 | - $this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password']); |
|
| 148 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
| 149 | + $this->instance->setSaslAuthData($server['sasl_user'], $server['sasl_password']); |
|
| 150 | 150 | } |
| 151 | 151 | } catch (\Exception $e) { |
| 152 | 152 | $this->fallback = true; |
@@ -166,16 +166,16 @@ discard block |
||
| 166 | 166 | public function getStats() |
| 167 | 167 | { |
| 168 | 168 | $stats = (array) $this->instance->getStats(); |
| 169 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
| 170 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
| 171 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
| 169 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
| 170 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
| 171 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
| 172 | 172 | |
| 173 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
| 173 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
| 174 | 174 | |
| 175 | 175 | return (new DriverStatistic()) |
| 176 | 176 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 177 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 177 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
| 178 | 178 | ->setRawData($stats) |
| 179 | - ->setSize($stats[ 'bytes' ]); |
|
| 179 | + ->setSize($stats['bytes']); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | \ No newline at end of file |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | { |
| 44 | 44 | $cacheItem = $this->cacheInstance->getItem($cacheKey); |
| 45 | 45 | |
| 46 | - if(!$cacheItem->isHit()) |
|
| 46 | + if (!$cacheItem->isHit()) |
|
| 47 | 47 | { |
| 48 | 48 | $cacheItem->set($callback()); |
| 49 | 49 | $this->cacheInstance->save($cacheItem); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * @param \Psr\Cache\CacheItemInterface $item |
| 63 | - * @return mixed |
|
| 63 | + * @return boolean |
|
| 64 | 64 | * @throws phpFastCacheDriverException |
| 65 | 65 | * @throws phpFastCacheInvalidArgumentException |
| 66 | 66 | */ |
@@ -187,6 +187,7 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | + * @param string $docId |
|
| 190 | 191 | * @return string|null |
| 191 | 192 | */ |
| 192 | 193 | protected function getLatestDocumentRevision($docId) |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | $url .= $path; |
| 176 | 176 | |
| 177 | 177 | $this->instance = CouchDBClient::create([ |
| 178 | - 'dbname' => $this->getDatabaseName(), |
|
| 179 | - 'url' => $url, |
|
| 180 | - 'timeout' => $timeout |
|
| 178 | + 'dbname' => $this->getDatabaseName(), |
|
| 179 | + 'url' => $url, |
|
| 180 | + 'timeout' => $timeout |
|
| 181 | 181 | ]); |
| 182 | 182 | |
| 183 | 183 | $this->createDatabase(); |
@@ -194,10 +194,10 @@ discard block |
||
| 194 | 194 | $path = '/' . $this->getDatabaseName() . '/' . urlencode($docId); |
| 195 | 195 | |
| 196 | 196 | $response = $this->instance->getHttpClient()->request( |
| 197 | - 'HEAD', |
|
| 198 | - $path, |
|
| 199 | - null, |
|
| 200 | - false |
|
| 197 | + 'HEAD', |
|
| 198 | + $path, |
|
| 199 | + null, |
|
| 200 | + false |
|
| 201 | 201 | ); |
| 202 | 202 | if(!empty($response->headers['etag'])){ |
| 203 | 203 | return trim($response->headers['etag'], " '\"\t\n\r\0\x0B"); |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | $info = $this->instance->getDatabaseInfo(); |
| 252 | 252 | |
| 253 | 253 | return (new DriverStatistic()) |
| 254 | - ->setSize($info['sizes']['active']) |
|
| 255 | - ->setRawData($info) |
|
| 256 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 257 | - ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |
|
| 254 | + ->setSize($info['sizes']['active']) |
|
| 255 | + ->setRawData($info) |
|
| 256 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 257 | + ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | \ No newline at end of file |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | * Check for Cross-Driver type confusion |
| 71 | 71 | */ |
| 72 | 72 | if ($item instanceof Item) { |
| 73 | - try{ |
|
| 73 | + try { |
|
| 74 | 74 | $this->instance->putDocument(['data' => $this->encode($this->driverPreWrap($item))], $item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
| 75 | - }catch (CouchDBException $e){ |
|
| 75 | + } catch (CouchDBException $e) { |
|
| 76 | 76 | throw new phpFastCacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), null, $e); |
| 77 | 77 | } |
| 78 | 78 | return true; |
@@ -88,17 +88,17 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | protected function driverRead(CacheItemInterface $item) |
| 90 | 90 | { |
| 91 | - try{ |
|
| 91 | + try { |
|
| 92 | 92 | $response = $this->instance->findDocument($item->getEncodedKey()); |
| 93 | - }catch (CouchDBException $e){ |
|
| 93 | + } catch (CouchDBException $e) { |
|
| 94 | 94 | throw new phpFastCacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), null, $e); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if($response->status === 404 || empty($response->body['data'])){ |
|
| 97 | + if ($response->status === 404 || empty($response->body['data'])) { |
|
| 98 | 98 | return null; |
| 99 | - }else if($response->status === 200){ |
|
| 99 | + } else if ($response->status === 200) { |
|
| 100 | 100 | return $this->decode($response->body['data']); |
| 101 | - }else{ |
|
| 101 | + } else { |
|
| 102 | 102 | throw new phpFastCacheDriverException('Got unexpected HTTP status: ' . $response->status); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | * Check for Cross-Driver type confusion |
| 116 | 116 | */ |
| 117 | 117 | if ($item instanceof Item) { |
| 118 | - try{ |
|
| 118 | + try { |
|
| 119 | 119 | $this->instance->deleteDocument($item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
| 120 | - }catch (CouchDBException $e){ |
|
| 120 | + } catch (CouchDBException $e) { |
|
| 121 | 121 | throw new phpFastCacheDriverException('Got error while trying to delete a document: ' . $e->getMessage(), null, $e); |
| 122 | 122 | } |
| 123 | 123 | return true; |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | protected function driverClear() |
| 134 | 134 | { |
| 135 | - try{ |
|
| 135 | + try { |
|
| 136 | 136 | $this->instance->deleteDatabase($this->getDatabaseName()); |
| 137 | 137 | $this->createDatabase(); |
| 138 | - }catch (CouchDBException $e){ |
|
| 138 | + } catch (CouchDBException $e) { |
|
| 139 | 139 | throw new phpFastCacheDriverException('Got error while trying to delete and recreate the database: ' . $e->getMessage(), null, $e); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -152,19 +152,19 @@ discard block |
||
| 152 | 152 | if ($this->instance instanceof CouchdbClient) { |
| 153 | 153 | throw new phpFastCacheLogicException('Already connected to Couchdb server'); |
| 154 | 154 | } else { |
| 155 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 156 | - $ssl = isset($this->config[ 'ssl' ]) ? $this->config[ 'ssl' ] : false; |
|
| 157 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : 5984; |
|
| 158 | - $path = isset($this->config[ 'path' ]) ? $this->config[ 'path' ] : '/'; |
|
| 159 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 160 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 161 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 10; |
|
| 155 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 156 | + $ssl = isset($this->config['ssl']) ? $this->config['ssl'] : false; |
|
| 157 | + $port = isset($this->config['port']) ? $this->config['port'] : 5984; |
|
| 158 | + $path = isset($this->config['path']) ? $this->config['path'] : '/'; |
|
| 159 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 160 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 161 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 10; |
|
| 162 | 162 | |
| 163 | 163 | $url = ($ssl ? 'https://' : 'http://'); |
| 164 | - if($username) |
|
| 164 | + if ($username) |
|
| 165 | 165 | { |
| 166 | 166 | $url .= "{$username}"; |
| 167 | - if($password) |
|
| 167 | + if ($password) |
|
| 168 | 168 | { |
| 169 | 169 | $url .= ":{$password}"; |
| 170 | 170 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | null, |
| 200 | 200 | false |
| 201 | 201 | ); |
| 202 | - if(!empty($response->headers['etag'])){ |
|
| 202 | + if (!empty($response->headers['etag'])) { |
|
| 203 | 203 | return trim($response->headers['etag'], " '\"\t\n\r\0\x0B"); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | protected function getDatabaseName() |
| 213 | 213 | { |
| 214 | - return isset($this->config[ 'database' ]) ? $this->config[ 'database' ] : 'phpfastcache'; |
|
| 214 | + return isset($this->config['database']) ? $this->config['database'] : 'phpfastcache'; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | protected function createDatabase() |
| 221 | 221 | { |
| 222 | - if(!in_array($this->instance->getDatabase(), $this->instance->getAllDatabases(), true)){ |
|
| 222 | + if (!in_array($this->instance->getDatabase(), $this->instance->getAllDatabases(), true)) { |
|
| 223 | 223 | $this->instance->createDatabase($this->instance->getDatabase()); |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | if ($item instanceof Item) { |
| 73 | 73 | try{ |
| 74 | 74 | $this->instance->putDocument(['data' => $this->encode($this->driverPreWrap($item))], $item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
| 75 | - }catch (CouchDBException $e){ |
|
| 75 | + } catch (CouchDBException $e){ |
|
| 76 | 76 | throw new phpFastCacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), null, $e); |
| 77 | 77 | } |
| 78 | 78 | return true; |
@@ -90,15 +90,15 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | try{ |
| 92 | 92 | $response = $this->instance->findDocument($item->getEncodedKey()); |
| 93 | - }catch (CouchDBException $e){ |
|
| 93 | + } catch (CouchDBException $e){ |
|
| 94 | 94 | throw new phpFastCacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), null, $e); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | if($response->status === 404 || empty($response->body['data'])){ |
| 98 | 98 | return null; |
| 99 | - }else if($response->status === 200){ |
|
| 99 | + } else if($response->status === 200){ |
|
| 100 | 100 | return $this->decode($response->body['data']); |
| 101 | - }else{ |
|
| 101 | + } else{ |
|
| 102 | 102 | throw new phpFastCacheDriverException('Got unexpected HTTP status: ' . $response->status); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | if ($item instanceof Item) { |
| 118 | 118 | try{ |
| 119 | 119 | $this->instance->deleteDocument($item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
| 120 | - }catch (CouchDBException $e){ |
|
| 120 | + } catch (CouchDBException $e){ |
|
| 121 | 121 | throw new phpFastCacheDriverException('Got error while trying to delete a document: ' . $e->getMessage(), null, $e); |
| 122 | 122 | } |
| 123 | 123 | return true; |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | try{ |
| 136 | 136 | $this->instance->deleteDatabase($this->getDatabaseName()); |
| 137 | 137 | $this->createDatabase(); |
| 138 | - }catch (CouchDBException $e){ |
|
| 138 | + } catch (CouchDBException $e){ |
|
| 139 | 139 | throw new phpFastCacheDriverException('Got error while trying to delete and recreate the database: ' . $e->getMessage(), null, $e); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | try{ |
| 198 | 198 | self::$instances[ $instance ] = new $class($config); |
| 199 | 199 | self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
| 200 | - }catch(phpFastCacheDriverCheckException $e){ |
|
| 200 | + } catch(phpFastCacheDriverCheckException $e){ |
|
| 201 | 201 | if($config['fallback']){ |
| 202 | 202 | try{ |
| 203 | 203 | $fallback = self::standardizeDriverName($config['fallback']); |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | self::$instances[ $instance ] = new $class($config); |
| 207 | 207 | self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
| 208 | 208 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
| 209 | - }else{ |
|
| 209 | + } else{ |
|
| 210 | 210 | throw new phpFastCacheInvalidConfigurationException('The fallback driver cannot be the same than the default driver', 0, $e); |
| 211 | 211 | } |
| 212 | - }catch (phpFastCacheInvalidArgumentException $e){ |
|
| 212 | + } catch (phpFastCacheInvalidArgumentException $e){ |
|
| 213 | 213 | throw new phpFastCacheInvalidConfigurationException('Invalid fallback driver configuration', 0, $e); |
| 214 | 214 | } |
| 215 | - }else{ |
|
| 215 | + } else{ |
|
| 216 | 216 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | self::$config = array_merge(self::$config, $name); |
| 328 | 328 | } else if (is_string($name)){ |
| 329 | 329 | self::$config[ $name ] = $value; |
| 330 | - }else{ |
|
| 330 | + } else{ |
|
| 331 | 331 | throw new phpFastCacheInvalidArgumentException('Invalid variable type: $name'); |
| 332 | 332 | } |
| 333 | 333 | } |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | |
| 347 | 347 | /** |
| 348 | - * @return array |
|
| 348 | + * @return ExtendedCacheItemPoolInterface[] |
|
| 349 | 349 | */ |
| 350 | 350 | public static function getDefaultConfig() |
| 351 | 351 | { |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | /** |
| 356 | - * @return array |
|
| 356 | + * @return string[] |
|
| 357 | 357 | */ |
| 358 | 358 | public static function getStaticSystemDrivers() |
| 359 | 359 | { |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
| 383 | - * @return array |
|
| 383 | + * @return string[] |
|
| 384 | 384 | */ |
| 385 | 385 | public static function getStaticAllDrivers() |
| 386 | 386 | { |
@@ -64,101 +64,101 @@ discard block |
||
| 64 | 64 | /** |
| 65 | 65 | * Specify if the item must provide detailed creation/modification dates |
| 66 | 66 | */ |
| 67 | - 'itemDetailedDate' => false, |
|
| 67 | + 'itemDetailedDate' => false, |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Automatically attempt to fallback to temporary directory |
| 71 | 71 | * if the cache fails to write on the specified directory |
| 72 | 72 | */ |
| 73 | - 'autoTmpFallback' => false, |
|
| 73 | + 'autoTmpFallback' => false, |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Provide a secure file manipulation mechanism, |
| 77 | 77 | * on intensive usage the performance can be affected. |
| 78 | 78 | */ |
| 79 | - 'secureFileManipulation' => false, |
|
| 79 | + 'secureFileManipulation' => false, |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Ignore Symfony notice for Symfony project which |
| 83 | 83 | * do not makes use of PhpFastCache's Symfony Bundle |
| 84 | 84 | */ |
| 85 | - 'ignoreSymfonyNotice' => false, |
|
| 85 | + 'ignoreSymfonyNotice' => false, |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * Default time-to-live in second |
| 89 | 89 | */ |
| 90 | - 'defaultTtl' => 900, |
|
| 90 | + 'defaultTtl' => 900, |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * Default key hash function |
| 94 | 94 | * (md5 by default) |
| 95 | 95 | */ |
| 96 | - 'defaultKeyHashFunction' => '', |
|
| 96 | + 'defaultKeyHashFunction' => '', |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * The securityKey that will be used |
| 100 | 100 | * to create sub-directory |
| 101 | 101 | * (Files-based drivers only) |
| 102 | 102 | */ |
| 103 | - 'securityKey' => 'Auto', |
|
| 103 | + 'securityKey' => 'Auto', |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * Auto-generate .htaccess if it's missing |
| 107 | 107 | * (Files-based drivers only) |
| 108 | 108 | */ |
| 109 | - 'htaccess' => true, |
|
| 109 | + 'htaccess' => true, |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * Default files chmod |
| 113 | 113 | * 0777 recommended |
| 114 | 114 | * (Files-based drivers only) |
| 115 | 115 | */ |
| 116 | - 'default_chmod' => 0777, |
|
| 116 | + 'default_chmod' => 0777, |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * The path where we will writecache files |
| 120 | 120 | * default value if empty: sys_get_temp_dir() |
| 121 | 121 | * (Files-based drivers only) |
| 122 | 122 | */ |
| 123 | - 'path' => '', |
|
| 123 | + 'path' => '', |
|
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * Driver fallback in case of failure. |
| 127 | 127 | * Caution, in case of failure an E_WARNING |
| 128 | 128 | * error will always be raised |
| 129 | 129 | */ |
| 130 | - 'fallback' => false, |
|
| 130 | + 'fallback' => false, |
|
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | 133 | * Maximum size (bytes) of object store in memory |
| 134 | 134 | * (Memcache(d) drivers only) |
| 135 | 135 | */ |
| 136 | - 'limited_memory_each_object' => 4096, |
|
| 136 | + 'limited_memory_each_object' => 4096, |
|
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * Compress stored data, if the backend supports it |
| 140 | 140 | * (Memcache(d) drivers only) |
| 141 | 141 | */ |
| 142 | - 'compress_data' => false, |
|
| 142 | + 'compress_data' => false, |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Prevent cache slams when |
| 146 | 146 | * making use of heavy cache |
| 147 | 147 | * items |
| 148 | 148 | */ |
| 149 | - 'preventCacheSlams' => false, |
|
| 149 | + 'preventCacheSlams' => false, |
|
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * Cache slams timeout |
| 153 | 153 | * in seconds |
| 154 | 154 | */ |
| 155 | - 'cacheSlamsTimeout' => 15, |
|
| 155 | + 'cacheSlamsTimeout' => 15, |
|
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * Cache slams timeout |
| 159 | 159 | * in seconds |
| 160 | 160 | */ |
| 161 | - 'cacheFileExtension' => 'txt', |
|
| 161 | + 'cacheFileExtension' => 'txt', |
|
| 162 | 162 | |
| 163 | 163 | ]; |
| 164 | 164 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @var array |
| 169 | 169 | */ |
| 170 | 170 | protected static $safeFileExtensions = [ |
| 171 | - 'txt', 'cache', 'db', 'pfc' |
|
| 171 | + 'txt', 'cache', 'db', 'pfc' |
|
| 172 | 172 | ]; |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -373,24 +373,24 @@ discard block |
||
| 373 | 373 | public static function getStaticSystemDrivers() |
| 374 | 374 | { |
| 375 | 375 | return [ |
| 376 | - 'Apc', |
|
| 377 | - 'Apcu', |
|
| 378 | - 'Cassandra', |
|
| 379 | - 'Couchbase', |
|
| 380 | - 'Couchdb', |
|
| 381 | - 'Devnull', |
|
| 382 | - 'Files', |
|
| 383 | - 'Leveldb', |
|
| 384 | - 'Memcache', |
|
| 385 | - 'Memcached', |
|
| 386 | - 'Memstatic', |
|
| 387 | - 'Mongodb', |
|
| 388 | - 'Predis', |
|
| 389 | - 'Redis', |
|
| 390 | - 'Ssdb', |
|
| 391 | - 'Sqlite', |
|
| 392 | - 'Wincache', |
|
| 393 | - 'Xcache', |
|
| 376 | + 'Apc', |
|
| 377 | + 'Apcu', |
|
| 378 | + 'Cassandra', |
|
| 379 | + 'Couchbase', |
|
| 380 | + 'Couchdb', |
|
| 381 | + 'Devnull', |
|
| 382 | + 'Files', |
|
| 383 | + 'Leveldb', |
|
| 384 | + 'Memcache', |
|
| 385 | + 'Memcached', |
|
| 386 | + 'Memstatic', |
|
| 387 | + 'Mongodb', |
|
| 388 | + 'Predis', |
|
| 389 | + 'Redis', |
|
| 390 | + 'Ssdb', |
|
| 391 | + 'Sqlite', |
|
| 392 | + 'Wincache', |
|
| 393 | + 'Xcache', |
|
| 394 | 394 | ]; |
| 395 | 395 | } |
| 396 | 396 | |
@@ -400,9 +400,9 @@ discard block |
||
| 400 | 400 | public static function getStaticAllDrivers() |
| 401 | 401 | { |
| 402 | 402 | return array_merge(self::getStaticSystemDrivers(), [ |
| 403 | - 'Devtrue', |
|
| 404 | - 'Devfalse', |
|
| 405 | - 'Cookie', |
|
| 403 | + 'Devtrue', |
|
| 404 | + 'Devfalse', |
|
| 405 | + 'Cookie', |
|
| 406 | 406 | ]); |
| 407 | 407 | } |
| 408 | 408 | |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | } |
| 505 | 505 | if(!in_array($configValue, self::$safeFileExtensions)){ |
| 506 | 506 | throw new phpFastCacheInvalidConfigurationException( |
| 507 | - "{$configName} is not a safe extension, currently allowed extension: " . implode(', ', self::$safeFileExtensions) |
|
| 507 | + "{$configName} is not a safe extension, currently allowed extension: " . implode(', ', self::$safeFileExtensions) |
|
| 508 | 508 | ); |
| 509 | 509 | } |
| 510 | 510 | break; |
@@ -203,42 +203,42 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | $instance = crc32($driver . serialize($config)); |
| 206 | - if (!isset(self::$instances[ $instance ])) { |
|
| 206 | + if (!isset(self::$instances[$instance])) { |
|
| 207 | 207 | $badPracticeOmeter[$driver] = 1; |
| 208 | - if(!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')){ |
|
| 208 | + if (!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) { |
|
| 209 | 209 | trigger_error('A Symfony Bundle to make the PhpFastCache integration more easier is now available here: https://github.com/PHPSocialNetwork/phpfastcache-bundle', E_USER_NOTICE); |
| 210 | 210 | } |
| 211 | 211 | $class = self::getNamespacePath() . $driver . '\Driver'; |
| 212 | - try{ |
|
| 213 | - self::$instances[ $instance ] = new $class($config); |
|
| 214 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
| 215 | - }catch(phpFastCacheDriverCheckException $e){ |
|
| 216 | - if($config['fallback']){ |
|
| 217 | - try{ |
|
| 212 | + try { |
|
| 213 | + self::$instances[$instance] = new $class($config); |
|
| 214 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
| 215 | + } catch (phpFastCacheDriverCheckException $e) { |
|
| 216 | + if ($config['fallback']) { |
|
| 217 | + try { |
|
| 218 | 218 | $fallback = self::standardizeDriverName($config['fallback']); |
| 219 | - if($fallback !== $driver){ |
|
| 219 | + if ($fallback !== $driver) { |
|
| 220 | 220 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
| 221 | - self::$instances[ $instance ] = new $class($config); |
|
| 222 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
| 221 | + self::$instances[$instance] = new $class($config); |
|
| 222 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
| 223 | 223 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
| 224 | - }else{ |
|
| 224 | + } else { |
|
| 225 | 225 | throw new phpFastCacheInvalidConfigurationException('The fallback driver cannot be the same than the default driver', 0, $e); |
| 226 | 226 | } |
| 227 | - }catch (phpFastCacheInvalidArgumentException $e){ |
|
| 227 | + } catch (phpFastCacheInvalidArgumentException $e) { |
|
| 228 | 228 | throw new phpFastCacheInvalidConfigurationException('Invalid fallback driver configuration', 0, $e); |
| 229 | 229 | } |
| 230 | - }else{ |
|
| 230 | + } else { |
|
| 231 | 231 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | - } else if($badPracticeOmeter[$driver] >= 5){ |
|
| 234 | + } else if ($badPracticeOmeter[$driver] >= 5) { |
|
| 235 | 235 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
| 236 | 236 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | $badPracticeOmeter[$driver]++; |
| 240 | 240 | |
| 241 | - return self::$instances[ $instance ]; |
|
| 241 | + return self::$instances[$instance]; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | public static function __callStatic($name, $arguments) |
| 301 | 301 | { |
| 302 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
| 302 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
| 303 | 303 | |
| 304 | 304 | return self::getInstance($name, $options); |
| 305 | 305 | } |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | { |
| 341 | 341 | if (is_array($name)) { |
| 342 | 342 | self::$config = array_merge(self::$config, $name); |
| 343 | - } else if (is_string($name)){ |
|
| 344 | - self::$config[ $name ] = $value; |
|
| 345 | - }else{ |
|
| 343 | + } else if (is_string($name)) { |
|
| 344 | + self::$config[$name] = $value; |
|
| 345 | + } else { |
|
| 346 | 346 | throw new phpFastCacheInvalidArgumentException('Invalid variable type: $name'); |
| 347 | 347 | } |
| 348 | 348 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | */ |
| 414 | 414 | public static function standardizeDriverName($driverName) |
| 415 | 415 | { |
| 416 | - if(!is_string($driverName)){ |
|
| 416 | + if (!is_string($driverName)) { |
|
| 417 | 417 | throw new phpFastCacheInvalidArgumentException(sprintf('Expected $driverName to be a string got "%s" instead', gettype($driverName))); |
| 418 | 418 | } |
| 419 | 419 | return ucfirst(strtolower(trim($driverName))); |
@@ -428,81 +428,81 @@ discard block |
||
| 428 | 428 | protected static function validateConfig(array $config) |
| 429 | 429 | { |
| 430 | 430 | foreach ($config as $configName => $configValue) { |
| 431 | - switch($configName) |
|
| 431 | + switch ($configName) |
|
| 432 | 432 | { |
| 433 | 433 | case 'itemDetailedDate': |
| 434 | - if(!is_bool($configValue)){ |
|
| 434 | + if (!is_bool($configValue)) { |
|
| 435 | 435 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
| 436 | 436 | } |
| 437 | 437 | break; |
| 438 | 438 | case 'autoTmpFallback': |
| 439 | - if(!is_bool($configValue)){ |
|
| 439 | + if (!is_bool($configValue)) { |
|
| 440 | 440 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
| 441 | 441 | } |
| 442 | 442 | break; |
| 443 | 443 | case 'secureFileManipulation': |
| 444 | - if(!is_bool($configValue)){ |
|
| 444 | + if (!is_bool($configValue)) { |
|
| 445 | 445 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
| 446 | 446 | } |
| 447 | 447 | break; |
| 448 | 448 | case 'ignoreSymfonyNotice': |
| 449 | - if(!is_bool($configValue)){ |
|
| 449 | + if (!is_bool($configValue)) { |
|
| 450 | 450 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
| 451 | 451 | } |
| 452 | 452 | break; |
| 453 | 453 | case 'defaultTtl': |
| 454 | - if(!is_numeric($configValue)){ |
|
| 454 | + if (!is_numeric($configValue)) { |
|
| 455 | 455 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be numeric"); |
| 456 | 456 | } |
| 457 | 457 | break; |
| 458 | 458 | case 'defaultKeyHashFunction': |
| 459 | - if(!is_string($configValue) && !function_exists($configValue)){ |
|
| 459 | + if (!is_string($configValue) && !function_exists($configValue)) { |
|
| 460 | 460 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a valid function name string"); |
| 461 | 461 | } |
| 462 | 462 | break; |
| 463 | 463 | case 'securityKey': |
| 464 | - if(!is_string($configValue)){ |
|
| 464 | + if (!is_string($configValue)) { |
|
| 465 | 465 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a string"); |
| 466 | 466 | } |
| 467 | 467 | break; |
| 468 | 468 | case 'htaccess': |
| 469 | - if(!is_bool($configValue)){ |
|
| 469 | + if (!is_bool($configValue)) { |
|
| 470 | 470 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
| 471 | 471 | } |
| 472 | 472 | break; |
| 473 | 473 | case 'default_chmod': |
| 474 | - if(!is_int($configValue)){ |
|
| 474 | + if (!is_int($configValue)) { |
|
| 475 | 475 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be an integer"); |
| 476 | 476 | } |
| 477 | 477 | break; |
| 478 | 478 | case 'path': |
| 479 | - if(!is_string($configValue)){ |
|
| 479 | + if (!is_string($configValue)) { |
|
| 480 | 480 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a string"); |
| 481 | 481 | } |
| 482 | 482 | break; |
| 483 | 483 | case 'fallback': |
| 484 | - if(!is_bool($configValue)){ |
|
| 484 | + if (!is_bool($configValue)) { |
|
| 485 | 485 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
| 486 | 486 | } |
| 487 | 487 | break; |
| 488 | 488 | case 'limited_memory_each_object': |
| 489 | - if(!is_int($configValue)){ |
|
| 489 | + if (!is_int($configValue)) { |
|
| 490 | 490 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be an integer"); |
| 491 | 491 | } |
| 492 | 492 | break; |
| 493 | 493 | case 'compress_data': |
| 494 | - if(!is_bool($configValue)){ |
|
| 494 | + if (!is_bool($configValue)) { |
|
| 495 | 495 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
| 496 | 496 | } |
| 497 | 497 | break; |
| 498 | 498 | case 'cacheFileExtension': |
| 499 | - if(!is_string($configValue)){ |
|
| 499 | + if (!is_string($configValue)) { |
|
| 500 | 500 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
| 501 | 501 | } |
| 502 | - if(strpos($configValue, '.') !== false){ |
|
| 502 | + if (strpos($configValue, '.') !== false) { |
|
| 503 | 503 | throw new phpFastCacheInvalidConfigurationException("{$configName} cannot contain a dot \".\""); |
| 504 | 504 | } |
| 505 | - if(!in_array($configValue, self::$safeFileExtensions)){ |
|
| 505 | + if (!in_array($configValue, self::$safeFileExtensions)) { |
|
| 506 | 506 | throw new phpFastCacheInvalidConfigurationException( |
| 507 | 507 | "{$configName} is not a safe extension, currently allowed extension: " . implode(', ', self::$safeFileExtensions) |
| 508 | 508 | ); |