@@ -74,6 +74,7 @@ protected function configure()
7474 ->addOption ('skip-methods ' , null , InputOption::VALUE_NONE , 'Don \'t check methods for docblocks. ' )
7575 ->addOption ('skip-anonymous-functions ' , null , InputOption::VALUE_NONE , 'Don \'t check anonymous functions for docblocks. ' )
7676 ->addOption ('json ' , 'j ' , InputOption::VALUE_NONE , 'Output JSON instead of a log. ' )
77+ ->addOption ('files-per-line ' , 'l ' , InputOption::VALUE_REQUIRED , 'Number of files per line in progress ' , 50 )
7778 ->addOption ('info-only ' , 'i ' , InputOption::VALUE_NONE , 'Information-only mode, just show summary. ' );
7879 }
7980
@@ -109,31 +110,29 @@ protected function execute(InputInterface $input, OutputInterface $output)
109110 $ this ->processDirectory ('' , $ files );
110111
111112 // Check files:
113+ $ filesPerLine = (int )$ input ->getOption ('files-per-line ' );
112114 $ totalFiles = count ($ files );
113- $ progressStep = ceil ($ totalFiles / 10 );
114- $ progressStep = $ progressStep < 1 ? 1 : $ progressStep ;
115- $ progressDot = round ($ progressStep / 10 );
116- $ progressDot = $ progressDot < 1 ? 1 : $ progressDot ;
117-
118- $ i = 0 ;
119- $ stepi = 0 ;
120- foreach ($ files as $ file ) {
121- if ($ this ->verbose && $ progressStep > 0 && $ i > 0 ) {
122- if ($ stepi % $ progressDot == 0 ) {
123- $ this ->output ->write ('. ' );
124- }
125-
126- if ($ i % $ progressStep == 0 || $ i == ($ totalFiles - 1 )) {
127- $ this ->output ->write ('. ' . $ i . ' / ' . $ totalFiles . ' ( ' . floor ((100 /$ totalFiles ) * $ i ) . '%) ' );
128- $ this ->output ->writeln ('' );
129- $ stepi = 0 ;
115+ $ files = array_chunk ($ files , $ filesPerLine );
116+ $ processed = 0 ;
117+ $ fileCountLength = strlen ((string )$ totalFiles );
118+
119+ while (count ($ files )) {
120+ $ chunk = array_shift ($ files );
121+ $ chunkFiles = count ($ chunk );
122+
123+ while (count ($ chunk )) {
124+ $ processed ++;
125+ $ file = array_shift ($ chunk );
126+
127+ if ($ this ->processFile ($ file )) {
128+ $ this ->output ->write ('<info>.</info> ' );
129+ } else {
130+ $ this ->output ->write ('<fg=red>F</> ' );
130131 }
131132 }
132133
133- $ this ->processFile ($ file );
134-
135- $ i ++;
136- $ stepi ++;
134+ $ this ->output ->write (str_pad ('' , $ filesPerLine - $ chunkFiles ));
135+ $ this ->output ->writeln (' ' . str_pad ($ processed , $ fileCountLength , ' ' , STR_PAD_LEFT ) . '/ ' . $ totalFiles . ' ( ' . floor ((100 /$ totalFiles ) * $ processed ) . '%) ' );
137136 }
138137
139138 if ($ this ->verbose ) {
@@ -206,6 +205,7 @@ protected function processDirectory($path = '', array &$worklist = [])
206205 /**
207206 * Check a specific PHP file for errors.
208207 * @param $file
208+ * @return bool
209209 */
210210 protected function processFile ($ file )
211211 {
@@ -246,5 +246,7 @@ protected function processFile($file)
246246 if (!$ errors ) {
247247 $ this ->passed += 1 ;
248248 }
249+
250+ return !$ errors ;
249251 }
250252}
0 commit comments