1
0
mirror of https://github.com/php/web-php.git synced 2026-03-24 15:22:19 +01:00
Files
archived-web-php/src/autoload.php
Andreas Möller c093fb5382 Enhancement: Enable trailing_comma_in_multiline fixer (#647)
* Enhancement: Enable and configure trailing_comma_in_multiline fixer

* Fix: Run 'make coding-standards'
2023-12-06 23:16:28 +00:00

29 lines
613 B
PHP

<?php
/**
* @see https://github.com/php-fig/fig-standards/blob/a1a0674a742c9d07c5dd450209fb33b115ee7b40/accepted/PSR-4-autoloader-examples.md#closure-example
*/
spl_autoload_register(static function (string $class): void {
$prefix = 'phpweb\\';
$directory = __DIR__ . '/';
$length = strlen($prefix);
if (strncmp($prefix, $class, $length) !== 0) {
return;
}
$relativeClass = substr(
$class,
$length,
);
$file = $directory . str_replace('\\', '/', $relativeClass) . '.php';
if (!file_exists($file)) {
return;
}
require $file;
});