11<?php
22
3- function runDir (string $ base , string $ dir ): int
3+ if (!file_exists ('composer.phar ' )) {
4+ $ composer = file_get_contents ('https://getcomposer.org/composer.phar ' );
5+ file_put_contents ('composer.phar ' , $ composer );
6+ }
7+ if (!file_exists ('vendor ' )) {
8+ exec ('php composer.phar install ' );
9+ exec ('php patch.php ' );
10+ }
11+
12+ function patchDir (string $ base , string $ dir ): int
413{
514 $ count = 0 ;
615 $ entries = scandir ($ dir );
@@ -10,7 +19,7 @@ function runDir(string $base, string $dir): int
1019 }
1120 $ filename = "$ base/ $ dir/ $ entry " ;
1221 if (is_dir ($ filename )) {
13- $ count += runDir ($ base , "$ dir/ $ entry " );
22+ $ count += patchDir ($ base , "$ dir/ $ entry " );
1423 }
1524 }
1625 foreach ($ entries as $ entry ) {
@@ -32,12 +41,12 @@ function runDir(string $base, string $dir): int
3241 return $ count ;
3342}
3443
35- function run (string $ base , array $ dirs )
44+ function patch (string $ base , array $ dirs )
3645{
3746 $ start = microtime (true );
3847 $ count = 0 ;
3948 foreach ($ dirs as $ dir ) {
40- $ count += runDir ($ base , $ dir );
49+ $ count += patchDir ($ base , $ dir );
4150 }
4251 $ end = microtime (true );
4352 $ time = ($ end - $ start ) * 1000 ;
@@ -46,4 +55,4 @@ function run(string $base, array $dirs)
4655 }
4756}
4857
49- run (__DIR__ , ['vendor ' ]);
58+ patch (__DIR__ , ['vendor ' ]);
0 commit comments