@@ -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, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException |
|
| 21 | + PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException |
|
| 22 | 22 | }; |
| 23 | 23 | use Phpfastcache\Util\ClassNamespaceResolverTrait; |
| 24 | 24 | |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | if (\is_array($config)) { |
| 115 | 115 | $config = new ConfigurationOption($config); |
| 116 | 116 | trigger_error( |
| 117 | - 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
| 118 | - E_USER_DEPRECATED |
|
| 117 | + 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
| 118 | + E_USER_DEPRECATED |
|
| 119 | 119 | ); |
| 120 | 120 | }elseif ($config === null){ |
| 121 | 121 | $config = self::getDefaultConfig(); |
@@ -318,27 +318,27 @@ discard block |
||
| 318 | 318 | { |
| 319 | 319 | trigger_error(\sprintf('Method "%s" is deprecated as of the V7 and will be removed soon or later, use CacheManager::getDriverList() instead.', __METHOD__), E_USER_DEPRECATED); |
| 320 | 320 | return [ |
| 321 | - 'Apc', |
|
| 322 | - 'Apcu', |
|
| 323 | - 'Cassandra', |
|
| 324 | - 'Couchbase', |
|
| 325 | - 'Couchdb', |
|
| 326 | - 'Devnull', |
|
| 327 | - 'Files', |
|
| 328 | - 'Leveldb', |
|
| 329 | - 'Memcache', |
|
| 330 | - 'Memcached', |
|
| 331 | - 'Memstatic', |
|
| 332 | - 'Mongodb', |
|
| 333 | - 'Predis', |
|
| 334 | - 'Redis', |
|
| 335 | - 'Riak', |
|
| 336 | - 'Ssdb', |
|
| 337 | - 'Sqlite', |
|
| 338 | - 'Wincache', |
|
| 339 | - 'Xcache', |
|
| 340 | - 'Zenddisk', |
|
| 341 | - 'Zendshm', |
|
| 321 | + 'Apc', |
|
| 322 | + 'Apcu', |
|
| 323 | + 'Cassandra', |
|
| 324 | + 'Couchbase', |
|
| 325 | + 'Couchdb', |
|
| 326 | + 'Devnull', |
|
| 327 | + 'Files', |
|
| 328 | + 'Leveldb', |
|
| 329 | + 'Memcache', |
|
| 330 | + 'Memcached', |
|
| 331 | + 'Memstatic', |
|
| 332 | + 'Mongodb', |
|
| 333 | + 'Predis', |
|
| 334 | + 'Redis', |
|
| 335 | + 'Riak', |
|
| 336 | + 'Ssdb', |
|
| 337 | + 'Sqlite', |
|
| 338 | + 'Wincache', |
|
| 339 | + 'Xcache', |
|
| 340 | + 'Zenddisk', |
|
| 341 | + 'Zendshm', |
|
| 342 | 342 | ]; |
| 343 | 343 | } |
| 344 | 344 | |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | { |
| 351 | 351 | trigger_error(\sprintf('Method "%s" is deprecated as of the V7 and will be removed soon or later, use CacheManager::getDriverList() instead.', __METHOD__), E_USER_DEPRECATED); |
| 352 | 352 | return \array_merge(self::getStaticSystemDrivers(), [ |
| 353 | - 'Devtrue', |
|
| 354 | - 'Devfalse', |
|
| 355 | - 'Cookie', |
|
| 353 | + 'Devtrue', |
|
| 354 | + 'Devfalse', |
|
| 355 | + 'Cookie', |
|
| 356 | 356 | ]); |
| 357 | 357 | } |
| 358 | 358 | |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | if(!\class_exists($className)){ |
| 432 | 432 | throw new PhpfastcacheInvalidArgumentException( |
| 433 | - sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className) |
|
| 433 | + sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className) |
|
| 434 | 434 | ); |
| 435 | 435 | } |
| 436 | 436 | |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | if(!\class_exists($className)){ |
| 485 | 485 | throw new PhpfastcacheInvalidArgumentException( |
| 486 | - sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className) |
|
| 486 | + sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className) |
|
| 487 | 487 | ); |
| 488 | 488 | } |
| 489 | 489 | |
@@ -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 | |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
| 118 | 118 | E_USER_DEPRECATED |
| 119 | 119 | ); |
| 120 | - }elseif ($config === null){ |
|
| 120 | + }elseif ($config === null) { |
|
| 121 | 121 | $config = self::getDefaultConfig(); |
| 122 | - }else if(!($config instanceof ConfigurationOption)){ |
|
| 122 | + } else if (!($config instanceof ConfigurationOption)) { |
|
| 123 | 123 | throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config))); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $instance = $instanceId ?: md5($driver . \serialize($config->toArray())); |
| 133 | 133 | |
| 134 | - if (!isset(self::$instances[ $instance ])) { |
|
| 135 | - $badPracticeOmeter[ $driver ] = 1; |
|
| 134 | + if (!isset(self::$instances[$instance])) { |
|
| 135 | + $badPracticeOmeter[$driver] = 1; |
|
| 136 | 136 | $driverClass = self::getDriverClass($driver); |
| 137 | 137 | try { |
| 138 | 138 | if (\class_exists($driverClass)) { |
| 139 | 139 | $configClass = $driverClass::getConfigClass(); |
| 140 | - self::$instances[ $instance ] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
| 141 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
| 140 | + self::$instances[$instance] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
| 141 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
| 142 | 142 | } else { |
| 143 | 143 | throw new PhpfastcacheDriverNotFoundException(\sprintf('The driver "%s" does not exists', $driver)); |
| 144 | 144 | } |
@@ -156,14 +156,14 @@ discard block |
||
| 156 | 156 | throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | - } else if ($badPracticeOmeter[ $driver ] >= 2) { |
|
| 159 | + } else if ($badPracticeOmeter[$driver] >= 2) { |
|
| 160 | 160 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
| 161 | 161 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $badPracticeOmeter[ $driver ]++; |
|
| 164 | + $badPracticeOmeter[$driver]++; |
|
| 165 | 165 | |
| 166 | - return self::$instances[ $instance ]; |
|
| 166 | + return self::$instances[$instance]; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string'); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if (isset(self::$instances[ $instanceId ])) { |
|
| 184 | - return self::$instances[ $instanceId ]; |
|
| 183 | + if (isset(self::$instances[$instanceId])) { |
|
| 184 | + return self::$instances[$instanceId]; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | throw new PhpfastcacheInstanceNotFoundException(\sprintf('Instance ID %s not found', $instanceId)); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if(!$autoDriver || !\is_string($autoDriver)){ |
|
| 241 | + if (!$autoDriver || !\is_string($autoDriver)) { |
|
| 242 | 242 | throw new PhpfastcacheLogicException('Unable to find out a valid driver automatically'); |
| 243 | 243 | } |
| 244 | 244 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public static function __callStatic(string $name, array $arguments): ExtendedCacheItemPoolInterface |
| 254 | 254 | { |
| 255 | - $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []); |
|
| 255 | + $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []); |
|
| 256 | 256 | |
| 257 | 257 | return self::getInstance($name, $options); |
| 258 | 258 | } |
@@ -364,14 +364,14 @@ discard block |
||
| 364 | 364 | { |
| 365 | 365 | static $driverList; |
| 366 | 366 | |
| 367 | - if(self::getDefaultNamespacePath() === self::getNamespacePath()){ |
|
| 368 | - if($driverList === null){ |
|
| 367 | + if (self::getDefaultNamespacePath() === self::getNamespacePath()) { |
|
| 368 | + if ($driverList === null) { |
|
| 369 | 369 | $prefix = 'Phpfastcache\Drivers\\'; |
| 370 | 370 | $classMap = self::createClassMap(__DIR__ . '/Drivers'); |
| 371 | 371 | $driverList = []; |
| 372 | 372 | |
| 373 | 373 | foreach ($classMap as $class => $file) { |
| 374 | - $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\') )); |
|
| 374 | + $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\'))); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | $driverList = array_values(array_unique($driverList)); |
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | public static function getDriverClass(string $driverName): string |
| 404 | 404 | { |
| 405 | - if(!empty(self::$driverCustoms[$driverName])){ |
|
| 405 | + if (!empty(self::$driverCustoms[$driverName])) { |
|
| 406 | 406 | $driverClass = self::$driverCustoms[$driverName]; |
| 407 | - }else if(!empty(self::$driverOverrides[$driverName])){ |
|
| 407 | + } else if (!empty(self::$driverOverrides[$driverName])) { |
|
| 408 | 408 | $driverClass = self::$driverOverrides[$driverName]; |
| 409 | - } else{ |
|
| 409 | + } else { |
|
| 410 | 410 | $driverClass = self::getNamespacePath() . $driverName . '\Driver'; |
| 411 | 411 | } |
| 412 | 412 | |
@@ -421,24 +421,24 @@ discard block |
||
| 421 | 421 | * @throws \Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException |
| 422 | 422 | * @return void |
| 423 | 423 | */ |
| 424 | - public static function addCustomDriver(string $driverName, string $className){ |
|
| 424 | + public static function addCustomDriver(string $driverName, string $className) { |
|
| 425 | 425 | $driverName = self::standardizeDriverName($driverName); |
| 426 | 426 | |
| 427 | - if(empty($driverName)){ |
|
| 427 | + if (empty($driverName)) { |
|
| 428 | 428 | throw new PhpfastcacheInvalidArgumentException("Can't add a custom driver because its name is empty"); |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - if(!\class_exists($className)){ |
|
| 431 | + if (!\class_exists($className)) { |
|
| 432 | 432 | throw new PhpfastcacheInvalidArgumentException( |
| 433 | 433 | sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className) |
| 434 | 434 | ); |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - if(!empty(self::$driverCustoms[$driverName])){ |
|
| 437 | + if (!empty(self::$driverCustoms[$driverName])) { |
|
| 438 | 438 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' has been already added", $driverName)); |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - if(\in_array($driverName, self::getDriverList(), true)){ |
|
| 441 | + if (\in_array($driverName, self::getDriverList(), true)) { |
|
| 442 | 442 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' is already a part of the PhpFastCache core", $driverName)); |
| 443 | 443 | } |
| 444 | 444 | |
@@ -455,11 +455,11 @@ discard block |
||
| 455 | 455 | { |
| 456 | 456 | $driverName = self::standardizeDriverName($driverName); |
| 457 | 457 | |
| 458 | - if(empty($driverName)){ |
|
| 458 | + if (empty($driverName)) { |
|
| 459 | 459 | throw new PhpfastcacheInvalidArgumentException("Can't remove a custom driver because its name is empty"); |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - if(!isset(self::$driverCustoms[$driverName])){ |
|
| 462 | + if (!isset(self::$driverCustoms[$driverName])) { |
|
| 463 | 463 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' does not exists", $driverName)); |
| 464 | 464 | } |
| 465 | 465 | |
@@ -474,24 +474,24 @@ discard block |
||
| 474 | 474 | * @throws \Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException |
| 475 | 475 | * @return void |
| 476 | 476 | */ |
| 477 | - public static function addCoreDriverOverride(string $driverName, string $className){ |
|
| 477 | + public static function addCoreDriverOverride(string $driverName, string $className) { |
|
| 478 | 478 | $driverName = self::standardizeDriverName($driverName); |
| 479 | 479 | |
| 480 | - if(empty($driverName)){ |
|
| 480 | + if (empty($driverName)) { |
|
| 481 | 481 | throw new PhpfastcacheInvalidArgumentException("Can't add a core driver override because its name is empty"); |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - if(!\class_exists($className)){ |
|
| 484 | + if (!\class_exists($className)) { |
|
| 485 | 485 | throw new PhpfastcacheInvalidArgumentException( |
| 486 | 486 | sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className) |
| 487 | 487 | ); |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if(!empty(self::$driverOverrides[$driverName])){ |
|
| 490 | + if (!empty(self::$driverOverrides[$driverName])) { |
|
| 491 | 491 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' has been already overridden", $driverName)); |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - if(!\in_array($driverName, self::getDriverList(), true)){ |
|
| 494 | + if (!\in_array($driverName, self::getDriverList(), true)) { |
|
| 495 | 495 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' can't be overridden since its not a part of the PhpFastCache core", $driverName)); |
| 496 | 496 | } |
| 497 | 497 | |
@@ -508,11 +508,11 @@ discard block |
||
| 508 | 508 | { |
| 509 | 509 | $driverName = self::standardizeDriverName($driverName); |
| 510 | 510 | |
| 511 | - if(empty($driverName)){ |
|
| 511 | + if (empty($driverName)) { |
|
| 512 | 512 | throw new PhpfastcacheInvalidArgumentException("Can't remove a core driver override because its name is empty"); |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - if(!isset(self::$driverOverrides[$driverName])){ |
|
| 515 | + if (!isset(self::$driverOverrides[$driverName])) { |
|
| 516 | 516 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' were not overridden", $driverName)); |
| 517 | 517 | } |
| 518 | 518 | |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
| 118 | 118 | E_USER_DEPRECATED |
| 119 | 119 | ); |
| 120 | - }elseif ($config === null){ |
|
| 120 | + } elseif ($config === null){ |
|
| 121 | 121 | $config = self::getDefaultConfig(); |
| 122 | - }else if(!($config instanceof ConfigurationOption)){ |
|
| 122 | + } else if(!($config instanceof ConfigurationOption)){ |
|
| 123 | 123 | throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config))); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | { |
| 405 | 405 | if(!empty(self::$driverCustoms[$driverName])){ |
| 406 | 406 | $driverClass = self::$driverCustoms[$driverName]; |
| 407 | - }else if(!empty(self::$driverOverrides[$driverName])){ |
|
| 407 | + } else if(!empty(self::$driverOverrides[$driverName])){ |
|
| 408 | 408 | $driverClass = self::$driverOverrides[$driverName]; |
| 409 | 409 | } else{ |
| 410 | 410 | $driverClass = self::getNamespacePath() . $driverName . '\Driver'; |