Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Runner.php

function Runner::printProgress

Print progress information for a single processed file.

Parameters

\PHP_CodeSniffer\Files\File $file The file that was processed.:

int $numFiles The total number of files to process.:

int $numProcessed The number of files that have been processed,: including this one.

Return value

void

2 calls to Runner::printProgress()
Runner::processChildProcs in vendor/squizlabs/php_codesniffer/src/Runner.php
Waits for child processes to complete and cleans up after them.
Runner::run in vendor/squizlabs/php_codesniffer/src/Runner.php
Performs the run.

File

vendor/squizlabs/php_codesniffer/src/Runner.php, line 851

Class

Runner

Namespace

PHP_CodeSniffer

Code

public function printProgress(File $file, $numFiles, $numProcessed) {
    if (PHP_CODESNIFFER_VERBOSITY > 0 || $this->config->showProgress === false) {
        return;
    }
    // Show progress information.
    if ($file->ignored === true) {
        echo 'S';
    }
    else {
        $errors = $file->getErrorCount();
        $warnings = $file->getWarningCount();
        $fixable = $file->getFixableCount();
        $fixed = $file->getFixedCount();
        if (PHP_CODESNIFFER_CBF === true) {
            // Files with fixed errors or warnings are F (green).
            // Files with unfixable errors or warnings are E (red).
            // Files with no errors or warnings are . (black).
            if ($fixable > 0) {
                if ($this->config->colors === true) {
                    echo "\x1b[31m";
                }
                echo 'E';
                if ($this->config->colors === true) {
                    echo "\x1b[0m";
                }
            }
            else {
                if ($fixed > 0) {
                    if ($this->config->colors === true) {
                        echo "\x1b[32m";
                    }
                    echo 'F';
                    if ($this->config->colors === true) {
                        echo "\x1b[0m";
                    }
                }
                else {
                    echo '.';
                }
            }
            
            //end if
        }
        else {
            // Files with errors are E (red).
            // Files with fixable errors are E (green).
            // Files with warnings are W (yellow).
            // Files with fixable warnings are W (green).
            // Files with no errors or warnings are . (black).
            if ($errors > 0) {
                if ($this->config->colors === true) {
                    if ($fixable > 0) {
                        echo "\x1b[32m";
                    }
                    else {
                        echo "\x1b[31m";
                    }
                }
                echo 'E';
                if ($this->config->colors === true) {
                    echo "\x1b[0m";
                }
            }
            else {
                if ($warnings > 0) {
                    if ($this->config->colors === true) {
                        if ($fixable > 0) {
                            echo "\x1b[32m";
                        }
                        else {
                            echo "\x1b[33m";
                        }
                    }
                    echo 'W';
                    if ($this->config->colors === true) {
                        echo "\x1b[0m";
                    }
                }
                else {
                    echo '.';
                }
            }
            
            //end if
        }
        
        //end if
    }
    
    //end if
    $numPerLine = 60;
    if ($numProcessed !== $numFiles && $numProcessed % $numPerLine !== 0) {
        return;
    }
    $percent = round($numProcessed / $numFiles * 100);
    $padding = strlen($numFiles) - strlen($numProcessed);
    if ($numProcessed === $numFiles && $numFiles > $numPerLine && $numProcessed % $numPerLine !== 0) {
        $padding += $numPerLine - ($numFiles - floor($numFiles / $numPerLine) * $numPerLine);
    }
    echo str_repeat(' ', $padding) . " {$numProcessed} / {$numFiles} ({$percent}%)" . PHP_EOL;
}
RSS feed
Powered by Drupal