Skip to content

Commit f313197

Browse files
committed
Capitalized Phpfastcache classe names
1 parent ebd8428 commit f313197

File tree

94 files changed

+595
-559
lines changed

Some content is hidden

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

94 files changed

+595
-559
lines changed

bin/ci/run_tests.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,54 @@
33
* @author Khoa Bui (khoaofgod) <[email protected]> http://www.phpfastcache.com
44
* @author Georges.L (Geolim4) <[email protected]>
55
*/
6+
declare(strict_types=1);
67

7-
function glob_recursive($pattern, $flags = 0)
8+
define('PFC_TEST_DIR', \realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests'));
9+
10+
/**
11+
* @param string $pattern
12+
* @param int $flags
13+
* @return array
14+
*/
15+
function phpfastcache_glob_recursive(string $pattern, int $flags = 0): array
816
{
9-
$files = glob($pattern, $flags);
17+
$files = \glob($pattern, $flags);
1018

11-
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir)
12-
{
13-
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
19+
foreach (\glob(\dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
20+
$files = \array_merge($files, phpfastcache_glob_recursive($dir . '/' . \basename($pattern), $flags));
1421
}
1522

1623
return $files;
1724
}
1825

1926
$status = 0;
20-
$driver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
21-
$testDir = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests');
27+
$driver = $argv[ 1 ] ?? 'Files';
2228

23-
foreach (glob_recursive($testDir . DIRECTORY_SEPARATOR . '*.test.php') as $filename) {
29+
foreach (phpfastcache_glob_recursive(PFC_TEST_DIR . DIRECTORY_SEPARATOR . '*.test.php') as $filename) {
2430
echo "\e[97m--\n";
2531
$command = "php -f {$filename} {$driver}";
26-
echo "\e[33mphpfastcache@test \e[34m~ \e[92m# \e[91m" . $command . "\n";
27-
exec ($command, $output, $return_var);
32+
echo "\e[33mphpfastcache@test \e[34m" . __DIR__ . " \e[92m# \e[91m" . $command . "\n";
33+
exec($command, $output, $return_var);
2834
echo "=====================================\n";
29-
echo "\e[95m" . implode("\n", $output) . "\n";
35+
echo "\e[95m" . \implode("\n", $output) . "\n";
3036
echo "=====================================\n";
31-
if($return_var === 0){
37+
if ($return_var === 0) {
3238
echo "\e[32mProcess finished with exit code $return_var";
33-
}else{
39+
} else {
3440
echo "\e[31mProcess finished with exit code $return_var";
3541
$status = 255;
3642
}
37-
echo "\n\n\n\n";
43+
echo \str_repeat(PHP_EOL, 3);
3844
/**
3945
* Reset $output to prevent override effects
4046
*/
4147
unset($output);
4248
}
4349

50+
if ($status === 0) {
51+
echo "\e[32m[OK] The build has passed successfully";
52+
} else {
53+
echo "\e[31m[KO] The build has failed miserably";
54+
}
55+
4456
exit($status);

docs/examples/extendedPhpFastCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace MyCustom\Project;
1616

1717
use Phpfastcache\Drivers\Files\Driver as FilesDriver;
18-
use Phpfastcache\Proxy\phpFastCacheAbstractProxy;
18+
use Phpfastcache\Proxy\PhpfastcacheAbstractProxy;
1919

2020
/**
2121
* Specific driver-based example
@@ -40,7 +40,7 @@ public function __construct(array $config = [])
4040
* Class myCustomCacheClass
4141
* @package MyCustom\Project
4242
*/
43-
class myCustomCacheClass extends phpFastCacheAbstractProxy
43+
class myCustomCacheClass extends PhpfastcacheAbstractProxy
4444
{
4545
public function __construct($driver = '', array $config = [])
4646
{

docs/migration/MigratingFromV6ToV7.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ We used to declare this namespace: `namespace phpFastCache;` or `use phpFastCach
1010
The time has changed, you now have to use: `namespace Phpfastcache;` or `use Phpfastcache\...;`
1111
For any useful purpose, the `src/` directory has been moved along to `lib/`.
1212

13+
### :warning: Phpfastcache "phpFastCache*" classes :warning:
14+
As of the V7 and to comply with modern standards the "phpFastCache*" classes have been **C**apitalized :warning:
15+
16+
#### :clock1: Then:
17+
We used to declare this kind of class: `class phpFastCacheAbstractProxy`
18+
19+
#### :alarm_clock: Now:
20+
The time has changed, you now have to use: `class PhpfastcacheAbstractProxy`
21+
For any useful purpose, all the PhpFastCache exceptions has been **C**apitalized.
22+
Class `Phpfastcache\Exceptions\phpFastCache[...]Exception` have been renamed to `Phpfastcache\Exceptions\Phpfastcache[...]Exception`
23+
1324
### Return type & Scalar type declarations
1425
:anger: :exclamation: The V7 will make use of new php's return type & scalars type declarations features.
1526
This means that you will now have to be very careful about the data types that you are sending to the phpFastCache API.

lib/Phpfastcache/Api.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
namespace Phpfastcache;
1717

18-
use Phpfastcache\Exceptions\phpFastCacheIOException;
19-
use Phpfastcache\Exceptions\phpFastCacheLogicException;
18+
use Phpfastcache\Exceptions\PhpfastcacheIOException;
19+
use Phpfastcache\Exceptions\PhpfastcacheLogicException;
2020

2121
/**
2222
* Class Api
@@ -53,8 +53,8 @@ public static function getVersion(): string
5353
* @param bool $fallbackOnChangelog
5454
* @param bool $cacheable
5555
* @return string
56-
* @throws \Phpfastcache\Exceptions\phpFastCacheLogicException
57-
* @throws \Phpfastcache\Exceptions\phpFastCacheIOException
56+
* @throws \Phpfastcache\Exceptions\PhpfastcacheLogicException
57+
* @throws \Phpfastcache\Exceptions\PhpfastcacheIOException
5858
*/
5959
public static function getPhpFastCacheVersion($fallbackOnChangelog = true, $cacheable = true): string
6060
{
@@ -74,11 +74,11 @@ public static function getPhpFastCacheVersion($fallbackOnChangelog = true, $cach
7474
$version = \trim($stdout);
7575
return $version;
7676
}
77-
throw new phpFastCacheLogicException('The git command used to retrieve the PhpFastCache version has failed.');
77+
throw new PhpfastcacheLogicException('The git command used to retrieve the PhpFastCache version has failed.');
7878
}
7979

8080
if(!$fallbackOnChangelog){
81-
throw new phpFastCacheLogicException('shell_exec is disabled therefore the PhpFastCache version cannot be retrieved.');
81+
throw new PhpfastcacheLogicException('shell_exec is disabled therefore the PhpFastCache version cannot be retrieved.');
8282
}
8383

8484
$changelogFilename = __DIR__ . '/../../CHANGELOG.md';
@@ -91,9 +91,9 @@ public static function getPhpFastCacheVersion($fallbackOnChangelog = true, $cach
9191
return $version;
9292
}
9393
}
94-
throw new phpFastCacheLogicException('Unable to retrieve the PhpFastCache version through the CHANGELOG.md as no valid string were found in it.');
94+
throw new PhpfastcacheLogicException('Unable to retrieve the PhpFastCache version through the CHANGELOG.md as no valid string were found in it.');
9595
}
96-
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.');
96+
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.');
9797
}
9898

9999
/**
@@ -122,8 +122,8 @@ public static function getPhpFastCacheGitHeadHash($cacheable = true): string
122122
/**
123123
* Return the API changelog, as a string.
124124
* @return string
125-
* @throws phpFastCacheLogicException
126-
* @throws phpFastCacheIOException
125+
* @throws PhpfastcacheLogicException
126+
* @throws PhpfastcacheIOException
127127
*/
128128
public static function getChangelog(): string
129129
{
@@ -133,16 +133,16 @@ public static function getChangelog(): string
133133
if($string){
134134
return $string;
135135
}
136-
throw new phpFastCacheLogicException('Unable to retrieve the PhpFastCache API changelog as it seems to be empty.');
136+
throw new PhpfastcacheLogicException('Unable to retrieve the PhpFastCache API changelog as it seems to be empty.');
137137
}
138-
throw new phpFastCacheIOException('The CHANGELOG_API.md file is not readable or has been removed.');
138+
throw new PhpfastcacheIOException('The CHANGELOG_API.md file is not readable or has been removed.');
139139
}
140140

141141
/**
142142
* Return the PhpFastCache changelog, as a string.
143143
* @return string
144-
* @throws phpFastCacheLogicException
145-
* @throws phpFastCacheIOException
144+
* @throws PhpfastcacheLogicException
145+
* @throws PhpfastcacheIOException
146146
*/
147147
public static function getPhpFastCacheChangelog(): string
148148
{
@@ -152,8 +152,8 @@ public static function getPhpFastCacheChangelog(): string
152152
if($string){
153153
return $string;
154154
}
155-
throw new phpFastCacheLogicException('Unable to retrieve the PhpFastCache changelog as it seems to be empty.');
155+
throw new PhpfastcacheLogicException('Unable to retrieve the PhpFastCache changelog as it seems to be empty.');
156156
}
157-
throw new phpFastCacheIOException('The CHANGELOG.md file is not readable or has been removed.');
157+
throw new PhpfastcacheIOException('The CHANGELOG.md file is not readable or has been removed.');
158158
}
159159
}

lib/Phpfastcache/CacheManager.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Phpfastcache\Config\ConfigurationOption;
1919
use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
2020
use Phpfastcache\Exceptions\{
21-
phpFastCacheDeprecatedException, phpFastCacheDriverCheckException, phpFastCacheDriverNotFoundException, phpFastCacheInstanceNotFoundException, phpFastCacheInvalidArgumentException, phpFastCacheInvalidConfigurationException
21+
PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException
2222
};
2323

2424
/**
@@ -83,17 +83,17 @@ class CacheManager
8383
*
8484
* @return ExtendedCacheItemPoolInterface
8585
*
86-
* @throws phpFastCacheDriverCheckException
87-
* @throws phpFastCacheInvalidConfigurationException
88-
* @throws phpFastCacheDriverNotFoundException
89-
* @throws phpFastCacheInvalidArgumentException
86+
* @throws PhpfastcacheDriverCheckException
87+
* @throws PhpfastcacheInvalidConfigurationException
88+
* @throws PhpfastcacheDriverNotFoundException
89+
* @throws PhpfastcacheInvalidArgumentException
9090
*/
9191
public static function getInstance($driver = 'auto', $config = null, $instanceId = null)
9292
{
9393
static $badPracticeOmeter = [];
9494

9595
if ($instanceId !== null && !\is_string($instanceId)) {
96-
throw new phpFastCacheInvalidArgumentException('The Instance ID must be a string');
96+
throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string');
9797
}
9898

9999
if (is_array($config)) {
@@ -105,7 +105,7 @@ public static function getInstance($driver = 'auto', $config = null, $instanceId
105105
}elseif ($config === null){
106106
$config = self::getDefaultConfig();
107107
}else if(!($config instanceof ConfigurationOption)){
108-
throw new phpFastCacheInvalidArgumentException(sprintf('Unsupported config type: %s', gettype($config)));
108+
throw new PhpfastcacheInvalidArgumentException(sprintf('Unsupported config type: %s', gettype($config)));
109109
}
110110

111111
$driver = self::standardizeDriverName($driver);
@@ -125,21 +125,21 @@ public static function getInstance($driver = 'auto', $config = null, $instanceId
125125
self::$instances[ $instance ] = new $driverClass(new $configClass($config->toArray()), $instance);
126126
self::$instances[ $instance ]->setEventManager(EventManager::getInstance());
127127
} else {
128-
throw new phpFastCacheDriverNotFoundException(sprintf('The driver "%s" does not exists', $driver));
128+
throw new PhpfastcacheDriverNotFoundException(sprintf('The driver "%s" does not exists', $driver));
129129
}
130-
} catch (phpFastCacheDriverCheckException $e) {
130+
} catch (PhpfastcacheDriverCheckException $e) {
131131
if ($config->getFallback()) {
132132
try {
133133

134134
$fallback = $config->getFallback();
135135
$config->setFallback('');
136136
trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING);
137137
return self::getInstance($fallback, $config);
138-
} catch (phpFastCacheInvalidArgumentException $e) {
139-
throw new phpFastCacheInvalidConfigurationException('Invalid fallback driver configuration', 0, $e);
138+
} catch (PhpfastcacheInvalidArgumentException $e) {
139+
throw new PhpfastcacheInvalidConfigurationException('Invalid fallback driver configuration', 0, $e);
140140
}
141141
} else {
142-
throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
142+
throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
143143
}
144144
}
145145
} else if ($badPracticeOmeter[ $driver ] >= 2) {
@@ -157,20 +157,20 @@ public static function getInstance($driver = 'auto', $config = null, $instanceId
157157
*
158158
* @return ExtendedCacheItemPoolInterface
159159
*
160-
* @throws phpFastCacheInvalidArgumentException
161-
* @throws phpFastCacheInstanceNotFoundException
160+
* @throws PhpfastcacheInvalidArgumentException
161+
* @throws PhpfastcacheInstanceNotFoundException
162162
*/
163163
public static function getInstanceById($instanceId): ExtendedCacheItemPoolInterface
164164
{
165165
if ($instanceId !== null && !\is_string($instanceId)) {
166-
throw new phpFastCacheInvalidArgumentException('The Instance ID must be a string');
166+
throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string');
167167
}
168168

169169
if (isset(self::$instances[ $instanceId ])) {
170170
return self::$instances[ $instanceId ];
171171
}
172172

173-
throw new phpFastCacheInstanceNotFoundException(sprintf('Instance ID %s not found', $instanceId));
173+
throw new PhpfastcacheInstanceNotFoundException(sprintf('Instance ID %s not found', $instanceId));
174174
}
175175

176176
/**
@@ -206,7 +206,7 @@ public static function &getInternalInstances(): array
206206
* @todo Does we really keep it ??
207207
* @param $config
208208
* @return string
209-
* @throws phpFastCacheDriverCheckException
209+
* @throws PhpfastcacheDriverCheckException
210210
*/
211211
public static function getAutoClass(array $config = [])
212212
{
@@ -218,7 +218,7 @@ public static function getAutoClass(array $config = [])
218218
self::getInstance($driver, $config);
219219
$autoDriver = $driver;
220220
break;
221-
} catch (phpFastCacheDriverCheckException $e) {
221+
} catch (PhpfastcacheDriverCheckException $e) {
222222
continue;
223223
}
224224
}

lib/Phpfastcache/Config/ConfigurationOption.php

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

99
namespace Phpfastcache\Config;
1010

11-
use Phpfastcache\Exceptions\phpFastCacheInvalidConfigurationException;
11+
use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException;
1212
use Phpfastcache\Util\ArrayObject;
1313

1414
class ConfigurationOption extends ArrayObject
@@ -93,7 +93,7 @@ public function __construct(...$args)
9393
* No more kidding now, it's 21th century.
9494
*/
9595
if(array_diff_key($array, get_object_vars($this))){
96-
throw new phpFastCacheInvalidConfigurationException(sprintf(
96+
throw new PhpfastcacheInvalidConfigurationException(sprintf(
9797
'Invalid option(s) for the config %s: %s',
9898
static::class,
9999
implode(', ', array_keys(array_diff_key($array, get_object_vars($this))))
@@ -127,7 +127,7 @@ public function __construct(...$args)
127127
$parameter = $reflectionMethod->getParameters()[0] ?? null;
128128
$typeHintExpected = ($parameter instanceof \ReflectionParameter ? ($parameter->getType() === 'object' ? $parameter->getClass() : $parameter->getType()) : 'Unknown type');
129129

130-
throw new phpFastCacheInvalidConfigurationException(sprintf(
130+
throw new PhpfastcacheInvalidConfigurationException(sprintf(
131131
'Invalid type hint found for "%s", expected "%s" got "%s"',
132132
lcfirst(substr($method, 3)),
133133
$typeHintExpected,
@@ -239,12 +239,12 @@ public function getDefaultKeyHashFunction()
239239
/**
240240
* @param Callable|string $defaultKeyHashFunction
241241
* @return ConfigurationOption
242-
* @throws phpFastCacheInvalidConfigurationException
242+
* @throws PhpfastcacheInvalidConfigurationException
243243
*/
244244
public function setDefaultKeyHashFunction($defaultKeyHashFunction)
245245
{
246246
if (!\function_exists($defaultKeyHashFunction) || !\is_callable($defaultKeyHashFunction)) {
247-
throw new phpFastCacheInvalidConfigurationException('defaultKeyHashFunction must be a valid function name string');
247+
throw new PhpfastcacheInvalidConfigurationException('defaultKeyHashFunction must be a valid function name string');
248248
}
249249
$this->defaultKeyHashFunction = $defaultKeyHashFunction;
250250
return $this;
@@ -387,7 +387,7 @@ public function getCacheFileExtension(): string
387387
/**
388388
* @param string $cacheFileExtension
389389
* @return ConfigurationOption
390-
* @throws phpFastCacheInvalidConfigurationException
390+
* @throws PhpfastcacheInvalidConfigurationException
391391
*/
392392
public function setCacheFileExtension(string $cacheFileExtension): self
393393
{
@@ -403,10 +403,10 @@ public function setCacheFileExtension(string $cacheFileExtension): self
403403
];
404404

405405
if (\strpos($cacheFileExtension, '.') !== false) {
406-
throw new phpFastCacheInvalidConfigurationException('cacheFileExtension cannot contain a dot "."');
406+
throw new PhpfastcacheInvalidConfigurationException('cacheFileExtension cannot contain a dot "."');
407407
}
408408
if (!\in_array($cacheFileExtension, $safeFileExtensions, true)) {
409-
throw new phpFastCacheInvalidConfigurationException(
409+
throw new PhpfastcacheInvalidConfigurationException(
410410
"{$cacheFileExtension} is not a safe extension, currently allowed extension: " . \implode(', ', $safeFileExtensions)
411411
);
412412
}

0 commit comments

Comments
 (0)