@@ -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 | |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | if (\is_array($config)) { |
116 | 116 | $config = new ConfigurationOption($config); |
117 | 117 | \trigger_error( |
118 | - 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
119 | - E_USER_DEPRECATED |
|
118 | + 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
119 | + E_USER_DEPRECATED |
|
120 | 120 | ); |
121 | 121 | }elseif ($config === null){ |
122 | 122 | $config = self::getDefaultConfig(); |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | if(!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)){ |
140 | 140 | throw new PhpfastcacheDriverException(sprintf( |
141 | - 'Class "%s" does not implement "%s"', |
|
142 | - $driverClass, |
|
143 | - ExtendedCacheItemPoolInterface::class |
|
141 | + 'Class "%s" does not implement "%s"', |
|
142 | + $driverClass, |
|
143 | + ExtendedCacheItemPoolInterface::class |
|
144 | 144 | )); |
145 | 145 | } |
146 | 146 | try { |
@@ -332,27 +332,27 @@ discard block |
||
332 | 332 | { |
333 | 333 | \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); |
334 | 334 | return [ |
335 | - 'Apc', |
|
336 | - 'Apcu', |
|
337 | - 'Cassandra', |
|
338 | - 'Couchbase', |
|
339 | - 'Couchdb', |
|
340 | - 'Devnull', |
|
341 | - 'Files', |
|
342 | - 'Leveldb', |
|
343 | - 'Memcache', |
|
344 | - 'Memcached', |
|
345 | - 'Memstatic', |
|
346 | - 'Mongodb', |
|
347 | - 'Predis', |
|
348 | - 'Redis', |
|
349 | - 'Riak', |
|
350 | - 'Ssdb', |
|
351 | - 'Sqlite', |
|
352 | - 'Wincache', |
|
353 | - 'Xcache', |
|
354 | - 'Zenddisk', |
|
355 | - 'Zendshm', |
|
335 | + 'Apc', |
|
336 | + 'Apcu', |
|
337 | + 'Cassandra', |
|
338 | + 'Couchbase', |
|
339 | + 'Couchdb', |
|
340 | + 'Devnull', |
|
341 | + 'Files', |
|
342 | + 'Leveldb', |
|
343 | + 'Memcache', |
|
344 | + 'Memcached', |
|
345 | + 'Memstatic', |
|
346 | + 'Mongodb', |
|
347 | + 'Predis', |
|
348 | + 'Redis', |
|
349 | + 'Riak', |
|
350 | + 'Ssdb', |
|
351 | + 'Sqlite', |
|
352 | + 'Wincache', |
|
353 | + 'Xcache', |
|
354 | + 'Zenddisk', |
|
355 | + 'Zendshm', |
|
356 | 356 | ]; |
357 | 357 | } |
358 | 358 | |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | { |
365 | 365 | \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); |
366 | 366 | return \array_merge(self::getStaticSystemDrivers(), [ |
367 | - 'Devtrue', |
|
368 | - 'Devfalse', |
|
369 | - 'Cookie', |
|
367 | + 'Devtrue', |
|
368 | + 'Devfalse', |
|
369 | + 'Cookie', |
|
370 | 370 | ]); |
371 | 371 | } |
372 | 372 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | |
445 | 445 | if(!\class_exists($className)){ |
446 | 446 | throw new PhpfastcacheInvalidArgumentException( |
447 | - sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className) |
|
447 | + sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className) |
|
448 | 448 | ); |
449 | 449 | } |
450 | 450 | |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | |
498 | 498 | if(!\class_exists($className)){ |
499 | 499 | throw new PhpfastcacheInvalidArgumentException( |
500 | - sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className) |
|
500 | + sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className) |
|
501 | 501 | ); |
502 | 502 | } |
503 | 503 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | |
512 | 512 | if(!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)){ |
513 | 513 | throw new PhpfastcacheLogicException( |
514 | - sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver') |
|
514 | + sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver') |
|
515 | 515 | ); |
516 | 516 | } |
517 | 517 |
@@ -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 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
119 | 119 | E_USER_DEPRECATED |
120 | 120 | ); |
121 | - }elseif ($config === null){ |
|
121 | + }elseif ($config === null) { |
|
122 | 122 | $config = self::getDefaultConfig(); |
123 | - }else if(!($config instanceof ConfigurationOption)){ |
|
123 | + } else if (!($config instanceof ConfigurationOption)) { |
|
124 | 124 | throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config))); |
125 | 125 | } |
126 | 126 | |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | |
133 | 133 | $instance = $instanceId ?: md5($driver . \serialize($config->toArray())); |
134 | 134 | |
135 | - if (!isset(self::$instances[ $instance ])) { |
|
136 | - self::$badPracticeOmeter[ $driver ] = 1; |
|
135 | + if (!isset(self::$instances[$instance])) { |
|
136 | + self::$badPracticeOmeter[$driver] = 1; |
|
137 | 137 | $driverClass = self::getDriverClass($driver); |
138 | 138 | |
139 | - if(!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)){ |
|
139 | + if (!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)) { |
|
140 | 140 | throw new PhpfastcacheDriverException(sprintf( |
141 | 141 | 'Class "%s" does not implement "%s"', |
142 | 142 | $driverClass, |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | try { |
147 | 147 | if (\class_exists($driverClass)) { |
148 | 148 | $configClass = $driverClass::getConfigClass(); |
149 | - self::$instances[ $instance ] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
150 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
149 | + self::$instances[$instance] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
150 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
151 | 151 | } else { |
152 | 152 | throw new PhpfastcacheDriverNotFoundException(\sprintf('The driver "%s" does not exists', $driver)); |
153 | 153 | } |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
166 | 166 | } |
167 | 167 | } |
168 | - } else if (self::$badPracticeOmeter[ $driver ] >= 2) { |
|
168 | + } else if (self::$badPracticeOmeter[$driver] >= 2) { |
|
169 | 169 | \trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
170 | 170 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
171 | 171 | } |
172 | 172 | |
173 | - self::$badPracticeOmeter[ $driver ]++; |
|
173 | + self::$badPracticeOmeter[$driver]++; |
|
174 | 174 | |
175 | - return self::$instances[ $instance ]; |
|
175 | + return self::$instances[$instance]; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string'); |
190 | 190 | } |
191 | 191 | |
192 | - if (isset(self::$instances[ $instanceId ])) { |
|
193 | - return self::$instances[ $instanceId ]; |
|
192 | + if (isset(self::$instances[$instanceId])) { |
|
193 | + return self::$instances[$instanceId]; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | throw new PhpfastcacheInstanceNotFoundException(\sprintf('Instance ID %s not found', $instanceId)); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | if ($autoDriver === null) { |
239 | 239 | foreach (self::getDriverList() as $driver) { |
240 | 240 | /** @var ExtendedCacheItemPoolInterface $driver */ |
241 | - if((self::CORE_DRIVER_NAMESPACE . $driver . '\Driver')::isUsableInAutoContext()){ |
|
241 | + if ((self::CORE_DRIVER_NAMESPACE . $driver . '\Driver')::isUsableInAutoContext()) { |
|
242 | 242 | try { |
243 | 243 | self::getInstance($driver, $config); |
244 | 244 | $autoDriver = $driver; |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - if(!$autoDriver || !\is_string($autoDriver)){ |
|
253 | + if (!$autoDriver || !\is_string($autoDriver)) { |
|
254 | 254 | throw new PhpfastcacheLogicException('Unable to find out a valid driver automatically'); |
255 | 255 | } |
256 | 256 | |
257 | - self::$badPracticeOmeter[ $autoDriver ]--; |
|
257 | + self::$badPracticeOmeter[$autoDriver]--; |
|
258 | 258 | |
259 | 259 | return $autoDriver; |
260 | 260 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public static function __callStatic(string $name, array $arguments): ExtendedCacheItemPoolInterface |
268 | 268 | { |
269 | - $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []); |
|
269 | + $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []); |
|
270 | 270 | |
271 | 271 | return self::getInstance($name, $options); |
272 | 272 | } |
@@ -378,14 +378,14 @@ discard block |
||
378 | 378 | { |
379 | 379 | static $driverList; |
380 | 380 | |
381 | - if(self::getDefaultNamespacePath() === self::getNamespacePath()){ |
|
382 | - if($driverList === null){ |
|
381 | + if (self::getDefaultNamespacePath() === self::getNamespacePath()) { |
|
382 | + if ($driverList === null) { |
|
383 | 383 | $prefix = self::CORE_DRIVER_NAMESPACE; |
384 | 384 | $classMap = self::createClassMap(__DIR__ . '/Drivers'); |
385 | 385 | $driverList = []; |
386 | 386 | |
387 | 387 | foreach ($classMap as $class => $file) { |
388 | - $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\') )); |
|
388 | + $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\'))); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | $driverList = array_values(array_unique($driverList)); |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | */ |
417 | 417 | public static function getDriverClass(string $driverName): string |
418 | 418 | { |
419 | - if(!empty(self::$driverCustoms[$driverName])){ |
|
419 | + if (!empty(self::$driverCustoms[$driverName])) { |
|
420 | 420 | $driverClass = self::$driverCustoms[$driverName]; |
421 | - }else if(!empty(self::$driverOverrides[$driverName])){ |
|
421 | + } else if (!empty(self::$driverOverrides[$driverName])) { |
|
422 | 422 | $driverClass = self::$driverOverrides[$driverName]; |
423 | - } else{ |
|
423 | + } else { |
|
424 | 424 | $driverClass = self::getNamespacePath() . $driverName . '\Driver'; |
425 | 425 | } |
426 | 426 | |
@@ -435,24 +435,24 @@ discard block |
||
435 | 435 | * @throws \Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException |
436 | 436 | * @return void |
437 | 437 | */ |
438 | - public static function addCustomDriver(string $driverName, string $className){ |
|
438 | + public static function addCustomDriver(string $driverName, string $className) { |
|
439 | 439 | $driverName = self::standardizeDriverName($driverName); |
440 | 440 | |
441 | - if(empty($driverName)){ |
|
441 | + if (empty($driverName)) { |
|
442 | 442 | throw new PhpfastcacheInvalidArgumentException("Can't add a custom driver because its name is empty"); |
443 | 443 | } |
444 | 444 | |
445 | - if(!\class_exists($className)){ |
|
445 | + if (!\class_exists($className)) { |
|
446 | 446 | throw new PhpfastcacheInvalidArgumentException( |
447 | 447 | sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className) |
448 | 448 | ); |
449 | 449 | } |
450 | 450 | |
451 | - if(!empty(self::$driverCustoms[$driverName])){ |
|
451 | + if (!empty(self::$driverCustoms[$driverName])) { |
|
452 | 452 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' has been already added", $driverName)); |
453 | 453 | } |
454 | 454 | |
455 | - if(\in_array($driverName, self::getDriverList(), true)){ |
|
455 | + if (\in_array($driverName, self::getDriverList(), true)) { |
|
456 | 456 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' is already a part of the PhpFastCache core", $driverName)); |
457 | 457 | } |
458 | 458 | |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | { |
470 | 470 | $driverName = self::standardizeDriverName($driverName); |
471 | 471 | |
472 | - if(empty($driverName)){ |
|
472 | + if (empty($driverName)) { |
|
473 | 473 | throw new PhpfastcacheInvalidArgumentException("Can't remove a custom driver because its name is empty"); |
474 | 474 | } |
475 | 475 | |
476 | - if(!isset(self::$driverCustoms[$driverName])){ |
|
476 | + if (!isset(self::$driverCustoms[$driverName])) { |
|
477 | 477 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' does not exists", $driverName)); |
478 | 478 | } |
479 | 479 | |
@@ -488,28 +488,28 @@ discard block |
||
488 | 488 | * @throws \Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException |
489 | 489 | * @return void |
490 | 490 | */ |
491 | - public static function addCoreDriverOverride(string $driverName, string $className){ |
|
491 | + public static function addCoreDriverOverride(string $driverName, string $className) { |
|
492 | 492 | $driverName = self::standardizeDriverName($driverName); |
493 | 493 | |
494 | - if(empty($driverName)){ |
|
494 | + if (empty($driverName)) { |
|
495 | 495 | throw new PhpfastcacheInvalidArgumentException("Can't add a core driver override because its name is empty"); |
496 | 496 | } |
497 | 497 | |
498 | - if(!\class_exists($className)){ |
|
498 | + if (!\class_exists($className)) { |
|
499 | 499 | throw new PhpfastcacheInvalidArgumentException( |
500 | 500 | sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className) |
501 | 501 | ); |
502 | 502 | } |
503 | 503 | |
504 | - if(!empty(self::$driverOverrides[$driverName])){ |
|
504 | + if (!empty(self::$driverOverrides[$driverName])) { |
|
505 | 505 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' has been already overridden", $driverName)); |
506 | 506 | } |
507 | 507 | |
508 | - if(!\in_array($driverName, self::getDriverList(), true)){ |
|
508 | + if (!\in_array($driverName, self::getDriverList(), true)) { |
|
509 | 509 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' can't be overridden since its not a part of the PhpFastCache core", $driverName)); |
510 | 510 | } |
511 | 511 | |
512 | - if(!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)){ |
|
512 | + if (!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)) { |
|
513 | 513 | throw new PhpfastcacheLogicException( |
514 | 514 | sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver') |
515 | 515 | ); |
@@ -528,11 +528,11 @@ discard block |
||
528 | 528 | { |
529 | 529 | $driverName = self::standardizeDriverName($driverName); |
530 | 530 | |
531 | - if(empty($driverName)){ |
|
531 | + if (empty($driverName)) { |
|
532 | 532 | throw new PhpfastcacheInvalidArgumentException("Can't remove a core driver override because its name is empty"); |
533 | 533 | } |
534 | 534 | |
535 | - if(!isset(self::$driverOverrides[$driverName])){ |
|
535 | + if (!isset(self::$driverOverrides[$driverName])) { |
|
536 | 536 | throw new PhpfastcacheLogicException(sprintf("Driver '%s' were not overridden", $driverName)); |
537 | 537 | } |
538 | 538 |
@@ -92,33 +92,33 @@ discard block |
||
92 | 92 | public function __construct(...$args) |
93 | 93 | { |
94 | 94 | parent::__construct(...$args); |
95 | - $array =& $this->getArray(); |
|
95 | + $array = & $this->getArray(); |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Detect unwanted keys and throw an exception. |
99 | 99 | * No more kidding now, it's 21th century. |
100 | 100 | */ |
101 | - if(array_diff_key($array, get_object_vars($this))){ |
|
101 | + if (array_diff_key($array, get_object_vars($this))) { |
|
102 | 102 | throw new PhpfastcacheInvalidConfigurationException(\sprintf( |
103 | 103 | 'Invalid option(s) for the config %s: %s', |
104 | 104 | static::class, |
105 | - implode(', ', array_keys(array_diff_key($array, get_object_vars($this)))) |
|
105 | + implode(', ', array_keys(array_diff_key($array, get_object_vars($this)))) |
|
106 | 106 | )); |
107 | 107 | } |
108 | 108 | |
109 | 109 | foreach (get_object_vars($this) as $property => $value) { |
110 | 110 | |
111 | - if(array_key_exists($property, $array)){ |
|
112 | - $this->$property = &$array[ $property ]; |
|
113 | - }else{ |
|
114 | - $array[ $property ] = &$this->$property; |
|
111 | + if (array_key_exists($property, $array)) { |
|
112 | + $this->$property = &$array[$property]; |
|
113 | + } else { |
|
114 | + $array[$property] = &$this->$property; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | foreach (get_class_methods($this) as $method) { |
119 | - if(strpos($method, 'set') === 0){ |
|
119 | + if (strpos($method, 'set') === 0) { |
|
120 | 120 | $value = null; |
121 | - try{ |
|
121 | + try { |
|
122 | 122 | /** |
123 | 123 | * We use property instead of getter |
124 | 124 | * because of is/get conditions and |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | $value = $this->{lcfirst(substr($method, 3))}; |
129 | 129 | $this->{$method}($value); |
130 | - }catch(\TypeError $e){ |
|
130 | + } catch (\TypeError $e) { |
|
131 | 131 | $typeHintGot = \is_object($value) ? \get_class($value) : \gettype($value); |
132 | 132 | $reflectionMethod = new \ReflectionMethod($this, $method); |
133 | 133 | $parameter = $reflectionMethod->getParameters()[0] ?? null; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function setIgnoreSymfonyNotice(bool $ignoreSymfonyNotice): self |
218 | 218 | { |
219 | - if($ignoreSymfonyNotice){ |
|
219 | + if ($ignoreSymfonyNotice) { |
|
220 | 220 | \trigger_error('Configuration option "ignoreSymfonyNotice" is deprecated as of the V7', E_USER_DEPRECATED); |
221 | 221 | } |
222 | 222 | $this->ignoreSymfonyNotice = $ignoreSymfonyNotice; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function setFallbackConfig($fallbackConfig): self |
333 | 333 | { |
334 | - if($fallbackConfig !== null && !($fallbackConfig instanceof self)){ |
|
334 | + if ($fallbackConfig !== null && !($fallbackConfig instanceof self)) { |
|
335 | 335 | throw new PhpfastcacheInvalidArgumentException(\sprintf( |
336 | 336 | 'Invalid argument "%s" for %s', |
337 | 337 | gettype($fallbackConfig) === 'object' ? get_class($fallbackConfig) : gettype($fallbackConfig), |
@@ -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\Core\Item; |
17 | 17 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $this->driver = $driver; |
71 | 71 | $this->driver->setItem($this); |
72 | 72 | $this->expirationDate = new \DateTime(); |
73 | - if($this->driver->getConfig()->isItemDetailedDate()){ |
|
73 | + if ($this->driver->getConfig()->isItemDetailedDate()) { |
|
74 | 74 | $this->creationDate = new \DateTime(); |
75 | 75 | $this->modificationDate = new \DateTime(); |
76 | 76 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | { |
225 | 225 | case 'array': |
226 | 226 | case 'object': |
227 | - if(\is_array($this->data) || $this->data instanceof \Countable){ |
|
227 | + if (\is_array($this->data) || $this->data instanceof \Countable) { |
|
228 | 228 | return \count($this->data); |
229 | 229 | } |
230 | 230 | break; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | if (\is_array($this->data)) { |
283 | 283 | $this->data[] = $data; |
284 | 284 | } else if (\is_string($data)) { |
285 | - $this->data .= (string)$data; |
|
285 | + $this->data .= (string) $data; |
|
286 | 286 | } else { |
287 | 287 | throw new PhpfastcacheInvalidArgumentException('$data must be either array nor string.'); |
288 | 288 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | if (\is_array($this->data)) { |
302 | 302 | \array_unshift($this->data, $data); |
303 | 303 | } else if (\is_string($data)) { |
304 | - $this->data = (string)$data . $this->data; |
|
304 | + $this->data = (string) $data . $this->data; |
|
305 | 305 | } else { |
306 | 306 | throw new PhpfastcacheInvalidArgumentException('$data must be either array nor string.'); |
307 | 307 | } |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | public function removeTag($tagName): ExtendedCacheItemInterface |
381 | 381 | { |
382 | 382 | if (($key = \array_search($tagName, $this->tags)) !== false) { |
383 | - unset($this->tags[ $key ]); |
|
383 | + unset($this->tags[$key]); |
|
384 | 384 | $this->removedTags[] = $tagName; |
385 | 385 | } |
386 | 386 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | final public function __debugInfo() |
460 | 460 | { |
461 | 461 | $info = \get_object_vars($this); |
462 | - $info[ 'driver' ] = 'object(' . \get_class($info[ 'driver' ]) . ')'; |
|
462 | + $info['driver'] = 'object(' . \get_class($info['driver']) . ')'; |
|
463 | 463 | |
464 | 464 | return $info; |
465 | 465 | } |
@@ -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\Core\Pool; |
17 | 17 | |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * due to performance issue on huge |
72 | 72 | * loop dispatching operations |
73 | 73 | */ |
74 | - if (!isset($this->itemInstances[ $key ])) { |
|
74 | + if (!isset($this->itemInstances[$key])) { |
|
75 | 75 | if (\preg_match('~([' . \preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)) { |
76 | - throw new PhpfastcacheInvalidArgumentException('Unsupported key character detected: "' . $matches[ 1 ] . '". Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers'); |
|
76 | + throw new PhpfastcacheInvalidArgumentException('Unsupported key character detected: "' . $matches[1] . '". Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | CacheManager::$ReadHits++; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | $driverData = $this->driverUnwrapData($driverArray); |
96 | 96 | |
97 | - if ($this->getConfig()[ 'preventCacheSlams' ]) { |
|
97 | + if ($this->getConfig()['preventCacheSlams']) { |
|
98 | 98 | while ($driverData instanceof ItemBatch) { |
99 | 99 | if ($driverData->getItemDate()->getTimestamp() + $this->getConfig()->getCacheSlamsTimeout() < \time()) { |
100 | 100 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * Reset the Item |
156 | 156 | */ |
157 | 157 | $item->set(null) |
158 | - ->expiresAfter(\abs((int)$this->getConfig()[ 'defaultTtl' ])) |
|
158 | + ->expiresAfter(\abs((int) $this->getConfig()['defaultTtl'])) |
|
159 | 159 | ->setHit(false) |
160 | 160 | ->setTags([]); |
161 | 161 | if ($this->getConfig()->isItemDetailedDate()) { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $item->setHit(true); |
173 | 173 | } |
174 | 174 | } else { |
175 | - $item->expiresAfter(\abs((int)$this->getConfig()[ 'defaultTtl' ])); |
|
175 | + $item->expiresAfter(\abs((int) $this->getConfig()['defaultTtl'])); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | * @param $this ExtendedCacheItemPoolInterface |
186 | 186 | * @param $this ExtendedCacheItemInterface |
187 | 187 | */ |
188 | - $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[ $key ]); |
|
188 | + $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[$key]); |
|
189 | 189 | |
190 | - return $this->itemInstances[ $key ]; |
|
190 | + return $this->itemInstances[$key]; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | public function setItem(CacheItemInterface $item) |
199 | 199 | { |
200 | 200 | if ($this->getClassNamespace() . '\\Item' === \get_class($item)) { |
201 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
201 | + $this->itemInstances[$item->getKey()] = $item; |
|
202 | 202 | |
203 | 203 | return $this; |
204 | 204 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | { |
216 | 216 | $collection = []; |
217 | 217 | foreach ($keys as $key) { |
218 | - $collection[ $key ] = $this->getItem($key); |
|
218 | + $collection[$key] = $this->getItem($key); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | return $collection; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
305 | - return (bool)$return; |
|
305 | + return (bool) $return; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | * due to performance issue on huge |
321 | 321 | * loop dispatching operations |
322 | 322 | */ |
323 | - if (!isset($this->itemInstances[ $item->getKey() ])) { |
|
324 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
325 | - } else if (\spl_object_hash($item) !== \spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
323 | + if (!isset($this->itemInstances[$item->getKey()])) { |
|
324 | + $this->itemInstances[$item->getKey()] = $item; |
|
325 | + } else if (\spl_object_hash($item) !== \spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
326 | 326 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
327 | 327 | } |
328 | 328 | |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | public function saveDeferred(CacheItemInterface $item) |
375 | 375 | { |
376 | 376 | if (!\array_key_exists($item->getKey(), $this->itemInstances)) { |
377 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
378 | - } else if (\spl_object_hash($item) !== \spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
377 | + $this->itemInstances[$item->getKey()] = $item; |
|
378 | + } else if (\spl_object_hash($item) !== \spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
379 | 379 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
380 | 380 | } |
381 | 381 | |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | */ |
387 | 387 | $this->eventManager->dispatch('CacheSaveDeferredItem', $this, $item); |
388 | 388 | |
389 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
389 | + return $this->deferredList[$item->getKey()] = $item; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -406,11 +406,11 @@ discard block |
||
406 | 406 | foreach ($this->deferredList as $key => $item) { |
407 | 407 | $result = $this->save($item); |
408 | 408 | if ($return !== false) { |
409 | - unset($this->deferredList[ $key ]); |
|
409 | + unset($this->deferredList[$key]); |
|
410 | 410 | $return = $result; |
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
414 | - return (bool)$return; |
|
414 | + return (bool) $return; |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | \ 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\Core\Pool; |
17 | 17 | |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | ]; |
160 | 160 | |
161 | 161 | if ($this->getConfig()->isItemDetailedDate()) { |
162 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = new \DateTime(); |
|
162 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = new \DateTime(); |
|
163 | 163 | /** |
164 | 164 | * If the creation date exists |
165 | 165 | * reuse it else set a new Date |
166 | 166 | */ |
167 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
|
167 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate() ?: new \DateTime(); |
|
168 | 168 | } else { |
169 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
|
170 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
|
169 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = null; |
|
170 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = null; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | return $wrap; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function driverUnwrapData(array $wrapper) |
181 | 181 | { |
182 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
182 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function driverUnwrapTags(array $wrapper) |
190 | 190 | { |
191 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
191 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function driverUnwrapEdate(array $wrapper) |
200 | 200 | { |
201 | - return $wrapper[ self::DRIVER_EDATE_WRAPPER_INDEX ]; |
|
201 | + return $wrapper[self::DRIVER_EDATE_WRAPPER_INDEX]; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function driverUnwrapCdate(array $wrapper) |
209 | 209 | { |
210 | - return $wrapper[ self::DRIVER_CDATE_WRAPPER_INDEX ]; |
|
210 | + return $wrapper[self::DRIVER_CDATE_WRAPPER_INDEX]; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public function driverUnwrapMdate(array $wrapper) |
219 | 219 | { |
220 | - return $wrapper[ self::DRIVER_MDATE_WRAPPER_INDEX ]; |
|
220 | + return $wrapper[self::DRIVER_MDATE_WRAPPER_INDEX]; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * that has slow performances |
275 | 275 | */ |
276 | 276 | |
277 | - $tagsItem->set(\array_merge((array)$data, [$item->getKey() => $expTimestamp])); |
|
277 | + $tagsItem->set(\array_merge((array) $data, [$item->getKey() => $expTimestamp])); |
|
278 | 278 | |
279 | 279 | /** |
280 | 280 | * Set the expiration date |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | $tagsItems = $this->getItems($this->getTagKeys($item->getRemovedTags())); |
297 | 297 | |
298 | 298 | foreach ($tagsItems as $tagsItem) { |
299 | - $data = (array)$tagsItem->get(); |
|
299 | + $data = (array) $tagsItem->get(); |
|
300 | 300 | |
301 | - unset($data[ $item->getKey() ]); |
|
301 | + unset($data[$item->getKey()]); |
|
302 | 302 | $tagsItem->set($data); |
303 | 303 | |
304 | 304 | /** |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | public static function getConfigClass(): string |
380 | 380 | { |
381 | 381 | $localConfigClass = \substr(static::class, 0, \strrpos(static::class, '\\')) . '\Config'; |
382 | - if(\class_exists($localConfigClass) && is_a($localConfigClass, ConfigurationOption::class, true)){ |
|
382 | + if (\class_exists($localConfigClass) && is_a($localConfigClass, ConfigurationOption::class, true)) { |
|
383 | 383 | return $localConfigClass; |
384 | 384 | } |
385 | 385 | return ConfigurationOption::class; |
@@ -66,5 +66,5 @@ |
||
66 | 66 | |
67 | 67 | if ((!\defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && \class_exists(\Composer\Autoload\ClassLoader::class)) { |
68 | 68 | \trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
69 | - E_USER_WARNING); |
|
69 | + E_USER_WARNING); |
|
70 | 70 | } |
71 | 71 | \ No newline at end of file |
@@ -41,7 +41,7 @@ |
||
41 | 41 | return true; |
42 | 42 | } else if (\constant($CONSTANT_NAME) !== $driverName) { |
43 | 43 | \trigger_error('Memcache collision detected, you used both Memcache and Memcached driver in your script, this may leads to unexpected behaviours', |
44 | - E_USER_WARNING); |
|
44 | + E_USER_WARNING); |
|
45 | 45 | |
46 | 46 | return false; |
47 | 47 | } |
@@ -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 | |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * due to performance issue on huge |
77 | 77 | * loop dispatching operations |
78 | 78 | */ |
79 | - if (isset($this->events[ $eventName ])) { |
|
80 | - foreach ($this->events[ $eventName ] as $event) { |
|
79 | + if (isset($this->events[$eventName])) { |
|
80 | + foreach ($this->events[$eventName] as $event) { |
|
81 | 81 | call_user_func_array($event, $args); |
82 | 82 | } |
83 | 83 | } |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | { |
94 | 94 | if (\strpos($name, 'on') === 0) { |
95 | 95 | $name = \substr($name, 2); |
96 | - if (\is_callable($arguments[ 0 ])) { |
|
97 | - if (isset($arguments[ 1 ]) && \is_string($arguments[ 0 ])) { |
|
98 | - $this->events[ $name ][ $arguments[ 1 ] ] = $arguments[ 0 ]; |
|
96 | + if (\is_callable($arguments[0])) { |
|
97 | + if (isset($arguments[1]) && \is_string($arguments[0])) { |
|
98 | + $this->events[$name][$arguments[1]] = $arguments[0]; |
|
99 | 99 | } else { |
100 | - $this->events[ $name ][] = $arguments[ 0 ]; |
|
100 | + $this->events[$name][] = $arguments[0]; |
|
101 | 101 | } |
102 | 102 | } else { |
103 | - throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[ 0 ]))); |
|
103 | + throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[0]))); |
|
104 | 104 | } |
105 | 105 | } else { |
106 | 106 | throw new \BadMethodCallException('An event must start with "on" such as "onCacheGetItem"'); |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function unbindEventCallback(string $eventName, string $callbackName): bool |
116 | 116 | { |
117 | - $return = isset($this->events[ $eventName ][ $callbackName ]); |
|
118 | - unset($this->events[ $eventName ][ $callbackName ]); |
|
117 | + $return = isset($this->events[$eventName][$callbackName]); |
|
118 | + unset($this->events[$eventName][$callbackName]); |
|
119 | 119 | |
120 | 120 | return $return; |
121 | 121 | } |