19 lines
565 B
PHP
19 lines
565 B
PHP
<?php
|
|
|
|
function yieldIncludes(string $file, &$includes, int $depth = 0): iterable
|
|
{
|
|
if (!isset($includes[$file])) return;
|
|
|
|
foreach (getAllLines($file) as $line) {
|
|
$includeFile = getLineIncludeFile($line);
|
|
if ($includeFile) {
|
|
yield from yieldIncludes($includeFile, $includes, $depth + 1);
|
|
unset($includes[$includeFile]);
|
|
} else {
|
|
if ($depth > 0 && str_starts_with($line, '<?php')) continue;
|
|
if (empty(trim($line))) continue;
|
|
yield $line;
|
|
}
|
|
}
|
|
}
|