@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | use Phpfastcache\Core\Item\ExtendedCacheItemInterface; |
| 20 | 20 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 21 | 21 | use Phpfastcache\Exceptions\{ |
| 22 | - PhpfastcacheDriverCheckException, PhpfastcacheInvalidArgumentException, PhpfastcacheRootException, PhpfastcacheSimpleCacheException |
|
| 22 | + PhpfastcacheDriverCheckException, PhpfastcacheInvalidArgumentException, PhpfastcacheRootException, PhpfastcacheSimpleCacheException |
|
| 23 | 23 | }; |
| 24 | 24 | use Psr\SimpleCache\CacheInterface; |
| 25 | 25 | |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | try { |
| 78 | 78 | $cacheItem = $this->internalCacheInstance |
| 79 | - ->getItem($key) |
|
| 80 | - ->set($value); |
|
| 79 | + ->getItem($key) |
|
| 80 | + ->set($value); |
|
| 81 | 81 | if (\is_int($ttl) && $ttl <= 0) { |
| 82 | 82 | $cacheItem->expiresAt((new \DateTime('@0'))); |
| 83 | 83 | } elseif (\is_int($ttl) || $ttl instanceof \DateInterval) { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -declare(strict_types=1); |
|
| 14 | +declare(strict_types = 1); |
|
| 15 | 15 | |
| 16 | 16 | namespace Phpfastcache\Helper; |
| 17 | 17 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | public function getMultiple($keys, $default = null) |
| 126 | 126 | { |
| 127 | 127 | try { |
| 128 | - return array_map(function (ExtendedCacheItemInterface $item) { |
|
| 128 | + return array_map(function(ExtendedCacheItemInterface $item) { |
|
| 129 | 129 | return $item->get(); |
| 130 | 130 | }, $this->internalCacheInstance->getItems($keys)); |
| 131 | 131 | } catch (PhpfastcacheInvalidArgumentException $e) { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -declare(strict_types=1); |
|
| 14 | +declare(strict_types = 1); |
|
| 15 | 15 | |
| 16 | 16 | namespace Phpfastcache\Helper; |
| 17 | 17 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function __construct($testName) |
| 37 | 37 | { |
| 38 | - $this->printText('[PhpFastCache CORE v' . Api::getPhpFastCacheVersion() . Api::getPhpFastCacheGitHeadHash() . ']', true); |
|
| 38 | + $this->printText('[PhpFastCache CORE v' . Api::getPhpFastCacheVersion() . Api::getPhpFastCacheGitHeadHash() . ']', true); |
|
| 39 | 39 | $this->printText('[PhpFastCache API v' . Api::getVersion() . ']', true); |
| 40 | 40 | $this->printText('[PHP v' . PHP_VERSION . ']', true); |
| 41 | 41 | $this->printText("[Begin Test: '{$testName}']"); |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | * @param \Throwable $exception |
| 185 | 185 | */ |
| 186 | 186 | public function exceptionHandler(\Throwable $exception) { |
| 187 | - if($exception instanceof PhpfastcacheDriverCheckException){ |
|
| 187 | + if ($exception instanceof PhpfastcacheDriverCheckException) { |
|
| 188 | 188 | $this->printSkipText('A driver could not be initialized due to missing requirement: ' . $exception->getMessage()); |
| 189 | - }else{ |
|
| 189 | + } else { |
|
| 190 | 190 | $this->printFailText(sprintf( |
| 191 | 191 | 'Uncaught exception "%s" in "%s" line %d with message: "%s"', |
| 192 | 192 | \get_class($exception), |
@@ -186,7 +186,7 @@ |
||
| 186 | 186 | public function exceptionHandler(\Throwable $exception) { |
| 187 | 187 | if($exception instanceof PhpfastcacheDriverCheckException){ |
| 188 | 188 | $this->printSkipText('A driver could not be initialized due to missing requirement: ' . $exception->getMessage()); |
| 189 | - }else{ |
|
| 189 | + } else{ |
|
| 190 | 190 | $this->printFailText(sprintf( |
| 191 | 191 | 'Uncaught exception "%s" in "%s" line %d with message: "%s"', |
| 192 | 192 | \get_class($exception), |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | if(array_diff_key($array, get_object_vars($this))){ |
| 96 | 96 | throw new PhpfastcacheInvalidConfigurationException(sprintf( |
| 97 | - 'Invalid option(s) for the config %s: %s', |
|
| 98 | - static::class, |
|
| 99 | - implode(', ', array_keys(array_diff_key($array, get_object_vars($this)))) |
|
| 97 | + 'Invalid option(s) for the config %s: %s', |
|
| 98 | + static::class, |
|
| 99 | + implode(', ', array_keys(array_diff_key($array, get_object_vars($this)))) |
|
| 100 | 100 | )); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | $typeHintExpected = ($parameter instanceof \ReflectionParameter ? ($parameter->getType() === 'object' ? $parameter->getClass() : $parameter->getType()) : 'Unknown type'); |
| 129 | 129 | |
| 130 | 130 | throw new PhpfastcacheInvalidConfigurationException(sprintf( |
| 131 | - 'Invalid type hint found for "%s", expected "%s" got "%s"', |
|
| 132 | - lcfirst(substr($method, 3)), |
|
| 133 | - $typeHintExpected, |
|
| 134 | - $typeHintGot |
|
| 131 | + 'Invalid type hint found for "%s", expected "%s" got "%s"', |
|
| 132 | + lcfirst(substr($method, 3)), |
|
| 133 | + $typeHintExpected, |
|
| 134 | + $typeHintGot |
|
| 135 | 135 | )); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -396,10 +396,10 @@ discard block |
||
| 396 | 396 | * by opening a pull request :) |
| 397 | 397 | */ |
| 398 | 398 | static $safeFileExtensions = [ |
| 399 | - 'txt', |
|
| 400 | - 'cache', |
|
| 401 | - 'db', |
|
| 402 | - 'pfc', |
|
| 399 | + 'txt', |
|
| 400 | + 'cache', |
|
| 401 | + 'db', |
|
| 402 | + 'pfc', |
|
| 403 | 403 | ]; |
| 404 | 404 | |
| 405 | 405 | if (\strpos($cacheFileExtension, '.') !== false) { |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | } |
| 408 | 408 | if (!\in_array($cacheFileExtension, $safeFileExtensions, true)) { |
| 409 | 409 | throw new PhpfastcacheInvalidConfigurationException( |
| 410 | - "{$cacheFileExtension} is not a safe extension, currently allowed extension: " . \implode(', ', $safeFileExtensions) |
|
| 410 | + "{$cacheFileExtension} is not a safe extension, currently allowed extension: " . \implode(', ', $safeFileExtensions) |
|
| 411 | 411 | ); |
| 412 | 412 | } |
| 413 | 413 | |
@@ -86,33 +86,33 @@ discard block |
||
| 86 | 86 | public function __construct(...$args) |
| 87 | 87 | { |
| 88 | 88 | parent::__construct(...$args); |
| 89 | - $array =& $this->getArray(); |
|
| 89 | + $array = & $this->getArray(); |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * Detect unwanted keys and throw an exception. |
| 93 | 93 | * No more kidding now, it's 21th century. |
| 94 | 94 | */ |
| 95 | - if(array_diff_key($array, get_object_vars($this))){ |
|
| 95 | + if (array_diff_key($array, get_object_vars($this))) { |
|
| 96 | 96 | throw new PhpfastcacheInvalidConfigurationException(sprintf( |
| 97 | 97 | 'Invalid option(s) for the config %s: %s', |
| 98 | 98 | static::class, |
| 99 | - implode(', ', array_keys(array_diff_key($array, get_object_vars($this)))) |
|
| 99 | + implode(', ', array_keys(array_diff_key($array, get_object_vars($this)))) |
|
| 100 | 100 | )); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | foreach (get_object_vars($this) as $property => $value) { |
| 104 | 104 | |
| 105 | - if(array_key_exists($property, $array)){ |
|
| 106 | - $this->$property = &$array[ $property ]; |
|
| 107 | - }else{ |
|
| 108 | - $array[ $property ] = &$this->$property; |
|
| 105 | + if (array_key_exists($property, $array)) { |
|
| 106 | + $this->$property = &$array[$property]; |
|
| 107 | + } else { |
|
| 108 | + $array[$property] = &$this->$property; |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | foreach (get_class_methods($this) as $method) { |
| 113 | - if(strpos($method, 'set') === 0){ |
|
| 113 | + if (strpos($method, 'set') === 0) { |
|
| 114 | 114 | $value = null; |
| 115 | - try{ |
|
| 115 | + try { |
|
| 116 | 116 | /** |
| 117 | 117 | * We use property instead of getter |
| 118 | 118 | * because of is/get conditions and |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | $value = $this->{lcfirst(substr($method, 3))}; |
| 123 | 123 | $this->{$method}($value); |
| 124 | - }catch(\TypeError $e){ |
|
| 124 | + } catch (\TypeError $e) { |
|
| 125 | 125 | $typeHintGot = \is_object($value) ? \get_class($value) : \gettype($value); |
| 126 | 126 | $reflectionMethod = new \ReflectionMethod($this, $method); |
| 127 | 127 | $parameter = $reflectionMethod->getParameters()[0] ?? null; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | use Phpfastcache\Config\ConfigurationOption; |
| 19 | 19 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 20 | 20 | use Phpfastcache\Exceptions\{ |
| 21 | - PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException |
|
| 21 | + PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException |
|
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | if (is_array($config)) { |
| 100 | 100 | $config = new ConfigurationOption($config); |
| 101 | 101 | trigger_error( |
| 102 | - 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
| 103 | - E_USER_DEPRECATED |
|
| 102 | + 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
| 103 | + E_USER_DEPRECATED |
|
| 104 | 104 | ); |
| 105 | 105 | }elseif ($config === null){ |
| 106 | 106 | $config = self::getDefaultConfig(); |
@@ -291,27 +291,27 @@ discard block |
||
| 291 | 291 | * @todo Reflection reader |
| 292 | 292 | */ |
| 293 | 293 | return [ |
| 294 | - 'Apc', |
|
| 295 | - 'Apcu', |
|
| 296 | - 'Cassandra', |
|
| 297 | - 'Couchbase', |
|
| 298 | - 'Couchdb', |
|
| 299 | - 'Devnull', |
|
| 300 | - 'Files', |
|
| 301 | - 'Leveldb', |
|
| 302 | - 'Memcache', |
|
| 303 | - 'Memcached', |
|
| 304 | - 'Memstatic', |
|
| 305 | - 'Mongodb', |
|
| 306 | - 'Predis', |
|
| 307 | - 'Redis', |
|
| 308 | - 'Riak', |
|
| 309 | - 'Ssdb', |
|
| 310 | - 'Sqlite', |
|
| 311 | - 'Wincache', |
|
| 312 | - 'Xcache', |
|
| 313 | - 'Zenddisk', |
|
| 314 | - 'Zendshm', |
|
| 294 | + 'Apc', |
|
| 295 | + 'Apcu', |
|
| 296 | + 'Cassandra', |
|
| 297 | + 'Couchbase', |
|
| 298 | + 'Couchdb', |
|
| 299 | + 'Devnull', |
|
| 300 | + 'Files', |
|
| 301 | + 'Leveldb', |
|
| 302 | + 'Memcache', |
|
| 303 | + 'Memcached', |
|
| 304 | + 'Memstatic', |
|
| 305 | + 'Mongodb', |
|
| 306 | + 'Predis', |
|
| 307 | + 'Redis', |
|
| 308 | + 'Riak', |
|
| 309 | + 'Ssdb', |
|
| 310 | + 'Sqlite', |
|
| 311 | + 'Wincache', |
|
| 312 | + 'Xcache', |
|
| 313 | + 'Zenddisk', |
|
| 314 | + 'Zendshm', |
|
| 315 | 315 | ]; |
| 316 | 316 | } |
| 317 | 317 | |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | * @todo Reflection reader |
| 325 | 325 | */ |
| 326 | 326 | return \array_merge(self::getStaticSystemDrivers(), [ |
| 327 | - 'Devtrue', |
|
| 328 | - 'Devfalse', |
|
| 329 | - 'Cookie', |
|
| 327 | + 'Devtrue', |
|
| 328 | + 'Devfalse', |
|
| 329 | + 'Cookie', |
|
| 330 | 330 | ]); |
| 331 | 331 | } |
| 332 | 332 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -declare(strict_types=1); |
|
| 14 | +declare(strict_types = 1); |
|
| 15 | 15 | |
| 16 | 16 | namespace Phpfastcache; |
| 17 | 17 | |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
| 103 | 103 | E_USER_DEPRECATED |
| 104 | 104 | ); |
| 105 | - }elseif ($config === null){ |
|
| 105 | + }elseif ($config === null) { |
|
| 106 | 106 | $config = self::getDefaultConfig(); |
| 107 | - }else if(!($config instanceof ConfigurationOption)){ |
|
| 107 | + } else if (!($config instanceof ConfigurationOption)) { |
|
| 108 | 108 | throw new PhpfastcacheInvalidArgumentException(sprintf('Unsupported config type: %s', gettype($config))); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $instance = $instanceId ?: md5($driver . \serialize($config->toArray())); |
| 118 | 118 | |
| 119 | - if (!isset(self::$instances[ $instance ])) { |
|
| 120 | - $badPracticeOmeter[ $driver ] = 1; |
|
| 119 | + if (!isset(self::$instances[$instance])) { |
|
| 120 | + $badPracticeOmeter[$driver] = 1; |
|
| 121 | 121 | $driverClass = self::getNamespacePath() . $driver . '\Driver'; |
| 122 | 122 | try { |
| 123 | 123 | if (\class_exists($driverClass)) { |
| 124 | 124 | $configClass = $driverClass::getConfigClass(); |
| 125 | - self::$instances[ $instance ] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
| 126 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
| 125 | + self::$instances[$instance] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
| 126 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
| 127 | 127 | } else { |
| 128 | 128 | throw new PhpfastcacheDriverNotFoundException(sprintf('The driver "%s" does not exists', $driver)); |
| 129 | 129 | } |
@@ -142,14 +142,14 @@ discard block |
||
| 142 | 142 | throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | - } else if ($badPracticeOmeter[ $driver ] >= 2) { |
|
| 145 | + } else if ($badPracticeOmeter[$driver] >= 2) { |
|
| 146 | 146 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
| 147 | 147 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $badPracticeOmeter[ $driver ]++; |
|
| 150 | + $badPracticeOmeter[$driver]++; |
|
| 151 | 151 | |
| 152 | - return self::$instances[ $instance ]; |
|
| 152 | + return self::$instances[$instance]; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string'); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if (isset(self::$instances[ $instanceId ])) { |
|
| 170 | - return self::$instances[ $instanceId ]; |
|
| 169 | + if (isset(self::$instances[$instanceId])) { |
|
| 170 | + return self::$instances[$instanceId]; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | throw new PhpfastcacheInstanceNotFoundException(sprintf('Instance ID %s not found', $instanceId)); |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public static function __callStatic($name, $arguments) |
| 236 | 236 | { |
| 237 | - $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []); |
|
| 237 | + $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []); |
|
| 238 | 238 | |
| 239 | 239 | return self::getInstance($name, $options); |
| 240 | 240 | } |
@@ -102,9 +102,9 @@ |
||
| 102 | 102 | 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
| 103 | 103 | E_USER_DEPRECATED |
| 104 | 104 | ); |
| 105 | - }elseif ($config === null){ |
|
| 105 | + } elseif ($config === null){ |
|
| 106 | 106 | $config = self::getDefaultConfig(); |
| 107 | - }else if(!($config instanceof ConfigurationOption)){ |
|
| 107 | + } else if(!($config instanceof ConfigurationOption)){ |
|
| 108 | 108 | throw new PhpfastcacheInvalidArgumentException(sprintf('Unsupported config type: %s', gettype($config))); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface}; |
| 19 | 19 | use Phpfastcache\Entities\DriverStatistic; |
| 20 | 20 | use Phpfastcache\Exceptions\{ |
| 21 | - PhpfastcacheInvalidArgumentException, PhpfastcacheDriverCheckException, PhpfastcacheDriverException |
|
| 21 | + PhpfastcacheInvalidArgumentException, PhpfastcacheDriverCheckException, PhpfastcacheDriverException |
|
| 22 | 22 | }; |
| 23 | 23 | use Phpfastcache\Util\ArrayObject; |
| 24 | 24 | use phpssdb\Core\{SimpleSSDB, SSDBException}; |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | * using hardcoded offset of pair key-value :-( |
| 148 | 148 | */ |
| 149 | 149 | $stat->setInfo(\sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ])) |
| 150 | - ->setRawData($info) |
|
| 151 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 152 | - ->setSize($this->instance->dbsize()); |
|
| 150 | + ->setRawData($info) |
|
| 151 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 152 | + ->setSize($this->instance->dbsize()); |
|
| 153 | 153 | |
| 154 | 154 | return $stat; |
| 155 | 155 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 20 | 20 | use Phpfastcache\Drivers\Ssdb\Driver as SsdbDriver; |
| 21 | 21 | use Phpfastcache\Exceptions\{ |
| 22 | - PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 22 | + PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 23 | 23 | }; |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface}; |
| 18 | 18 | use Phpfastcache\Entities\DriverStatistic; |
| 19 | 19 | use Phpfastcache\Exceptions\{ |
| 20 | - PhpfastcacheInvalidArgumentException |
|
| 20 | + PhpfastcacheInvalidArgumentException |
|
| 21 | 21 | }; |
| 22 | 22 | use Psr\Cache\CacheItemInterface; |
| 23 | 23 | |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | $stats = (array)zend_shm_cache_info(); |
| 133 | 133 | return (new DriverStatistic()) |
| 134 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 135 | - ->setInfo(\sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats[ 'items_total' ])) |
|
| 136 | - ->setRawData($stats) |
|
| 137 | - ->setSize($stats[ 'memory_total' ]); |
|
| 134 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 135 | + ->setInfo(\sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats[ 'items_total' ])) |
|
| 136 | + ->setRawData($stats) |
|
| 137 | + ->setSize($stats[ 'memory_total' ]); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | \ No newline at end of file |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 19 | 19 | use Phpfastcache\Drivers\Zendshm\Driver as ZendSHMDriver; |
| 20 | 20 | use Phpfastcache\Exceptions\{ |
| 21 | - PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 21 | + PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | namespace Phpfastcache\Drivers\Couchdb; |
| 17 | 17 | |
| 18 | 18 | use Doctrine\CouchDB\{ |
| 19 | - CouchDBClient as CouchdbClient, CouchDBException |
|
| 19 | + CouchDBClient as CouchdbClient, CouchDBException |
|
| 20 | 20 | }; |
| 21 | 21 | use Phpfastcache\Config\ConfigurationOption; |
| 22 | 22 | use Phpfastcache\Core\Pool\{ |
| 23 | - DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
| 23 | + DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
| 24 | 24 | }; |
| 25 | 25 | use Phpfastcache\Exceptions\{ |
| 26 | - PhpfastcacheDriverException, PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 26 | + PhpfastcacheDriverException, PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 27 | 27 | }; |
| 28 | 28 | use Phpfastcache\Entities\DriverStatistic; |
| 29 | 29 | use Phpfastcache\Util\ArrayObject; |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | $url .= $clientConfig[ 'path' ]; |
| 76 | 76 | |
| 77 | 77 | $this->instance = CouchDBClient::create([ |
| 78 | - 'dbname' => $this->getDatabaseName(), |
|
| 79 | - 'url' => $url, |
|
| 80 | - 'timeout' => $clientConfig[ 'timeout' ], |
|
| 78 | + 'dbname' => $this->getDatabaseName(), |
|
| 79 | + 'url' => $url, |
|
| 80 | + 'timeout' => $clientConfig[ 'timeout' ], |
|
| 81 | 81 | ]); |
| 82 | 82 | |
| 83 | 83 | $this->createDatabase(); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | if ($item instanceof Item) { |
| 123 | 123 | try { |
| 124 | 124 | $this->instance->putDocument(['data' => $this->encode($this->driverPreWrap($item))], $item->getEncodedKey(), |
| 125 | - $this->getLatestDocumentRevision($item->getEncodedKey())); |
|
| 125 | + $this->getLatestDocumentRevision($item->getEncodedKey())); |
|
| 126 | 126 | } catch (CouchDBException $e) { |
| 127 | 127 | throw new PhpfastcacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), null, $e); |
| 128 | 128 | } |
@@ -179,10 +179,10 @@ discard block |
||
| 179 | 179 | $path = '/' . $this->getDatabaseName() . '/' . urlencode($docId); |
| 180 | 180 | |
| 181 | 181 | $response = $this->instance->getHttpClient()->request( |
| 182 | - 'HEAD', |
|
| 183 | - $path, |
|
| 184 | - null, |
|
| 185 | - false |
|
| 182 | + 'HEAD', |
|
| 183 | + $path, |
|
| 184 | + null, |
|
| 185 | + false |
|
| 186 | 186 | ); |
| 187 | 187 | if (!empty($response->headers[ 'etag' ])) { |
| 188 | 188 | return \trim($response->headers[ 'etag' ], " '\"\t\n\r\0\x0B"); |
@@ -236,9 +236,9 @@ discard block |
||
| 236 | 236 | $info = $this->instance->getDatabaseInfo(); |
| 237 | 237 | |
| 238 | 238 | return (new DriverStatistic()) |
| 239 | - ->setSize($info[ 'sizes' ][ 'active' ]) |
|
| 240 | - ->setRawData($info) |
|
| 241 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 242 | - ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |
|
| 239 | + ->setSize($info[ 'sizes' ][ 'active' ]) |
|
| 240 | + ->setRawData($info) |
|
| 241 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 242 | + ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |
|
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -declare(strict_types=1); |
|
| 14 | +declare(strict_types = 1); |
|
| 15 | 15 | |
| 16 | 16 | namespace Phpfastcache\Drivers\Couchdb; |
| 17 | 17 | |
@@ -62,22 +62,22 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $clientConfig = $this->getConfig(); |
| 64 | 64 | |
| 65 | - $url = ($clientConfig[ 'ssl' ] ? 'https://' : 'http://'); |
|
| 66 | - if ($clientConfig[ 'username' ]) { |
|
| 65 | + $url = ($clientConfig['ssl'] ? 'https://' : 'http://'); |
|
| 66 | + if ($clientConfig['username']) { |
|
| 67 | 67 | $url .= "{$clientConfig['username']}"; |
| 68 | - if ($clientConfig[ 'password' ]) { |
|
| 68 | + if ($clientConfig['password']) { |
|
| 69 | 69 | $url .= ":{$clientConfig['password']}"; |
| 70 | 70 | } |
| 71 | 71 | $url .= '@'; |
| 72 | 72 | } |
| 73 | - $url .= $clientConfig[ 'host' ]; |
|
| 73 | + $url .= $clientConfig['host']; |
|
| 74 | 74 | $url .= ":{$clientConfig['port']}"; |
| 75 | - $url .= $clientConfig[ 'path' ]; |
|
| 75 | + $url .= $clientConfig['path']; |
|
| 76 | 76 | |
| 77 | 77 | $this->instance = CouchDBClient::create([ |
| 78 | 78 | 'dbname' => $this->getDatabaseName(), |
| 79 | 79 | 'url' => $url, |
| 80 | - 'timeout' => $clientConfig[ 'timeout' ], |
|
| 80 | + 'timeout' => $clientConfig['timeout'], |
|
| 81 | 81 | ]); |
| 82 | 82 | |
| 83 | 83 | $this->createDatabase(); |
@@ -98,10 +98,10 @@ discard block |
||
| 98 | 98 | throw new PhpfastcacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), null, $e); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ($response->status === 404 || empty($response->body[ 'data' ])) { |
|
| 101 | + if ($response->status === 404 || empty($response->body['data'])) { |
|
| 102 | 102 | return null; |
| 103 | 103 | } else if ($response->status === 200) { |
| 104 | - return $this->decode($response->body[ 'data' ]); |
|
| 104 | + return $this->decode($response->body['data']); |
|
| 105 | 105 | } else { |
| 106 | 106 | throw new PhpfastcacheDriverException('Got unexpected HTTP status: ' . $response->status); |
| 107 | 107 | } |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | null, |
| 185 | 185 | false |
| 186 | 186 | ); |
| 187 | - if (!empty($response->headers[ 'etag' ])) { |
|
| 188 | - return \trim($response->headers[ 'etag' ], " '\"\t\n\r\0\x0B"); |
|
| 187 | + if (!empty($response->headers['etag'])) { |
|
| 188 | + return \trim($response->headers['etag'], " '\"\t\n\r\0\x0B"); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | return null; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $info = $this->instance->getDatabaseInfo(); |
| 237 | 237 | |
| 238 | 238 | return (new DriverStatistic()) |
| 239 | - ->setSize($info[ 'sizes' ][ 'active' ]) |
|
| 239 | + ->setSize($info['sizes']['active']) |
|
| 240 | 240 | ->setRawData($info) |
| 241 | 241 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 242 | 242 | ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |