|
1 | 1 | <?php |
| 2 | + |
2 | 3 | declare(strict_types=1); |
3 | 4 |
|
4 | 5 | namespace Phpfastcache\Autoload; |
|
23 | 24 | /** |
24 | 25 | * Register Autoload |
25 | 26 | */ |
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 | + } |
35 | 37 |
|
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; |
38 | 40 |
|
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; |
43 | 47 | } |
44 | | - return; |
45 | | - } |
46 | 48 |
|
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; |
49 | 51 |
|
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; |
54 | 58 | } |
55 | | - return; |
56 | | - } |
57 | 59 |
|
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; |
60 | 62 |
|
61 | | - if (is_readable($path)) { |
62 | | - require_once $path; |
| 63 | + if (is_readable($path)) { |
| 64 | + require_once $path; |
| 65 | + } |
63 | 66 | } |
64 | | -}); |
| 67 | +); |
65 | 68 |
|
66 | 69 | if ((!defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && class_exists(ClassLoader::class)) { |
67 | 70 | trigger_error( |
|
0 commit comments