Skip to content

Print progress to stderr #1606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ function printProgress($file, $numFiles, $numProcessed)

// Show progress information.
if ($file->ignored === true) {
echo 'S';
fwrite(STDERR, 'S');
} else {
$errors = $file->getErrorCount();
$warnings = $file->getWarningCount();
Expand All @@ -744,26 +744,26 @@ function printProgress($file, $numFiles, $numProcessed)
// Files with no errors or warnings are . (black).
if ($fixable > 0) {
if ($this->config->colors === true) {
echo "\033[31m";
fwrite(STDERR, "\033[31m");
}

echo 'E';
fwrite(STDERR, 'E');

if ($this->config->colors === true) {
echo "\033[0m";
fwrite(STDERR, "\033[0m");
}
} else if ($fixed > 0) {
if ($this->config->colors === true) {
echo "\033[32m";
fwrite(STDERR, "\033[32m");
}

echo 'F';
fwrite(STDERR, 'F');

if ($this->config->colors === true) {
echo "\033[0m";
fwrite(STDERR, "\033[0m");
}
} else {
echo '.';
fwrite(STDERR, '.');
}//end if
} else {
// Files with errors are E (red).
Expand All @@ -774,42 +774,42 @@ function printProgress($file, $numFiles, $numProcessed)
if ($errors > 0) {
if ($this->config->colors === true) {
if ($fixable > 0) {
echo "\033[32m";
fwrite(STDERR, "\033[32m");
} else {
echo "\033[31m";
fwrite(STDERR, "\033[31m");
}
}

echo 'E';
fwrite(STDERR, 'E');

if ($this->config->colors === true) {
echo "\033[0m";
fwrite(STDERR, "\033[0m");
}
} else if ($warnings > 0) {
if ($this->config->colors === true) {
if ($fixable > 0) {
echo "\033[32m";
fwrite(STDERR, "\033[32m");
} else {
echo "\033[33m";
fwrite(STDERR, "\033[33m");
}
}

echo 'W';
fwrite(STDERR, 'W');

if ($this->config->colors === true) {
echo "\033[0m";
fwrite(STDERR, "\033[0m");
}
} else {
echo '.';
fwrite(STDERR, '.');
}//end if
}//end if
}//end if

if (($numProcessed % 60) === 0) {
$padding = (strlen($numFiles) - strlen($numProcessed));
echo str_repeat(' ', $padding);
fwrite(STDERR, str_repeat(' ', $padding));
$percent = round(($numProcessed / $numFiles) * 100);
echo " $numProcessed / $numFiles ($percent%)".PHP_EOL;
fwrite(STDERR, " $numProcessed / $numFiles ($percent%)".PHP_EOL);
}

}//end printProgress()
Expand Down