Skip to content

Commit db9fa20

Browse files
committed
Add the PHP builder.
1 parent 1a15f6e commit db9fa20

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

build/builder.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
$files = array_filter(array_map(function($path){
4+
return realpath($path);
5+
}, glob(__DIR__ . '/../source/**')));
6+
sort($files);
7+
8+
//var_dump($files);
9+
10+
$hints = [];
11+
foreach ($files as $file){
12+
$text = file_get_contents($file);
13+
$text = trim($text);
14+
15+
[$category, $author, $body] = array_map(function($line){
16+
return trim($line);
17+
}, explode("\n", $text, 3));
18+
19+
$hints[] = '$hints[] = [' . var_export($category, true) . ', ' . \
20+
var_export($author, true) . ', "' . \
21+
strtr($body, ["\n" => '\n', "\t" => '\t', "\"" => '\"', "'" => '\'']) . '"];';
22+
}
23+
24+
$body = file_get_contents(__DIR__ . '/../index.php.src');
25+
$body = str_replace('/* OTHER_HINTS */', join("\n", $hints), $body);
26+
file_put_contents(__DIR__ . '/../built.php', $body);

0 commit comments

Comments
 (0)