@@ -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, PhpfastcacheDriverException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException |
|
21 | + PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException |
|
22 | 22 | }; |
23 | 23 | use Phpfastcache\Util\ClassNamespaceResolverTrait; |
24 | 24 | |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | if (\is_array($config)) { |
117 | 117 | $config = new ConfigurationOption($config); |
118 | 118 | trigger_error( |
119 | - 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
120 | - E_USER_DEPRECATED |
|
119 | + 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
120 | + E_USER_DEPRECATED |
|
121 | 121 | ); |
122 | 122 | }elseif ($config === null){ |
123 | 123 | $config = self::getDefaultConfig(); |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | |
140 | 140 | if(!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)){ |
141 | 141 | throw new PhpfastcacheDriverException(sprintf( |
142 | - 'Class "%s" does not implement "%s"', |
|
143 | - $driverClass, |
|
144 | - ExtendedCacheItemPoolInterface::class |
|
142 | + 'Class "%s" does not implement "%s"', |
|
143 | + $driverClass, |
|
144 | + ExtendedCacheItemPoolInterface::class |
|
145 | 145 | )); |
146 | 146 | } |
147 | 147 | try { |
@@ -328,27 +328,27 @@ discard block |
||
328 | 328 | { |
329 | 329 | 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); |
330 | 330 | return [ |
331 | - 'Apc', |
|
332 | - 'Apcu', |
|
333 | - 'Cassandra', |
|
334 | - 'Couchbase', |
|
335 | - 'Couchdb', |
|
336 | - 'Devnull', |
|
337 | - 'Files', |
|
338 | - 'Leveldb', |
|
339 | - 'Memcache', |
|
340 | - 'Memcached', |
|
341 | - 'Memstatic', |
|
342 | - 'Mongodb', |
|
343 | - 'Predis', |
|
344 | - 'Redis', |
|
345 | - 'Riak', |
|
346 | - 'Ssdb', |
|
347 | - 'Sqlite', |
|
348 | - 'Wincache', |
|
349 | - 'Xcache', |
|
350 | - 'Zenddisk', |
|
351 | - 'Zendshm', |
|
331 | + 'Apc', |
|
332 | + 'Apcu', |
|
333 | + 'Cassandra', |
|
334 | + 'Couchbase', |
|
335 | + 'Couchdb', |
|
336 | + 'Devnull', |
|
337 | + 'Files', |
|
338 | + 'Leveldb', |
|
339 | + 'Memcache', |
|
340 | + 'Memcached', |
|
341 | + 'Memstatic', |
|
342 | + 'Mongodb', |
|
343 | + 'Predis', |
|
344 | + 'Redis', |
|
345 | + 'Riak', |
|
346 | + 'Ssdb', |
|
347 | + 'Sqlite', |
|
348 | + 'Wincache', |
|
349 | + 'Xcache', |
|
350 | + 'Zenddisk', |
|
351 | + 'Zendshm', |
|
352 | 352 | ]; |
353 | 353 | } |
354 | 354 | |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | { |
361 | 361 | 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); |
362 | 362 | return \array_merge(self::getStaticSystemDrivers(), [ |
363 | - 'Devtrue', |
|
364 | - 'Devfalse', |
|
365 | - 'Cookie', |
|
363 | + 'Devtrue', |
|
364 | + 'Devfalse', |
|
365 | + 'Cookie', |
|
366 | 366 | ]); |
367 | 367 | } |
368 | 368 | |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | |
441 | 441 | if(!\class_exists($className)){ |
442 | 442 | throw new PhpfastcacheInvalidArgumentException( |
443 | - sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className) |
|
443 | + sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className) |
|
444 | 444 | ); |
445 | 445 | } |
446 | 446 | |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | if(!\class_exists($className)){ |
495 | 495 | throw new PhpfastcacheInvalidArgumentException( |
496 | - sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className) |
|
496 | + sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className) |
|
497 | 497 | ); |
498 | 498 | } |
499 | 499 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | |
508 | 508 | if(!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)){ |
509 | 509 | throw new PhpfastcacheLogicException( |
510 | - sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver') |
|
510 | + sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver') |
|
511 | 511 | ); |
512 | 512 | } |
513 | 513 |
@@ -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 | |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
120 | 120 | E_USER_DEPRECATED |
121 | 121 | ); |
122 | - }elseif ($config === null){ |
|
122 | + }elseif ($config === null) { |
|
123 | 123 | $config = self::getDefaultConfig(); |
124 | - }else if(!($config instanceof ConfigurationOption)){ |
|
124 | + } else if (!($config instanceof ConfigurationOption)) { |
|
125 | 125 | throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config))); |
126 | 126 | } |
127 | 127 | |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | |
134 | 134 | $instance = $instanceId ?: md5($driver . \serialize($config->toArray())); |
135 | 135 | |
136 | - if (!isset(self::$instances[ $instance ])) { |
|
137 | - $badPracticeOmeter[ $driver ] = 1; |
|
136 | + if (!isset(self::$instances[$instance])) { |
|
137 | + $badPracticeOmeter[$driver] = 1; |
|
138 | 138 | $driverClass = self::getDriverClass($driver); |
139 | 139 | |
140 | - if(!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)){ |
|
140 | + if (!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)) { |
|
141 | 141 | throw new PhpfastcacheDriverException(sprintf( |
142 | 142 | 'Class "%s" does not implement "%s"', |
143 | 143 | $driverClass, |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | try { |
148 | 148 | if (\class_exists($driverClass)) { |
149 | 149 | $configClass = $driverClass::getConfigClass(); |
150 | - self::$instances[ $instance ] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
151 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
150 | + self::$instances[$instance] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
151 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
152 | 152 | } else { |
153 | 153 | throw new PhpfastcacheDriverNotFoundException(\sprintf('The driver "%s" does not exists', $driver)); |
154 | 154 | } |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
167 | 167 | } |
168 | 168 | } |
169 | - } else if ($badPracticeOmeter[ $driver ] >= 2) { |
|
169 | + } else if ($badPracticeOmeter[$driver] >= 2) { |
|
170 | 170 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
171 | 171 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
172 | 172 | } |
173 | 173 | |
174 | - $badPracticeOmeter[ $driver ]++; |
|
174 | + $badPracticeOmeter[$driver]++; |
|
175 | 175 | |
176 | - return self::$instances[ $instance ]; |
|
176 | + return self::$instances[$instance]; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string'); |
191 | 191 | } |
192 | 192 | |
193 | - if (isset(self::$instances[ $instanceId ])) { |
|
194 | - return self::$instances[ $instanceId ]; |
|
193 | + if (isset(self::$instances[$instanceId])) { |
|
194 | + return self::$instances[$instanceId]; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | throw new PhpfastcacheInstanceNotFoundException(\sprintf('Instance ID %s not found', $instanceId)); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | - if(!$autoDriver || !\is_string($autoDriver)){ |
|
251 | + if (!$autoDriver || !\is_string($autoDriver)) { |
|
252 | 252 | throw new PhpfastcacheLogicException('Unable to find out a valid driver automatically'); |
253 | 253 | } |
254 | 254 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public static function __callStatic(string $name, array $arguments): ExtendedCacheItemPoolInterface |
264 | 264 | { |
265 | - $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []); |
|
265 | + $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []); |
|
266 | 266 | |
267 | 267 | return self::getInstance($name, $options); |
268 | 268 | } |
@@ -374,14 +374,14 @@ discard block |
||
374 | 374 | { |
375 | 375 | static $driverList; |
376 | 376 | |
377 | - if(self::getDefaultNamespacePath() === self::getNamespacePath()){ |
|
378 | - if($driverList === null){ |
|
377 | + if (self::getDefaultNamespacePath() === self::getNamespacePath()) { |
|
378 | + if ($driverList === null) { |
|
379 | 379 | $prefix = self::CORE_DRIVER_NAMESPACE; |
380 | 380 | $classMap = self::createClassMap(__DIR__ . '/Drivers'); |
381 | 381 | $driverList = []; |
382 | 382 | |
383 | 383 | foreach ($classMap as $class => $file) { |
384 | - $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\') )); |
|
384 | + $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\'))); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | $driverList = array_values(array_unique($driverList)); |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public static function getDriverClass(string $driverName): string |
414 | 414 | { |
415 | - if(!empty(self::$driverCustoms[$driverName])){ |
|
415 | + if (!empty(self::$driverCustoms[$driverName])) { |
|
416 | 416 | $driverClass = self::$driverCustoms[$driverName]; |
417 | - }else if(!empty(self::$driverOverrides[$driverName])){ |
|
417 | + } else if (!empty(self::$driverOverrides[$driverName])) { |
|
418 | 418 | $driverClass = self::$driverOverrides[$driverName]; |
419 | - } else{ |
|
419 | + } else { |
|
420 | 420 | $driverClass = self::getNamespacePath() . $driverName . '\Driver'; |
421 | 421 | } |
422 | 422 | |
@@ -431,24 +431,24 @@ discard block |
||
431 | 431 | * @throws \Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException |
432 | 432 | * @return void |
433 | 433 | */ |
434 | - public static function addCustomDriver(string $driverName, string $className){ |
|
434 | + public static function addCustomDriver(string $driverName, string $className) { |
|
435 | 435 | $driverName = self::standardizeDriverName($driverName); |
436 | 436 | |
437 | - if(empty($driverName)){ |
|
437 | + if (empty($driverName)) { |
|
438 | 438 | throw new PhpfastcacheInvalidArgumentException("Can't add a custom driver because its name is empty"); |
439 | 439 | } |
440 | 440 | |
441 | - if(!\class_exists($className)){ |
|
441 | + if (!\class_exists($className)) { |
|
442 | 442 | throw new PhpfastcacheInvalidArgumentException( |
443 | 443 | sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className) |
444 | 444 | ); |
445 | 445 | } |
446 | 446 | |
447 | - if(!empty(self::$driverCustoms[$driverName])){ |
|
447 | + if (!empty(self::$driverCustoms[$driverName])) { |
|
448 | 448 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' has been already added", $driverName)); |
449 | 449 | } |
450 | 450 | |
451 | - if(\in_array($driverName, self::getDriverList(), true)){ |
|
451 | + if (\in_array($driverName, self::getDriverList(), true)) { |
|
452 | 452 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' is already a part of the PhpFastCache core", $driverName)); |
453 | 453 | } |
454 | 454 | |
@@ -465,11 +465,11 @@ discard block |
||
465 | 465 | { |
466 | 466 | $driverName = self::standardizeDriverName($driverName); |
467 | 467 | |
468 | - if(empty($driverName)){ |
|
468 | + if (empty($driverName)) { |
|
469 | 469 | throw new PhpfastcacheInvalidArgumentException("Can't remove a custom driver because its name is empty"); |
470 | 470 | } |
471 | 471 | |
472 | - if(!isset(self::$driverCustoms[$driverName])){ |
|
472 | + if (!isset(self::$driverCustoms[$driverName])) { |
|
473 | 473 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' does not exists", $driverName)); |
474 | 474 | } |
475 | 475 | |
@@ -484,28 +484,28 @@ discard block |
||
484 | 484 | * @throws \Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException |
485 | 485 | * @return void |
486 | 486 | */ |
487 | - public static function addCoreDriverOverride(string $driverName, string $className){ |
|
487 | + public static function addCoreDriverOverride(string $driverName, string $className) { |
|
488 | 488 | $driverName = self::standardizeDriverName($driverName); |
489 | 489 | |
490 | - if(empty($driverName)){ |
|
490 | + if (empty($driverName)) { |
|
491 | 491 | throw new PhpfastcacheInvalidArgumentException("Can't add a core driver override because its name is empty"); |
492 | 492 | } |
493 | 493 | |
494 | - if(!\class_exists($className)){ |
|
494 | + if (!\class_exists($className)) { |
|
495 | 495 | throw new PhpfastcacheInvalidArgumentException( |
496 | 496 | sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className) |
497 | 497 | ); |
498 | 498 | } |
499 | 499 | |
500 | - if(!empty(self::$driverOverrides[$driverName])){ |
|
500 | + if (!empty(self::$driverOverrides[$driverName])) { |
|
501 | 501 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' has been already overridden", $driverName)); |
502 | 502 | } |
503 | 503 | |
504 | - if(!\in_array($driverName, self::getDriverList(), true)){ |
|
504 | + if (!\in_array($driverName, self::getDriverList(), true)) { |
|
505 | 505 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' can't be overridden since its not a part of the PhpFastCache core", $driverName)); |
506 | 506 | } |
507 | 507 | |
508 | - if(!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)){ |
|
508 | + if (!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)) { |
|
509 | 509 | throw new PhpfastcacheLogicException( |
510 | 510 | sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver') |
511 | 511 | ); |
@@ -524,11 +524,11 @@ discard block |
||
524 | 524 | { |
525 | 525 | $driverName = self::standardizeDriverName($driverName); |
526 | 526 | |
527 | - if(empty($driverName)){ |
|
527 | + if (empty($driverName)) { |
|
528 | 528 | throw new PhpfastcacheInvalidArgumentException("Can't remove a core driver override because its name is empty"); |
529 | 529 | } |
530 | 530 | |
531 | - if(!isset(self::$driverOverrides[$driverName])){ |
|
531 | + if (!isset(self::$driverOverrides[$driverName])) { |
|
532 | 532 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' were not overridden", $driverName)); |
533 | 533 | } |
534 | 534 |