@@ -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 @@ |
||
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\Exceptions; |
17 | 17 |
@@ -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 | |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if (is_array($config)) { |
103 | 103 | $config = new ConfigurationOption($config); |
104 | 104 | trigger_error( |
105 | - 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
106 | - E_USER_DEPRECATED |
|
105 | + 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
106 | + E_USER_DEPRECATED |
|
107 | 107 | ); |
108 | 108 | }elseif ($config === null){ |
109 | 109 | $config = self::getDefaultConfig(); |
@@ -304,27 +304,27 @@ discard block |
||
304 | 304 | { |
305 | 305 | 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); |
306 | 306 | return [ |
307 | - 'Apc', |
|
308 | - 'Apcu', |
|
309 | - 'Cassandra', |
|
310 | - 'Couchbase', |
|
311 | - 'Couchdb', |
|
312 | - 'Devnull', |
|
313 | - 'Files', |
|
314 | - 'Leveldb', |
|
315 | - 'Memcache', |
|
316 | - 'Memcached', |
|
317 | - 'Memstatic', |
|
318 | - 'Mongodb', |
|
319 | - 'Predis', |
|
320 | - 'Redis', |
|
321 | - 'Riak', |
|
322 | - 'Ssdb', |
|
323 | - 'Sqlite', |
|
324 | - 'Wincache', |
|
325 | - 'Xcache', |
|
326 | - 'Zenddisk', |
|
327 | - 'Zendshm', |
|
307 | + 'Apc', |
|
308 | + 'Apcu', |
|
309 | + 'Cassandra', |
|
310 | + 'Couchbase', |
|
311 | + 'Couchdb', |
|
312 | + 'Devnull', |
|
313 | + 'Files', |
|
314 | + 'Leveldb', |
|
315 | + 'Memcache', |
|
316 | + 'Memcached', |
|
317 | + 'Memstatic', |
|
318 | + 'Mongodb', |
|
319 | + 'Predis', |
|
320 | + 'Redis', |
|
321 | + 'Riak', |
|
322 | + 'Ssdb', |
|
323 | + 'Sqlite', |
|
324 | + 'Wincache', |
|
325 | + 'Xcache', |
|
326 | + 'Zenddisk', |
|
327 | + 'Zendshm', |
|
328 | 328 | ]; |
329 | 329 | } |
330 | 330 | |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | { |
337 | 337 | 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); |
338 | 338 | return \array_merge(self::getStaticSystemDrivers(), [ |
339 | - 'Devtrue', |
|
340 | - 'Devfalse', |
|
341 | - 'Cookie', |
|
339 | + 'Devtrue', |
|
340 | + 'Devfalse', |
|
341 | + 'Cookie', |
|
342 | 342 | ]); |
343 | 343 | } |
344 | 344 |
@@ -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 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
106 | 106 | E_USER_DEPRECATED |
107 | 107 | ); |
108 | - }elseif ($config === null){ |
|
108 | + }elseif ($config === null) { |
|
109 | 109 | $config = self::getDefaultConfig(); |
110 | - }else if(!($config instanceof ConfigurationOption)){ |
|
110 | + } else if (!($config instanceof ConfigurationOption)) { |
|
111 | 111 | throw new PhpfastcacheInvalidArgumentException(sprintf('Unsupported config type: %s', gettype($config))); |
112 | 112 | } |
113 | 113 | |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | |
120 | 120 | $instance = $instanceId ?: md5($driver . \serialize($config->toArray())); |
121 | 121 | |
122 | - if (!isset(self::$instances[ $instance ])) { |
|
123 | - $badPracticeOmeter[ $driver ] = 1; |
|
122 | + if (!isset(self::$instances[$instance])) { |
|
123 | + $badPracticeOmeter[$driver] = 1; |
|
124 | 124 | $driverClass = self::getNamespacePath() . $driver . '\Driver'; |
125 | 125 | try { |
126 | 126 | if (\class_exists($driverClass)) { |
127 | 127 | $configClass = $driverClass::getConfigClass(); |
128 | - self::$instances[ $instance ] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
129 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
128 | + self::$instances[$instance] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
129 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
130 | 130 | } else { |
131 | 131 | throw new PhpfastcacheDriverNotFoundException(sprintf('The driver "%s" does not exists', $driver)); |
132 | 132 | } |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
145 | 145 | } |
146 | 146 | } |
147 | - } else if ($badPracticeOmeter[ $driver ] >= 2) { |
|
147 | + } else if ($badPracticeOmeter[$driver] >= 2) { |
|
148 | 148 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
149 | 149 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
150 | 150 | } |
151 | 151 | |
152 | - $badPracticeOmeter[ $driver ]++; |
|
152 | + $badPracticeOmeter[$driver]++; |
|
153 | 153 | |
154 | - return self::$instances[ $instance ]; |
|
154 | + return self::$instances[$instance]; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string'); |
169 | 169 | } |
170 | 170 | |
171 | - if (isset(self::$instances[ $instanceId ])) { |
|
172 | - return self::$instances[ $instanceId ]; |
|
171 | + if (isset(self::$instances[$instanceId])) { |
|
172 | + return self::$instances[$instanceId]; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | throw new PhpfastcacheInstanceNotFoundException(sprintf('Instance ID %s not found', $instanceId)); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - if(!$autoDriver || !\is_string($autoDriver)){ |
|
229 | + if (!$autoDriver || !\is_string($autoDriver)) { |
|
230 | 230 | throw new PhpfastcacheLogicException('Unable to find out a valid driver automatically'); |
231 | 231 | } |
232 | 232 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public static function __callStatic(string $name, array $arguments): ExtendedCacheItemPoolInterface |
242 | 242 | { |
243 | - $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []); |
|
243 | + $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []); |
|
244 | 244 | |
245 | 245 | return self::getInstance($name, $options); |
246 | 246 | } |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | { |
351 | 351 | static $driverList; |
352 | 352 | |
353 | - if(self::getDefaultNamespacePath() === self::getNamespacePath()){ |
|
354 | - if($driverList === null){ |
|
353 | + if (self::getDefaultNamespacePath() === self::getNamespacePath()) { |
|
354 | + if ($driverList === null) { |
|
355 | 355 | $prefix = 'Phpfastcache\Drivers\\'; |
356 | 356 | $classMap = self::createClassMap(__DIR__ . '/Drivers'); |
357 | 357 | $driverList = []; |
358 | 358 | |
359 | 359 | foreach ($classMap as $class => $file) { |
360 | - $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\') )); |
|
360 | + $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\'))); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | $driverList = array_values(array_unique($driverList)); |