Skip to content

Instantly share code, notes, and snippets.

@rudiedirkx
Created December 22, 2024 22:37
Show Gist options
  • Save rudiedirkx/e6a1addec077ac31f9b2fbd508fa6c2e to your computer and use it in GitHub Desktop.
Save rudiedirkx/e6a1addec077ac31f9b2fbd508fa6c2e to your computer and use it in GitHub Desktop.
<?php
$output = trim(file_get_contents('php://stdin'));
$lines = explode("\n", $output);
$counts = [];
$lastFile = null;
foreach ($lines as $line) {
if (preg_match('#^ Line \s+ (.+)#', $line, $match)) {
$lastFile = trim($match[1]);
$counts[$lastFile] = 0;
}
elseif (preg_match('#^ \d+ #', $line, $match)) {
$counts[$lastFile]++;
}
}
// print_r($counts);
foreach ($counts as $file => $count) {
printf("% 4d %s\n", $count, $file);
}
printf("\nTotal errors: %d\n\n", array_sum($counts));
exit($counts ? 1 : 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment