Last active
June 18, 2019 07:24
-
-
Save nimolix/601874b07f548bc4726c5b1643561141 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$directories = ['application', 'library', 'database', '']; | |
define("CWD", dirname(__FILE__)); | |
echo '<h1>Parallel PHP Linter</h1>'; | |
$time_start = microtime(true); | |
foreach ($directories as $directory) { | |
$path = escapeshellcmd(CWD . DIRECTORY_SEPARATOR . $directory); | |
echo "<h2>Checking $path:</h2>"; | |
$out = []; | |
$maxdepth = ''; | |
if (empty($directory)) { | |
$maxdepth = '-maxdepth 1'; | |
} | |
exec("find $path $maxdepth -type f -name '*.php' -print0 | xargs -0 -n1 -P8 sh -c 'php -l -n \"$0\" || exit 1' | (! grep -v 'No syntax errors detected' )", $out, $status); | |
if ($status !== 0) { | |
echo '<pre>'; | |
echo join("\n", $out); | |
echo '</pre>'; | |
echo '<span style="color:red"><strong>Failed!</strong></span>' . "\n\n"; | |
} else { | |
echo '<span style="color:green"><strong>OK!</strong></span>' . "\n\n"; | |
} | |
} | |
echo '<p>Total execution time in seconds: ' . (microtime(true) - $time_start) . '</p>'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment