Skip to content

Commit 80aa467

Browse files
committed
Enforced PSR12 compliance
1 parent ed9afa1 commit 80aa467

112 files changed

Lines changed: 678 additions & 368 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Total Downloads](https://img.shields.io/packagist/dt/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Latest Stable Version](https://img.shields.io/packagist/v/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![License](https://img.shields.io/packagist/l/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Coding Standards](https://img.shields.io/badge/CI-PSR6-orange.svg?maxAge=86400)](https://github.com/php-fig/cache) [![Coding Standards](https://img.shields.io/badge/CS-PSR16-orange.svg?maxAge=86400)](https://github.com/php-fig/simple-cache)
1+
[![Total Downloads](https://img.shields.io/packagist/dt/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Latest Stable Version](https://img.shields.io/packagist/v/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![License](https://img.shields.io/packagist/l/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Cache Interface](https://img.shields.io/badge/CI-PSR6-orange.svg?maxAge=86400)](https://github.com/php-fig/cache) [![Extended Coding Style](https://img.shields.io/badge/ECS-PSR12-orange.svg?maxAge=86400)](https://www.php-fig.org/psr/psr-12/) [![Simple Cache](https://img.shields.io/badge/SC-PSR16-orange.svg?maxAge=86400)](https://github.com/php-fig/simple-cache)
22
[![Code Climate](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache/badges/gpa.svg)](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache/?branch=master) [![Build Status](https://travis-ci.org/PHPSocialNetwork/phpfastcache.svg?branch=master)](https://travis-ci.org/PHPSocialNetwork/phpfastcache) [![Semver compliant](https://img.shields.io/badge/Semver-2.0.0-yellow.svg?maxAge=86400)](https://semver.org/spec/v2.0.0.html) [![Patreon](https://img.shields.io/badge/Support%20us%20on-Patreon-f96854.svg?maxAge=86400)](https://www.patreon.com/geolim4)
33

44
#### :warning: Please note that the V8 is an important (with small BC breaking) update of PhpFastCache !

bin/ci/run_tests.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
define('PFC_TEST_DIR', \realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests'));
1010

11+
$timestamp = microtime(true);
1112
$climate = new League\CLImate\CLImate;
1213
$climate->forceAnsiOn();
1314
$status = 0;
@@ -53,6 +54,9 @@
5354
unset($output);
5455
}
5556

57+
$execTime = gmdate('i\m s\s', (int) round(microtime(true) - $timestamp, 3));
58+
$climate->out('<yellow>Total tests duration: </yellow><light_green>' . $execTime . '</light_green>');
59+
5660
if ($status === 0) {
5761
$climate->backgroundGreen()->white()->flank('[OK] The build has passed successfully', '#')->out('');
5862
} else {

lib/Phpfastcache/Api.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
*
45
* This file is part of phpFastCache.
@@ -101,7 +102,9 @@ public static function getPhpFastCacheVersion(bool $fallbackOnChangelog = true,
101102
}
102103
throw new PhpfastcacheLogicException('Unable to retrieve the PhpFastCache version through the CHANGELOG.md as no valid string were found in it.');
103104
}
104-
throw new PhpfastcacheLogicException('shell_exec being disabled we attempted to retrieve the PhpFastCache version through the CHANGELOG.md file but it is not readable or has been removed.');
105+
throw new PhpfastcacheLogicException(
106+
'shell_exec being disabled we attempted to retrieve the PhpFastCache version through the CHANGELOG.md file but it is not readable or has been removed.'
107+
);
105108
}
106109

107110
/**

lib/Phpfastcache/Autoload/Autoload.php

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace Phpfastcache\Autoload;
@@ -23,45 +24,47 @@
2324
/**
2425
* Register Autoload
2526
*/
26-
spl_autoload_register(static function ($entity): void {
27-
$module = explode('\\', $entity, 2);
28-
if (!in_array($module[0], ['Phpfastcache', 'Psr'])) {
29-
/**
30-
* Not a part of phpFastCache file
31-
* then we return here.
32-
*/
33-
return;
34-
}
27+
spl_autoload_register(
28+
static function ($entity): void {
29+
$module = explode('\\', $entity, 2);
30+
if (!in_array($module[0], ['Phpfastcache', 'Psr'])) {
31+
/**
32+
* Not a part of phpFastCache file
33+
* then we return here.
34+
*/
35+
return;
36+
}
3537

36-
if (strpos($entity, 'Psr\Cache') === 0) {
37-
$path = PFC_BIN_DIR . 'dependencies/Psr/Cache/src/' . substr(strrchr($entity, '\\'), 1) . '.' . PFC_PHP_EXT;
38+
if (strpos($entity, 'Psr\Cache') === 0) {
39+
$path = PFC_BIN_DIR . 'dependencies/Psr/Cache/src/' . substr(strrchr($entity, '\\'), 1) . '.' . PFC_PHP_EXT;
3840

39-
if (is_readable($path)) {
40-
require_once $path;
41-
} else {
42-
trigger_error('Cannot locate the Psr/Cache files', E_USER_ERROR);
41+
if (is_readable($path)) {
42+
require_once $path;
43+
} else {
44+
trigger_error('Cannot locate the Psr/Cache files', E_USER_ERROR);
45+
}
46+
return;
4347
}
44-
return;
45-
}
4648

47-
if (strpos($entity, 'Psr\SimpleCache') === 0) {
48-
$path = PFC_BIN_DIR . 'dependencies/Psr/SimpleCache/src/' . substr(strrchr($entity, '\\'), 1) . '.' . PFC_PHP_EXT;
49+
if (strpos($entity, 'Psr\SimpleCache') === 0) {
50+
$path = PFC_BIN_DIR . 'dependencies/Psr/SimpleCache/src/' . substr(strrchr($entity, '\\'), 1) . '.' . PFC_PHP_EXT;
4951

50-
if (is_readable($path)) {
51-
require_once $path;
52-
} else {
53-
trigger_error('Cannot locate the Psr/SimpleCache files', E_USER_ERROR);
52+
if (is_readable($path)) {
53+
require_once $path;
54+
} else {
55+
trigger_error('Cannot locate the Psr/SimpleCache files', E_USER_ERROR);
56+
}
57+
return;
5458
}
55-
return;
56-
}
5759

58-
$entity = str_replace('\\', '/', $entity);
59-
$path = PFC_LIB_DIR . $entity . '.' . PFC_PHP_EXT;
60+
$entity = str_replace('\\', '/', $entity);
61+
$path = PFC_LIB_DIR . $entity . '.' . PFC_PHP_EXT;
6062

61-
if (is_readable($path)) {
62-
require_once $path;
63+
if (is_readable($path)) {
64+
require_once $path;
65+
}
6366
}
64-
});
67+
);
6568

6669
if ((!defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && class_exists(ClassLoader::class)) {
6770
trigger_error(

lib/Phpfastcache/CacheManager.php

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
*
45
* This file is part of phpFastCache.
@@ -191,8 +192,10 @@ public static function getInstance(string $driver, ?ConfigurationOptionInterface
191192
}
192193
} else {
193194
if (self::$badPracticeOmeter[$driver] >= 2) {
194-
trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
195-
See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F');
195+
trigger_error(
196+
'[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
197+
See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'
198+
);
196199
}
197200
}
198201

@@ -248,11 +251,13 @@ public static function standardizeDriverName(string $driverName): string
248251
protected static function validateDriverClass(string $driverClass): string
249252
{
250253
if (!\is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)) {
251-
throw new PhpfastcacheDriverException(\sprintf(
252-
'Class "%s" does not implement "%s"',
253-
$driverClass,
254-
ExtendedCacheItemPoolInterface::class
255-
));
254+
throw new PhpfastcacheDriverException(
255+
\sprintf(
256+
'Class "%s" does not implement "%s"',
257+
$driverClass,
258+
ExtendedCacheItemPoolInterface::class
259+
)
260+
);
256261
}
257262
return $driverClass;
258263
}
@@ -311,13 +316,18 @@ public static function clearInstances(): bool
311316
public static function clearInstance(ExtendedCacheItemPoolInterface $cachePoolInstance): bool
312317
{
313318
$found = false;
314-
self::$instances = \array_filter(\array_map(static function (ExtendedCacheItemPoolInterface $cachePool) use ($cachePoolInstance, &$found) {
315-
if (\spl_object_hash($cachePool) === \spl_object_hash($cachePoolInstance)) {
316-
$found = true;
317-
return null;
318-
}
319-
return $cachePool;
320-
}, self::$instances));
319+
self::$instances = \array_filter(
320+
\array_map(
321+
static function (ExtendedCacheItemPoolInterface $cachePool) use ($cachePoolInstance, &$found) {
322+
if (\spl_object_hash($cachePool) === \spl_object_hash($cachePoolInstance)) {
323+
$found = true;
324+
return null;
325+
}
326+
return $cachePool;
327+
},
328+
self::$instances
329+
)
330+
);
321331

322332
return $found;
323333
}
@@ -459,8 +469,12 @@ public static function addCoreDriverOverride(string $driverName, string $classNa
459469

460470
if (!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)) {
461471
throw new PhpfastcacheLogicException(
462-
\sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className,
463-
self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver')
472+
\sprintf(
473+
"Can't override '%s' because the class '%s' MUST extend '%s'",
474+
$driverName,
475+
$className,
476+
self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver'
477+
)
464478
);
465479
}
466480

lib/Phpfastcache/Cluster/AggregatablePoolInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
*
45
* This file is part of phpFastCache.

lib/Phpfastcache/Cluster/AggregatorInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
*
45
* This file is part of phpFastCache.

lib/Phpfastcache/Cluster/ClusterAggregator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
*
45
* This file is part of phpFastCache.

lib/Phpfastcache/Cluster/ClusterPoolAbstract.php

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
*
45
* This file is part of phpFastCache.
@@ -38,7 +39,8 @@
3839
*/
3940
abstract class ClusterPoolAbstract implements ClusterPoolInterface
4041
{
41-
use DriverBaseTrait, ClusterPoolTrait {
42+
use DriverBaseTrait;
43+
use ClusterPoolTrait {
4244
DriverBaseTrait::__construct as private __parentConstruct;
4345
}
4446

@@ -191,17 +193,41 @@ protected function getStandardizedItem(ExtendedCacheItemInterface $item, Extende
191193
public function getStats(): DriverStatistic
192194
{
193195
$stats = new DriverStatistic();
194-
$stats->setInfo(sprintf('Using %d pool(s): %s', \count($this->clusterPools), \implode(', ', \array_map(static function (ExtendedCacheItemPoolInterface $pool) {
195-
return \get_class($pool);
196-
}, $this->clusterPools))));
197-
198-
$stats->setSize((int) \array_sum(\array_map(static function (ExtendedCacheItemPoolInterface $pool) {
199-
return $pool->getStats()->getSize();
200-
}, $this->clusterPools)));
201-
202-
$stats->setData((int) \array_map(static function (ExtendedCacheItemPoolInterface $pool) {
203-
return $pool->getStats()->getData();
204-
}, $this->clusterPools));
196+
$stats->setInfo(
197+
sprintf(
198+
'Using %d pool(s): %s',
199+
\count($this->clusterPools),
200+
\implode(
201+
', ',
202+
\array_map(
203+
static function (ExtendedCacheItemPoolInterface $pool) {
204+
return \get_class($pool);
205+
},
206+
$this->clusterPools
207+
)
208+
)
209+
)
210+
);
211+
212+
$stats->setSize(
213+
(int)\array_sum(
214+
\array_map(
215+
static function (ExtendedCacheItemPoolInterface $pool) {
216+
return $pool->getStats()->getSize();
217+
},
218+
$this->clusterPools
219+
)
220+
)
221+
);
222+
223+
$stats->setData(
224+
(int)\array_map(
225+
static function (ExtendedCacheItemPoolInterface $pool) {
226+
return $pool->getStats()->getData();
227+
},
228+
$this->clusterPools
229+
)
230+
);
205231

206232
return $stats;
207233
}

lib/Phpfastcache/Cluster/ClusterPoolInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
*
45
* This file is part of phpFastCache.

0 commit comments

Comments
 (0)