Start op project
This commit is contained in:
commit
08d014713a
41
bundle.php
Executable file
41
bundle.php
Executable file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
function line(string $text): void
|
||||
{
|
||||
echo $text . PHP_EOL;
|
||||
}
|
||||
|
||||
if (count($argv) < 2) {
|
||||
line('Usage: bundle.php <file>');
|
||||
exit(1);
|
||||
}
|
||||
$targetFile = $argv[1];
|
||||
if (!file_exists($targetFile)) {
|
||||
line('File not found: ' . $targetFile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
function getIncludes(string $file): array
|
||||
{
|
||||
$content = file_get_contents($file);
|
||||
$files = [];
|
||||
foreach (explode("\n", $content) as $line) {
|
||||
if (str_starts_with($line, 'include')) {
|
||||
$line = "include 'test.include.php';";
|
||||
preg_match("/include\s+'([^']+)'/", $line, $matches);
|
||||
$files[] = $matches[1];
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
var_dump(getIncludes($targetFile));
|
||||
|
||||
function buildIncludeTree(string $file): array
|
||||
{
|
||||
$includes = getIncludes($file);
|
||||
foreach ($includes as $include) {
|
||||
|
||||
}
|
||||
}
|
3
test.include.php
Normal file
3
test.include.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
echo 'test.include' . PHP_EOL;
|
Loading…
x
Reference in New Issue
Block a user