Skip to content

Commit d102ab0

Browse files
committed
Improve opcode cachability for autoloading
1 parent bb3ff4e commit d102ab0

File tree

2 files changed

+186
-179
lines changed

2 files changed

+186
-179
lines changed

build/bootstrap.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,22 @@ static function (SplFileInfo $file) use ($tab): string {
4747
$function = $file->getFilenameWithoutExtension();
4848
$namespace = str_replace('/', '\\', $file->getRelativePath());
4949

50-
return sprintf($tab.'$functions[\'%s\'] = __DIR__.\'/%s\';', $namespace.'\\'.$function, $path);
50+
return sprintf($tab.$tab.'\'%s\' => __DIR__.\'/%s\',', $namespace.'\\'.$function, $path);
5151
}
5252
),
53-
static fn (iterable $codeLines): iterable => concat([
54-
'<?php declare(strict_types=1);',
55-
'',
56-
'(static function (): void {',
57-
$tab . '/** @var array<string, string> $functions */',
58-
$tab . '$functions = [];',
59-
], $codeLines),
53+
static fn (iterable $codeLines): iterable => concat(
54+
[
55+
'<?php declare(strict_types=1);',
56+
'',
57+
'(static function (): void {',
58+
$tab . '/** @var array<string, string> $functions */',
59+
$tab . '$functions = [',
60+
],
61+
$codeLines,
62+
[
63+
$tab.'];'
64+
]
65+
),
6066
static fn (iterable $codeLines): iterable => concat($codeLines, ['', $autoload, '})();', '']),
6167
static fn (iterable $codeLines): string => join($codeLines, PHP_EOL)
6268
);

0 commit comments

Comments
 (0)