@@ -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 | } |
@@ -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\Util; |
17 | 17 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | $map = []; |
57 | 57 | |
58 | - if(\is_array($dir) || $dir instanceof \Traversable){ |
|
58 | + if (\is_array($dir) || $dir instanceof \Traversable) { |
|
59 | 59 | foreach ($dir as $file) { |
60 | 60 | if (!$file->isFile()) { |
61 | 61 | continue; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | \gc_mem_caches(); |
71 | 71 | } |
72 | 72 | foreach ($classes as $class) { |
73 | - $map[ $class ] = $path; |
|
73 | + $map[$class] = $path; |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | } |
@@ -94,19 +94,19 @@ discard block |
||
94 | 94 | $tokens = \token_get_all($contents); |
95 | 95 | $classes = []; |
96 | 96 | $namespace = ''; |
97 | - for ($i = 0; isset($tokens[ $i ]); ++$i) { |
|
98 | - $token = $tokens[ $i ]; |
|
99 | - if (!isset($token[ 1 ])) { |
|
97 | + for ($i = 0; isset($tokens[$i]); ++$i) { |
|
98 | + $token = $tokens[$i]; |
|
99 | + if (!isset($token[1])) { |
|
100 | 100 | continue; |
101 | 101 | } |
102 | 102 | $class = ''; |
103 | - switch ($token[ 0 ]) { |
|
103 | + switch ($token[0]) { |
|
104 | 104 | case \T_NAMESPACE: |
105 | 105 | $namespace = ''; |
106 | 106 | // If there is a namespace, extract it |
107 | - while (isset($tokens[ ++$i ][ 1 ])) { |
|
108 | - if (\in_array($tokens[ $i ][ 0 ], [\T_STRING, \T_NS_SEPARATOR])) { |
|
109 | - $namespace .= $tokens[ $i ][ 1 ]; |
|
107 | + while (isset($tokens[ ++$i][1])) { |
|
108 | + if (\in_array($tokens[$i][0], [\T_STRING, \T_NS_SEPARATOR])) { |
|
109 | + $namespace .= $tokens[$i][1]; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | $namespace .= '\\'; |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | // Skip usage of ::class constant |
118 | 118 | $isClassConstant = false; |
119 | 119 | for ($j = $i - 1; $j > 0; --$j) { |
120 | - if (!isset($tokens[ $j ][ 1 ])) { |
|
120 | + if (!isset($tokens[$j][1])) { |
|
121 | 121 | break; |
122 | 122 | } |
123 | - if (\T_DOUBLE_COLON === $tokens[ $j ][ 0 ]) { |
|
123 | + if (\T_DOUBLE_COLON === $tokens[$j][0]) { |
|
124 | 124 | $isClassConstant = true; |
125 | 125 | break; |
126 | - } elseif (!\in_array($tokens[ $j ][ 0 ], [\T_WHITESPACE, \T_DOC_COMMENT, \T_COMMENT], false)) { |
|
126 | + } elseif (!\in_array($tokens[$j][0], [\T_WHITESPACE, \T_DOC_COMMENT, \T_COMMENT], false)) { |
|
127 | 127 | break; |
128 | 128 | } |
129 | 129 | } |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | break; |
132 | 132 | } |
133 | 133 | // Find the classname |
134 | - while (isset($tokens[ ++$i ][ 1 ])) { |
|
135 | - $t = $tokens[ $i ]; |
|
136 | - if (\T_STRING === $t[ 0 ]) { |
|
137 | - $class .= $t[ 1 ]; |
|
138 | - } elseif ('' !== $class && \T_WHITESPACE === $t[ 0 ]) { |
|
134 | + while (isset($tokens[ ++$i][1])) { |
|
135 | + $t = $tokens[$i]; |
|
136 | + if (\T_STRING === $t[0]) { |
|
137 | + $class .= $t[1]; |
|
138 | + } elseif ('' !== $class && \T_WHITESPACE === $t[0]) { |
|
139 | 139 | break; |
140 | 140 | } |
141 | 141 | } |
@@ -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\Util; |
17 | 17 | |
@@ -87,8 +87,7 @@ discard block |
||
87 | 87 | return \unlink($source); |
88 | 88 | } |
89 | 89 | |
90 | - $files = new RecursiveIteratorIterator |
|
91 | - ( |
|
90 | + $files = new RecursiveIteratorIterator( |
|
92 | 91 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
93 | 92 | RecursiveIteratorIterator::CHILD_FIRST |
94 | 93 | ); |
@@ -138,8 +137,8 @@ discard block |
||
138 | 137 | /** |
139 | 138 | * Allows to dereference char |
140 | 139 | */ |
141 | - $__FILE__ = \preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc. |
|
142 | - $prefix = $__FILE__[ 0 ] === \DIRECTORY_SEPARATOR ? \DIRECTORY_SEPARATOR : ''; |
|
140 | + $__FILE__ = \preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__); // remove file protocols such as "phar://" etc. |
|
141 | + $prefix = $__FILE__[0] === \DIRECTORY_SEPARATOR ? \DIRECTORY_SEPARATOR : ''; |
|
143 | 142 | return $prefix . \implode(\DIRECTORY_SEPARATOR, $absolutes); |
144 | 143 | } |
145 | 144 | } |
146 | 145 | \ 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\IO; |
17 | 17 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | { |
57 | 57 | $securityKey = $this->getConfig()->getSecurityKey(); |
58 | 58 | if (!$securityKey || \mb_strtolower($securityKey) === 'auto') { |
59 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
60 | - $securityKey = \preg_replace('/^www./', '', \strtolower(\str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
59 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
60 | + $securityKey = \preg_replace('/^www./', '', \strtolower(\str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
61 | 61 | } else { |
62 | 62 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
63 | 63 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | return $full_path; |
101 | 101 | } |
102 | 102 | |
103 | - if (!isset($this->tmp[ $full_path_hash ]) || (!@\file_exists($full_path) || !@\is_writable($full_path))) { |
|
103 | + if (!isset($this->tmp[$full_path_hash]) || (!@\file_exists($full_path) || !@\is_writable($full_path))) { |
|
104 | 104 | if (!@\file_exists($full_path)) { |
105 | 105 | @mkdir($full_path, $this->getDefaultChmod(), true); |
106 | 106 | } else if (!@\is_writable($full_path)) { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | throw new PhpfastcacheIOException('Path "' . $full_path . '" is not writable, please set a chmod 0777 or any writable permission and make sure to make use of an absolute path !'); |
126 | 126 | } |
127 | 127 | |
128 | - $this->tmp[ $full_path_hash ] = $full_path; |
|
128 | + $this->tmp[$full_path_hash] = $full_path; |
|
129 | 129 | $this->htaccessGen($full_path, \array_key_exists('htaccess', $this->getConfig()) ? $this->getConfig()->getHtaccess() : false); |
130 | 130 | } |
131 | 131 |
@@ -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 | |
@@ -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 | } |
@@ -419,10 +419,10 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public static function getDriverClass(string $driverName): string |
421 | 421 | { |
422 | - if (!empty(self::$driverCustoms[ $driverName ])) { |
|
423 | - $driverClass = self::$driverCustoms[ $driverName ]; |
|
424 | - } else if (!empty(self::$driverOverrides[ $driverName ])) { |
|
425 | - $driverClass = self::$driverOverrides[ $driverName ]; |
|
422 | + if (!empty(self::$driverCustoms[$driverName])) { |
|
423 | + $driverClass = self::$driverCustoms[$driverName]; |
|
424 | + } else if (!empty(self::$driverOverrides[$driverName])) { |
|
425 | + $driverClass = self::$driverOverrides[$driverName]; |
|
426 | 426 | } else { |
427 | 427 | $driverClass = self::getNamespacePath() . $driverName . '\Driver'; |
428 | 428 | } |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | ); |
453 | 453 | } |
454 | 454 | |
455 | - if (!empty(self::$driverCustoms[ $driverName ])) { |
|
455 | + if (!empty(self::$driverCustoms[$driverName])) { |
|
456 | 456 | throw new PhpfastcacheLogicException(\sprintf("Driver '%s' has been already added", $driverName)); |
457 | 457 | } |
458 | 458 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | throw new PhpfastcacheLogicException(\sprintf("Driver '%s' is already a part of the PhpFastCache core", $driverName)); |
461 | 461 | } |
462 | 462 | |
463 | - self::$driverCustoms[ $driverName ] = $className; |
|
463 | + self::$driverCustoms[$driverName] = $className; |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -477,11 +477,11 @@ discard block |
||
477 | 477 | throw new PhpfastcacheInvalidArgumentException("Can't remove a custom driver because its name is empty"); |
478 | 478 | } |
479 | 479 | |
480 | - if (!isset(self::$driverCustoms[ $driverName ])) { |
|
480 | + if (!isset(self::$driverCustoms[$driverName])) { |
|
481 | 481 | throw new PhpfastcacheLogicException(\sprintf("Driver '%s' does not exists", $driverName)); |
482 | 482 | } |
483 | 483 | |
484 | - unset(self::$driverCustoms[ $driverName ]); |
|
484 | + unset(self::$driverCustoms[$driverName]); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | ); |
507 | 507 | } |
508 | 508 | |
509 | - if (!empty(self::$driverOverrides[ $driverName ])) { |
|
509 | + if (!empty(self::$driverOverrides[$driverName])) { |
|
510 | 510 | throw new PhpfastcacheLogicException(\sprintf("Driver '%s' has been already overridden", $driverName)); |
511 | 511 | } |
512 | 512 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | ); |
522 | 522 | } |
523 | 523 | |
524 | - self::$driverOverrides[ $driverName ] = $className; |
|
524 | + self::$driverOverrides[$driverName] = $className; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -538,10 +538,10 @@ discard block |
||
538 | 538 | throw new PhpfastcacheInvalidArgumentException("Can't remove a core driver override because its name is empty"); |
539 | 539 | } |
540 | 540 | |
541 | - if (!isset(self::$driverOverrides[ $driverName ])) { |
|
541 | + if (!isset(self::$driverOverrides[$driverName])) { |
|
542 | 542 | throw new PhpfastcacheLogicException(\sprintf("Driver '%s' were not overridden", $driverName)); |
543 | 543 | } |
544 | 544 | |
545 | - unset(self::$driverOverrides[ $driverName ]); |
|
545 | + unset(self::$driverOverrides[$driverName]); |
|
546 | 546 | } |
547 | 547 | } |