PHP_CodeSniffer
[ class tree: PHP_CodeSniffer ] [ index: PHP_CodeSniffer ] [ all elements ]

Source for file Runner.php

Documentation is available at Runner.php

  1. <?php
  2. /**
  3.  * Responsible for running PHPCS and PHPCBF.
  4.  *
  5.  * After creating an object of this class, you probably just want to
  6.  * call runPHPCS() or runPHPCBF().
  7.  *
  8.  * @author    Greg Sherwood <gsherwood@squiz.net>
  9.  * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
  10.  * @license   https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
  11.  */
  12.  
  13. namespace PHP_CodeSniffer;
  14.  
  15. use PHP_CodeSniffer\Files\FileList;
  16. use PHP_CodeSniffer\Files\File;
  17. use PHP_CodeSniffer\Files\DummyFile;
  18. use PHP_CodeSniffer\Util\Cache;
  19. use PHP_CodeSniffer\Util\Common;
  20. use PHP_CodeSniffer\Exceptions\RuntimeException;
  21.  
  22. class Runner
  23. {
  24.  
  25.     /**
  26.      * The config data for the run.
  27.      *
  28.      * @var \PHP_CodeSniffer\Config 
  29.      */
  30.     public $config = null;
  31.  
  32.     /**
  33.      * The ruleset used for the run.
  34.      *
  35.      * @var \PHP_CodeSniffer\Ruleset 
  36.      */
  37.     public $ruleset = null;
  38.  
  39.     /**
  40.      * The reporter used for generating reports after the run.
  41.      *
  42.      * @var \PHP_CodeSniffer\Reporter 
  43.      */
  44.     public $reporter = null;
  45.  
  46.  
  47.     /**
  48.      * Run the PHPCS script.
  49.      *
  50.      * @return array 
  51.      */
  52.     public function runPHPCS()
  53.     {
  54.         Util\Timing::startTiming();
  55.         Runner::checkRequirements();
  56.  
  57.         if (defined('PHP_CODESNIFFER_CBF'=== false{
  58.             define('PHP_CODESNIFFER_CBF'false);
  59.         }
  60.  
  61.         // Creating the Config object populates it with all required settings
  62.         // based on the CLI arguments provided to the script and any config
  63.         // values the user has set.
  64.         $this->config = new Config();
  65.  
  66.         // Init the run and load the rulesets to set additional config vars.
  67.         $this->init();
  68.  
  69.         // Print a list of sniffs in each of the supplied standards.
  70.         // We fudge the config here so that each standard is explained in isolation.
  71.         if ($this->config->explain === true{
  72.             $standards $this->config->standards;
  73.             foreach ($standards as $standard{
  74.                 $this->config->standards = array($standard);
  75.                 $ruleset = new Ruleset($this->config);
  76.                 $ruleset->explain();
  77.             }
  78.  
  79.             exit(0);
  80.         }
  81.  
  82.         // Generate documentation for each of the supplied standards.
  83.         if ($this->config->generator !== null{
  84.             $standards $this->config->standards;
  85.             foreach ($standards as $standard{
  86.                 $this->config->standards = array($standard);
  87.                 $ruleset   = new Ruleset($this->config);
  88.                 $class     'PHP_CodeSniffer\Generators\\'.$this->config->generator;
  89.                 $generator = new $class($ruleset);
  90.                 $generator->generate();
  91.             }
  92.  
  93.             exit(0);
  94.         }
  95.  
  96.         // Other report formats don't really make sense in interactive mode
  97.         // so we hard-code the full report here and when outputting.
  98.         // We also ensure parallel processing is off because we need to do one file at a time.
  99.         if ($this->config->interactive === true{
  100.             $this->config->reports  = array('full' => null);
  101.             $this->config->parallel = 1;
  102.         }
  103.  
  104.         // Disable caching if we are processing STDIN as we can't be 100%
  105.         // sure where the file came from or if it will change in the future.
  106.         if ($this->config->stdin === true{
  107.             $this->config->cache = false;
  108.         }
  109.  
  110.         $numErrors $this->run();
  111.  
  112.         // Print all the reports for this run.
  113.         $toScreen $this->reporter->printReports();
  114.  
  115.         // Only print timer output if no reports were
  116.         // printed to the screen so we don't put additional output
  117.         // in something like an XML report. If we are printing to screen,
  118.         // the report types would have already worked out who should
  119.         // print the timer info.
  120.         if ($this->config->interactive === false
  121.             && ($toScreen === false
  122.             || (($this->reporter->totalErrors + $this->reporter->totalWarnings=== 0 && $this->config->showProgress === true))
  123.         {
  124.             Util\Timing::printRunTime();
  125.         }
  126.  
  127.         if ($numErrors === 0{
  128.             // No errors found.
  129.             exit(0);
  130.         else if ($this->reporter->totalFixable === 0{
  131.             // Errors found, but none of them can be fixed by PHPCBF.
  132.             exit(1);
  133.         else {
  134.             // Errors found, and some can be fixed by PHPCBF.
  135.             exit(2);
  136.         }
  137.  
  138.     }//end runPHPCS()
  139.  
  140.  
  141.     /**
  142.      * Run the PHPCBF script.
  143.      *
  144.      * @return array 
  145.      */
  146.     public function runPHPCBF()
  147.     {
  148.         if (defined('PHP_CODESNIFFER_CBF'=== false{
  149.             define('PHP_CODESNIFFER_CBF'true);
  150.         }
  151.  
  152.         Util\Timing::startTiming();
  153.         Runner::checkRequirements();
  154.  
  155.         // Creating the Config object populates it with all required settings
  156.         // based on the CLI arguments provided to the script and any config
  157.         // values the user has set.
  158.         $this->config = new Config();
  159.  
  160.         // Init the run and load the rulesets to set additional config vars.
  161.         $this->init();
  162.  
  163.         // Override some of the command line settings that might break the fixes.
  164.         $this->config->verbosity    = 0;
  165.         $this->config->showProgress = false;
  166.         $this->config->generator    = null;
  167.         $this->config->explain      = false;
  168.         $this->config->interactive  = false;
  169.         $this->config->cache        = false;
  170.         $this->config->showSources  = false;
  171.         $this->config->recordErrors = false;
  172.         $this->config->reportFile   = null;
  173.         $this->config->reports      = array('cbf' => null);
  174.  
  175.         // If a standard tries to set command line arguments itself, some
  176.         // may be blocked because PHPCBF is running, so stop the script
  177.         // dying if any are found.
  178.         $this->config->dieOnUnknownArg = false;
  179.  
  180.         $numErrors $this->run();
  181.         $this->reporter->printReports();
  182.  
  183.         echo PHP_EOL;
  184.         Util\Timing::printRunTime();
  185.  
  186.         // We can't tell exactly how many errors were fixed, but
  187.         // we know how many errors were found.
  188.         exit($numErrors);
  189.  
  190.     }//end runPHPCBF()
  191.  
  192.  
  193.     /**
  194.      * Exits if the minimum requirements of PHP_CodSniffer are not met.
  195.      *
  196.      * @return array 
  197.      */
  198.     public function checkRequirements()
  199.     {
  200.         // Check the PHP version.
  201.         if (version_compare(PHP_VERSION'5.4.0'=== -1{
  202.             echo 'ERROR: PHP_CodeSniffer requires PHP version 5.4.0 or greater.'.PHP_EOL;
  203.             exit(3);
  204.         }
  205.  
  206.         if (extension_loaded('tokenizer'=== false{
  207.             echo 'ERROR: PHP_CodeSniffer requires the tokenizer extension to be enabled.'.PHP_EOL;
  208.             exit(3);
  209.         }
  210.  
  211.     }//end checkRequirements()
  212.  
  213.  
  214.     /**
  215.      * Init the rulesets and other high-level settings.
  216.      *
  217.      * @return void 
  218.      */
  219.     private function init()
  220.     {
  221.         // Ensure this option is enabled or else line endings will not always
  222.         // be detected properly for files created on a Mac with the /r line ending.
  223.         ini_set('auto_detect_line_endings'true);
  224.  
  225.         // Check that the standards are valid.
  226.         foreach ($this->config->standards as $standard{
  227.             if (Util\Standards::isInstalledStandard($standard=== false{
  228.                 // They didn't select a valid coding standard, so help them
  229.                 // out by letting them know which standards are installed.
  230.                 echo 'ERROR: the "'.$standard.'" coding standard is not installed. ';
  231.                 Util\Standards::printInstalledStandards();
  232.                 exit(3);
  233.             }
  234.         }
  235.  
  236.         // Saves passing the Config object into other objects that only need
  237.         // the verbostity flag for deubg output.
  238.         if (defined('PHP_CODESNIFFER_VERBOSITY'=== false{
  239.             define('PHP_CODESNIFFER_VERBOSITY'$this->config->verbosity);
  240.         }
  241.  
  242.         // Create this class so it is autoloaded and sets up a bunch
  243.         // of PHP_CodeSniffer-specific token type constants.
  244.         $tokens = new Util\Tokens();
  245.  
  246.         // The ruleset contains all the information about how the files
  247.         // should be checked and/or fixed.
  248.         $this->ruleset = new Ruleset($this->config);
  249.  
  250.     }//end init()
  251.  
  252.  
  253.     /**
  254.      * Performs the run.
  255.      *
  256.      * @return int The number of errors and warnings found.
  257.      */
  258.     private function run()
  259.     {
  260.         // The class that manages all reporters for the run.
  261.         $this->reporter = new Reporter($this->config);
  262.  
  263.         // Include bootstrap files.
  264.         foreach ($this->config->bootstrap as $bootstrap{
  265.             include $bootstrap;
  266.         }
  267.  
  268.         if ($this->config->stdin === true{
  269.             $fileContents $this->config->stdinContent;
  270.             if ($fileContents === null{
  271.                 $handle fopen('php://stdin''r');
  272.                 stream_set_blocking($handletrue);
  273.                 $fileContents stream_get_contents($handle);
  274.                 fclose($handle);
  275.             }
  276.  
  277.             $todo  = new FileList($this->config$this->ruleset);
  278.             $dummy = new DummyFile($fileContents$this->ruleset$this->config);
  279.             $todo->addFile($dummy->path$dummy);
  280.  
  281.             $numFiles = 1;
  282.         else {
  283.             if (empty($this->config->files=== true{
  284.                 echo 'ERROR: You must supply at least one file or directory to process.'.PHP_EOL.PHP_EOL;
  285.                 $this->config->printUsage();
  286.                 exit(0);
  287.             }
  288.  
  289.             if (PHP_CODESNIFFER_VERBOSITY > 0{
  290.                 echo 'Creating file list... ';
  291.             }
  292.  
  293.             $todo     = new FileList($this->config$this->ruleset);
  294.             $numFiles count($todo);
  295.  
  296.             if (PHP_CODESNIFFER_VERBOSITY > 0{
  297.                 echo "DONE ($numFiles files in queue)".PHP_EOL;
  298.             }
  299.  
  300.             if ($this->config->cache === true{
  301.                 if (PHP_CODESNIFFER_VERBOSITY > 0{
  302.                     echo 'Loading cache... ';
  303.                 }
  304.  
  305.                 Cache::load($this->ruleset$this->config);
  306.  
  307.                 if (PHP_CODESNIFFER_VERBOSITY > 0{
  308.                     $size = Cache::getSize();
  309.                     echo "DONE ($size files in cache)".PHP_EOL;
  310.                 }
  311.             }
  312.         }//end if
  313.  
  314.         $numProcessed = 0;
  315.         $dots         = 0;
  316.         $maxLength    strlen($numFiles);
  317.         $lastDir      '';
  318.         $childProcs   = array();
  319.  
  320.         // Turn all sniff errors into exceptions.
  321.         set_error_handler(array($this'handleErrors'));
  322.  
  323.         // If verbosity is too high, turn off parallelism so the
  324.         // debug output is clean.
  325.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  326.             $this->config->parallel = 1;
  327.         }
  328.  
  329.         // If the PCNTL extension isn't installed, we can't fork.
  330.         if (function_exists('pcntl_fork'=== false{
  331.             $this->config->parallel = 1;
  332.         }
  333.  
  334.         if ($this->config->parallel === 1{
  335.             // Running normally.
  336.             foreach ($todo as $path => $file{
  337.                 $currDir dirname($path);
  338.                 if ($lastDir !== $currDir{
  339.                     if (PHP_CODESNIFFER_VERBOSITY > 0 || (PHP_CODESNIFFER_CBF === true && $this->config->stdin === false)) {
  340.                         echo 'Changing into directory '.Common::stripBasepath($currDir$this->config->basepath).PHP_EOL;
  341.                     }
  342.  
  343.                     $lastDir $currDir;
  344.                 }
  345.  
  346.                 $this->processFile($file);
  347.  
  348.                 $numProcessed++;
  349.  
  350.                 if (PHP_CODESNIFFER_VERBOSITY > 0
  351.                     || $this->config->interactive === true
  352.                     || $this->config->showProgress === false
  353.                 {
  354.                     continue;
  355.                 }
  356.  
  357.                 // Show progress information.
  358.                 if ($file->ignored === true{
  359.                     echo 'S';
  360.                 else {
  361.                     $errors   $file->getErrorCount();
  362.                     $warnings $file->getWarningCount();
  363.                     if ($errors > 0{
  364.                         if ($this->config->colors === true{
  365.                             echo "\033[31m";
  366.                         }
  367.  
  368.                         echo 'E';
  369.                     else if ($warnings > 0{
  370.                         if ($this->config->colors === true{
  371.                             echo "\033[33m";
  372.                         }
  373.  
  374.                         echo 'W';
  375.                     else {
  376.                         echo '.';
  377.                     }
  378.  
  379.                     if ($this->config->colors === true{
  380.                         echo "\033[0m";
  381.                     }
  382.                 }//end if
  383.  
  384.                 $dots++;
  385.                 if ($dots === 60{
  386.                     $padding ($maxLength strlen($numProcessed));
  387.                     echo str_repeat(' '$padding);
  388.                     $percent round(($numProcessed $numFiles* 100);
  389.                     echo " $numProcessed / $numFiles ($percent%)".PHP_EOL;
  390.                     $dots = 0;
  391.                 }
  392.             }//end foreach
  393.         else {
  394.             // Batching and forking.
  395.             $numFiles    count($todo);
  396.             $numPerBatch ceil($numFiles $this->config->parallel);
  397.  
  398.             for ($batch = 0; $batch $this->config->parallel; $batch++{
  399.                 $startAt ($batch $numPerBatch);
  400.                 if ($startAt >= $numFiles{
  401.                     break;
  402.                 }
  403.  
  404.                 $endAt ($startAt $numPerBatch);
  405.                 if ($endAt $numFiles{
  406.                     $endAt $numFiles;
  407.                 }
  408.  
  409.                 $childOutFilename tempnam(sys_get_temp_dir()'phpcs-child');
  410.                 $pid pcntl_fork();
  411.                 if ($pid === -1{
  412.                     throw new RuntimeException('Failed to create child process');
  413.                 else if ($pid !== 0{
  414.                     $childProcs[= array(
  415.                                      'pid' => $pid,
  416.                                      'out' => $childOutFilename,
  417.                                     );
  418.                 else {
  419.                     // Move forward to the start of the batch.
  420.                     $todo->rewind();
  421.                     for ($i = 0; $i $startAt$i++{
  422.                         $todo->next();
  423.                     }
  424.  
  425.                     // Reset the reporter to make sure only figures from this
  426.                     // file batch are recorded.
  427.                     $this->reporter->totalFiles    = 0;
  428.                     $this->reporter->totalErrors   = 0;
  429.                     $this->reporter->totalWarnings = 0;
  430.                     $this->reporter->totalFixable  = 0;
  431.  
  432.                     // Process the files.
  433.                     $pathsProcessed = array();
  434.                     ob_start();
  435.                     for ($i $startAt$i $endAt$i++{
  436.                         $path $todo->key();
  437.                         $file $todo->current();
  438.  
  439.                         $currDir dirname($path);
  440.                         if ($lastDir !== $currDir{
  441.                             if (PHP_CODESNIFFER_VERBOSITY > 0 || (PHP_CODESNIFFER_CBF === true && $this->config->stdin === false)) {
  442.                                 echo 'Changing into directory '.Common::stripBasepath($currDir$this->config->basepath).PHP_EOL;
  443.                             }
  444.  
  445.                             $lastDir $currDir;
  446.                         }
  447.  
  448.                         $this->processFile($file);
  449.  
  450.                         $pathsProcessed[$path;
  451.                         $todo->next();
  452.                     }
  453.  
  454.                     $debugOutput ob_get_contents();
  455.                     ob_end_clean();
  456.  
  457.                     // Write information about the run to the filesystem
  458.                     // so it can be picked up by the main process.
  459.                     $childOutput = array(
  460.                                     'totalFiles'    => $this->reporter->totalFiles,
  461.                                     'totalErrors'   => $this->reporter->totalErrors,
  462.                                     'totalWarnings' => $this->reporter->totalWarnings,
  463.                                     'totalFixable'  => $this->reporter->totalFixable,
  464.                                    );
  465.  
  466.                     $output  '<'.'?php'."\n".' $childOutput = ';
  467.                     $output .= var_export($childOutputtrue);
  468.                     $output .= ";\n\$debugOutput = ";
  469.                     $output .= var_export($debugOutputtrue);
  470.  
  471.                     if ($this->config->cache === true{
  472.                         $childCache = array();
  473.                         foreach ($pathsProcessed as $path{
  474.                             $childCache[$path= Cache::get($path);
  475.                         }
  476.  
  477.                         $output .= ";\n\$childCache = ";
  478.                         $output .= var_export($childCachetrue);
  479.                     }
  480.  
  481.                     $output .= ";\n?".'>';
  482.                     file_put_contents($childOutFilename$output);
  483.                     exit($pid);
  484.                 }//end if
  485.             }//end for
  486.  
  487.             $this->processChildProcs($childProcs);
  488.         }//end if
  489.  
  490.         restore_error_handler();
  491.  
  492.         if (PHP_CODESNIFFER_VERBOSITY === 0
  493.             && $this->config->interactive === false
  494.             && $this->config->showProgress === true
  495.         {
  496.             echo PHP_EOL.PHP_EOL;
  497.         }
  498.  
  499.         if ($this->config->cache === true{
  500.             Cache::save();
  501.         }
  502.  
  503.         $ignoreWarnings = Config::getConfigData('ignore_warnings_on_exit');
  504.         $ignoreErrors   = Config::getConfigData('ignore_errors_on_exit');
  505.  
  506.         $return ($this->reporter->totalErrors + $this->reporter->totalWarnings);
  507.         if ($ignoreErrors !== null{
  508.             $ignoreErrors = (bool) $ignoreErrors;
  509.             if ($ignoreErrors === true{
  510.                 $return -= $this->reporter->totalErrors;
  511.             }
  512.         }
  513.  
  514.         if ($ignoreWarnings !== null{
  515.             $ignoreWarnings = (bool) $ignoreWarnings;
  516.             if ($ignoreWarnings === true{
  517.                 $return -= $this->reporter->totalWarnings;
  518.             }
  519.         }
  520.  
  521.         return $return;
  522.  
  523.     }//end run()
  524.  
  525.  
  526.     /**
  527.      * Converts all PHP errors into exceptions.
  528.      *
  529.      * This method forces a sniff to stop processing if it is not
  530.      * able to handle a specific piece of code, instead of continuing
  531.      * and potentially getting into a loop.
  532.      *
  533.      * @param int    $code    The level of error raised.
  534.      * @param string $message The error message.
  535.      * @param string $file    The path of the file that raised the error.
  536.      * @param int    $line    The line number the error was raised at.
  537.      *
  538.      * @return void 
  539.      */
  540.     public function handleErrors($code$message$file$line)
  541.     {
  542.         throw new RuntimeException("$message in $file on line $line");
  543.  
  544.     }//end handleErrors()
  545.  
  546.  
  547.     /**
  548.      * Processes a single file, including checking and fixing.
  549.      *
  550.      * @param \PHP_CodeSniffer\Files\File $file The file to be processed.
  551.      *
  552.      * @return void 
  553.      */
  554.     private function processFile($file)
  555.     {
  556.         if (PHP_CODESNIFFER_VERBOSITY > 0 || (PHP_CODESNIFFER_CBF === true && $this->config->stdin === false)) {
  557.             $startTime microtime(true);
  558.             echo 'Processing '.basename($file->path).' ';
  559.             if (PHP_CODESNIFFER_VERBOSITY > 1{
  560.                 echo PHP_EOL;
  561.             }
  562.         }
  563.  
  564.         try {
  565.             $file->process();
  566.  
  567.             if (PHP_CODESNIFFER_VERBOSITY > 0
  568.                 || (PHP_CODESNIFFER_CBF === true && $this->config->stdin === false)
  569.             {
  570.                 $timeTaken ((microtime(true$startTime* 1000);
  571.                 if ($timeTaken < 1000{
  572.                     $timeTaken round($timeTaken);
  573.                     echo "DONE in {$timeTaken}ms";
  574.                 else {
  575.                     $timeTaken round(($timeTaken / 1000)2);
  576.                     echo "DONE in $timeTaken secs";
  577.                 }
  578.  
  579.                 if (PHP_CODESNIFFER_CBF === true{
  580.                     $errors $file->getFixableCount();
  581.                     echo " ($errors fixable violations)".PHP_EOL;
  582.                 else {
  583.                     $errors   $file->getErrorCount();
  584.                     $warnings $file->getWarningCount();
  585.                     echo " ($errors errors, $warnings warnings)".PHP_EOL;
  586.                 }
  587.             }
  588.         catch (\Exception $e{
  589.             $error 'An error occurred during processing; checking has been aborted. The error message was: '.$e->getMessage();
  590.             $file->addErrorOnLine($error1'Internal.Exception');
  591.         }//end try
  592.  
  593.         $this->reporter->cacheFileReport($file$this->config);
  594.  
  595.         // Clean up the file to save (a lot of) memory.
  596.         $file->cleanUp();
  597.  
  598.         if ($this->config->interactive === true{
  599.             /*
  600.                 Running interactively.
  601.                 Print the error report for the current file and then wait for user input.
  602.             */
  603.  
  604.             // Get current violations and then clear the list to make sure
  605.             // we only print violations for a single file each time.
  606.             $numErrors = null;
  607.             while ($numErrors !== 0{
  608.                 $numErrors ($file->getErrorCount($file->getWarningCount());
  609.                 if ($numErrors === 0{
  610.                     continue;
  611.                 }
  612.  
  613.                 $this->reporter->printReport('full');
  614.  
  615.                 echo '<ENTER> to recheck, [s] to skip or [q] to quit : ';
  616.                 $input fgets(STDIN);
  617.                 $input trim($input);
  618.  
  619.                 switch ($input{
  620.                 case 's':
  621.                     break(2);
  622.                 case 'q':
  623.                     exit(0);
  624.                 default:
  625.                     // Repopulate the sniffs because some of them save their state
  626.                     // and only clear it when the file changes, but we are rechecking
  627.                     // the same file.
  628.                     $file->ruleset->populateTokenListeners();
  629.                     $file->reloadContent();
  630.                     $file->process();
  631.                     $this->reporter->cacheFileReport($file$this->config);
  632.                     break;
  633.                 }
  634.             }//end while
  635.         }//end if
  636.  
  637.     }//end processFile()
  638.  
  639.  
  640.     /**
  641.      * Waits for child processes to complete and cleans up after them.
  642.      *
  643.      * The reporting information returned by each child process is merged
  644.      * into the main reporter class.
  645.      *
  646.      * @param array $childProcs An array of child processes to wait for.
  647.      *
  648.      * @return void 
  649.      */
  650.     private function processChildProcs($childProcs)
  651.     {
  652.         $dots         = 0;
  653.         $numProcessed = 0;
  654.         $totalBatches count($childProcs);
  655.         $maxLength    strlen($totalBatches);
  656.  
  657.         while (count($childProcs> 0{
  658.             foreach ($childProcs as $key => $procData{
  659.                 $res pcntl_waitpid($procData['pid']$statusWNOHANG);
  660.                 if ($res === $procData['pid']{
  661.                     if (file_exists($procData['out']=== true{
  662.                         include $procData['out'];
  663.                         if (isset($childOutput=== true{
  664.                             $this->reporter->totalFiles    += $childOutput['totalFiles'];
  665.                             $this->reporter->totalErrors   += $childOutput['totalErrors'];
  666.                             $this->reporter->totalWarnings += $childOutput['totalWarnings'];
  667.                             $this->reporter->totalFixable  += $childOutput['totalFixable'];
  668.                         }
  669.  
  670.                         if (isset($debugOutput=== true{
  671.                             echo $debugOutput;
  672.                         }
  673.  
  674.                         if (isset($childCache=== true{
  675.                             foreach ($childCache as $path => $cache{
  676.                                 Cache::set($path$cache);
  677.                             }
  678.                         }
  679.  
  680.                         unlink($procData['out']);
  681.                         unset($childProcs[$key]);
  682.  
  683.                         $numProcessed++;
  684.  
  685.                         if (PHP_CODESNIFFER_VERBOSITY > 0
  686.                             || $this->config->showProgress === false
  687.                         {
  688.                             continue;
  689.                         }
  690.  
  691.                         if ($childOutput['totalErrors'> 0{
  692.                             if ($this->config->colors === true{
  693.                                 echo "\033[31m";
  694.                             }
  695.  
  696.                             echo 'E';
  697.                         else if ($childOutput['totalWarnings'> 0{
  698.                             if ($this->config->colors === true{
  699.                                 echo "\033[33m";
  700.                             }
  701.  
  702.                             echo 'W';
  703.                         else {
  704.                             echo '.';
  705.                         }
  706.  
  707.                         if ($this->config->colors === true{
  708.                             echo "\033[0m";
  709.                         }
  710.  
  711.                         $dots++;
  712.                         if ($dots === 60{
  713.                             $padding ($maxLength strlen($numProcessed));
  714.                             echo str_repeat(' '$padding);
  715.                             $percent round(($numProcessed $totalBatches* 100);
  716.                             echo " $numProcessed / $totalBatches ($percent%)".PHP_EOL;
  717.                             $dots = 0;
  718.                         }
  719.                     }//end if
  720.                 }//end if
  721.             }//end foreach
  722.         }//end while
  723.  
  724.     }//end processChildProcs()
  725.  
  726.  
  727. }//end class

Documentation generated on Mon, 11 Mar 2019 14:53:40 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.