@@ -137,14 +137,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
137137
138138 $ config = (new ConfigProcessor (new ConfigParser ($ input , $ this ->getDefinition ())))->processConfig ();
139139
140-
141140 // Get files to check:
142- $ files = FileProviderFactory::getFileProvider ($ config )->getFiles ();
141+ $ files = FileProviderFactory::getFileProvider ($ config )->getFileIterator ();
143142
144143 // Check files:
145144 $ filesPerLine = $ config ->getFilesPerLine ();
146- $ totalFiles = count ($ files );
147- $ files = array_chunk ($ files , $ filesPerLine );
145+ $ totalFiles = iterator_count ($ files );
146+ // $files = array_chunk($files, $filesPerLine);
148147 $ processed = 0 ;
149148
150149 $ fileChecker = new FileChecker (
@@ -164,33 +163,28 @@ protected function execute(InputInterface $input, OutputInterface $output)
164163 $ output ->writeln ('' );
165164 }
166165
167- while (count ($ files )) {
168- $ chunk = array_shift ($ files );
169- $ chunkFiles = count ($ chunk );
170-
171- while (count ($ chunk )) {
172- $ processed ++;
173- $ file = array_shift ($ chunk );
174-
175- $ status = $ fileChecker ->checkFile ($ file );
176- $ statusCollection ->addFileStatus ($ status );
177-
178- if ($ config ->isVerbose ()) {
179- if ($ status ->hasErrors ()) {
180- $ output ->write ('<fg=red>F</> ' );
181- } elseif ($ status ->hasWarnings ()) {
182- $ output ->write ('<fg=yellow>W</> ' );
183- } else {
184- $ output ->write ('<info>.</info> ' );
185- }
166+ /** @var \SplFileInfo $file */
167+ foreach ($ files as $ file ) {
168+ $ processed ++;
169+
170+ $ status = $ fileChecker ->checkFile ($ file ->getPathname ());
171+ $ statusCollection ->addFileStatus ($ status );
172+
173+ if ($ config ->isVerbose ()) {
174+ if ($ status ->hasErrors ()) {
175+ $ output ->write ('<fg=red>F</> ' );
176+ } elseif ($ status ->hasWarnings ()) {
177+ $ output ->write ('<fg=yellow>W</> ' );
178+ } else {
179+ $ output ->write ('<info>.</info> ' );
186180 }
187181 }
188182
189- if ($ config ->isVerbose ()) {
183+ if ($ processed % $ config -> getFilesPerLine () === 0 && $ config ->isVerbose ()) {
190184 $ output ->writeln (
191185 sprintf (
192186 '%s %s/%d (%d%%) ' ,
193- str_pad ('' , $ filesPerLine - $ chunkFiles ),
187+ str_pad ('' , $ filesPerLine - $ processed ),
194188 str_pad ((string )$ processed , strlen ((string )$ totalFiles ), ' ' , STR_PAD_LEFT ),
195189 $ totalFiles ,
196190 floor ((100 / $ totalFiles ) * $ processed )
@@ -199,7 +193,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
199193 }
200194 }
201195
202-
203196 if ($ config ->isVerbose ()) {
204197 $ time = round (microtime (true ) - $ startTime , 2 );
205198 $ output ->writeln ('' );
0 commit comments