@@ -132,8 +132,8 @@ 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 | 139 | if (!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)) { |
@@ -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 | } |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
167 | 167 | } |
168 | 168 | } |
169 | - } else if (self::$badPracticeOmeter[ $driver ] >= 2) { |
|
169 | + } else if (self::$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 | - self::$badPracticeOmeter[ $driver ]++; |
|
174 | + self::$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)); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | throw new PhpfastcacheLogicException('Unable to find out a valid driver automatically'); |
256 | 256 | } |
257 | 257 | |
258 | - self::$badPracticeOmeter[ $autoDriver ]--; |
|
258 | + self::$badPracticeOmeter[$autoDriver]--; |
|
259 | 259 | |
260 | 260 | return $autoDriver; |
261 | 261 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public static function __callStatic(string $name, array $arguments): ExtendedCacheItemPoolInterface |
269 | 269 | { |
270 | - $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []); |
|
270 | + $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []); |
|
271 | 271 | |
272 | 272 | return self::getInstance($name, $options); |
273 | 273 | } |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | |
398 | 398 | $driverList = \array_merge($driverList, \array_keys(self::$driverCustoms)); |
399 | 399 | |
400 | - if($FQCNAsKey){ |
|
400 | + if ($FQCNAsKey) { |
|
401 | 401 | $realDriverList = []; |
402 | - foreach ($driverList as $driverName){ |
|
402 | + foreach ($driverList as $driverName) { |
|
403 | 403 | $realDriverList[self::getDriverClass($driverName)] = $driverName; |
404 | 404 | } |
405 | 405 | $driverList = $realDriverList; |
@@ -428,10 +428,10 @@ discard block |
||
428 | 428 | */ |
429 | 429 | public static function getDriverClass(string $driverName): string |
430 | 430 | { |
431 | - if (!empty(self::$driverCustoms[ $driverName ])) { |
|
432 | - $driverClass = self::$driverCustoms[ $driverName ]; |
|
433 | - } else if (!empty(self::$driverOverrides[ $driverName ])) { |
|
434 | - $driverClass = self::$driverOverrides[ $driverName ]; |
|
431 | + if (!empty(self::$driverCustoms[$driverName])) { |
|
432 | + $driverClass = self::$driverCustoms[$driverName]; |
|
433 | + } else if (!empty(self::$driverOverrides[$driverName])) { |
|
434 | + $driverClass = self::$driverOverrides[$driverName]; |
|
435 | 435 | } else { |
436 | 436 | $driverClass = self::getNamespacePath() . $driverName . '\Driver'; |
437 | 437 | } |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | ); |
462 | 462 | } |
463 | 463 | |
464 | - if (!empty(self::$driverCustoms[ $driverName ])) { |
|
464 | + if (!empty(self::$driverCustoms[$driverName])) { |
|
465 | 465 | throw new PhpfastcacheLogicException(\sprintf("Driver '%s' has been already added", $driverName)); |
466 | 466 | } |
467 | 467 | |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | throw new PhpfastcacheLogicException(\sprintf("Driver '%s' is already a part of the PhpFastCache core", $driverName)); |
470 | 470 | } |
471 | 471 | |
472 | - self::$driverCustoms[ $driverName ] = $className; |
|
472 | + self::$driverCustoms[$driverName] = $className; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -486,11 +486,11 @@ discard block |
||
486 | 486 | throw new PhpfastcacheInvalidArgumentException("Can't remove a custom driver because its name is empty"); |
487 | 487 | } |
488 | 488 | |
489 | - if (!isset(self::$driverCustoms[ $driverName ])) { |
|
489 | + if (!isset(self::$driverCustoms[$driverName])) { |
|
490 | 490 | throw new PhpfastcacheLogicException(\sprintf("Driver '%s' does not exists", $driverName)); |
491 | 491 | } |
492 | 492 | |
493 | - unset(self::$driverCustoms[ $driverName ]); |
|
493 | + unset(self::$driverCustoms[$driverName]); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | ); |
516 | 516 | } |
517 | 517 | |
518 | - if (!empty(self::$driverOverrides[ $driverName ])) { |
|
518 | + if (!empty(self::$driverOverrides[$driverName])) { |
|
519 | 519 | throw new PhpfastcacheLogicException(\sprintf("Driver '%s' has been already overridden", $driverName)); |
520 | 520 | } |
521 | 521 | |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | ); |
531 | 531 | } |
532 | 532 | |
533 | - self::$driverOverrides[ $driverName ] = $className; |
|
533 | + self::$driverOverrides[$driverName] = $className; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -547,10 +547,10 @@ discard block |
||
547 | 547 | throw new PhpfastcacheInvalidArgumentException("Can't remove a core driver override because its name is empty"); |
548 | 548 | } |
549 | 549 | |
550 | - if (!isset(self::$driverOverrides[ $driverName ])) { |
|
550 | + if (!isset(self::$driverOverrides[$driverName])) { |
|
551 | 551 | throw new PhpfastcacheLogicException(\sprintf("Driver '%s' were not overridden", $driverName)); |
552 | 552 | } |
553 | 553 | |
554 | - unset(self::$driverOverrides[ $driverName ]); |
|
554 | + unset(self::$driverOverrides[$driverName]); |
|
555 | 555 | } |
556 | 556 | } |
@@ -64,32 +64,32 @@ discard block |
||
64 | 64 | */ |
65 | 65 | static $version; |
66 | 66 | |
67 | - if($version && $cacheable){ |
|
67 | + if ($version && $cacheable) { |
|
68 | 68 | return $version; |
69 | 69 | } |
70 | 70 | |
71 | - if(\function_exists('shell_exec')){ |
|
71 | + if (\function_exists('shell_exec')) { |
|
72 | 72 | $command = 'git -C "' . __DIR__ . '" describe --abbrev=0 --tags'; |
73 | 73 | $stdout = shell_exec($command); |
74 | - if(\is_string($stdout)){ |
|
74 | + if (\is_string($stdout)) { |
|
75 | 75 | $version = \trim($stdout); |
76 | 76 | return $version; |
77 | 77 | } |
78 | - if(!$fallbackOnChangelog){ |
|
78 | + if (!$fallbackOnChangelog) { |
|
79 | 79 | throw new PhpfastcacheLogicException('The git command used to retrieve the PhpFastCache version has failed.'); |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - if(!$fallbackOnChangelog){ |
|
83 | + if (!$fallbackOnChangelog) { |
|
84 | 84 | throw new PhpfastcacheLogicException('shell_exec is disabled therefore the PhpFastCache version cannot be retrieved.'); |
85 | 85 | } |
86 | 86 | |
87 | 87 | $changelogFilename = __DIR__ . '/../../CHANGELOG.md'; |
88 | - if(\file_exists($changelogFilename)){ |
|
88 | + if (\file_exists($changelogFilename)) { |
|
89 | 89 | $versionPrefix = '## '; |
90 | 90 | $changelog = \explode("\n", self::getPhpFastCacheChangelog()); |
91 | - foreach ($changelog as $line){ |
|
92 | - if(\strpos($line, $versionPrefix) === 0){ |
|
91 | + foreach ($changelog as $line) { |
|
92 | + if (\strpos($line, $versionPrefix) === 0) { |
|
93 | 93 | $version = \trim(\str_replace($versionPrefix, '', $line)); |
94 | 94 | return $version; |
95 | 95 | } |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | { |
108 | 108 | static $hash; |
109 | 109 | |
110 | - if($hash && $cacheable){ |
|
110 | + if ($hash && $cacheable) { |
|
111 | 111 | return $hash; |
112 | 112 | } |
113 | 113 | |
114 | - if(\function_exists('shell_exec')){ |
|
114 | + if (\function_exists('shell_exec')) { |
|
115 | 115 | $stdout = \shell_exec('git rev-parse --short HEAD'); |
116 | - if(\is_string($stdout)){ |
|
116 | + if (\is_string($stdout)) { |
|
117 | 117 | $hash = \trim($stdout); |
118 | 118 | return "#{$hash}"; |
119 | 119 | } |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | public static function getChangelog(): string |
132 | 132 | { |
133 | 133 | $changelogFilename = __DIR__ . '/../../CHANGELOG_API.md'; |
134 | - if(\file_exists($changelogFilename)){ |
|
134 | + if (\file_exists($changelogFilename)) { |
|
135 | 135 | $string = \str_replace(["\r\n", "\r"], "\n", \trim(\file_get_contents($changelogFilename))); |
136 | - if($string){ |
|
136 | + if ($string) { |
|
137 | 137 | return $string; |
138 | 138 | } |
139 | 139 | throw new PhpfastcacheLogicException('Unable to retrieve the PhpFastCache API changelog as it seems to be empty.'); |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | public static function getPhpFastCacheChangelog(): string |
151 | 151 | { |
152 | 152 | $changelogFilename = __DIR__ . '/../../CHANGELOG.md'; |
153 | - if(\file_exists($changelogFilename)){ |
|
153 | + if (\file_exists($changelogFilename)) { |
|
154 | 154 | $string = \str_replace(["\r\n", "\r"], "\n", \trim(\file_get_contents($changelogFilename))); |
155 | - if($string){ |
|
155 | + if ($string) { |
|
156 | 156 | return $string; |
157 | 157 | } |
158 | 158 | throw new PhpfastcacheLogicException('Unable to retrieve the PhpFastCache changelog as it seems to be empty.'); |