@@ -73,31 +73,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
7373 $ source = $ util ->getDiffSource ();
7474 }
7575
76- $ files = array ();
77- $ sources = explode (' ' , $ source );
78- foreach ($ sources as $ source ) {
79- if (!is_dir ($ source )){
80- $ files [] = $ source ;
81- continue ;
82- }
83-
84- $ recursiveFiles = new RecursiveIteratorIterator (
85- new RecursiveDirectoryIterator ($ source )
86- );
87- foreach ($ recursiveFiles as $ file ) {
88- if ($ file ->isDir ()){
89- continue ;
90- }
91- $ files [] = $ file ->getPathname ();
92- }
93- }
94-
95- $ sources = $ files ;
76+ $ sources = $ this ->getAllFiles (explode (' ' , $ source ));
9677 $ exitCode = 0 ;
9778 $ columnSize = 80 ;
9879 $ errors = '' ;
9980 foreach ($ sources as $ line => $ source ) {
100- if ( ( $ line % $ columnSize ) == 0 ) {
81+ if (( $ line % $ columnSize ) == 0 ) {
10182 $ style ->newLine ();
10283 }
10384
@@ -109,7 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
10990 return ;
11091 }
11192
112- $ command ->output ->write ('<error>F </> ' );
93+ $ command ->output ->write ('<error>E </> ' );
11394 $ errors = $ buffer ;
11495 });
11596
@@ -127,10 +108,45 @@ protected function execute(InputInterface $input, OutputInterface $output)
127108
128109 $ style ->section ('Results ' );
129110 $ output ->writeln ('<info>Command: php -l FILE</> ' );
130- $ output ->writeln ('<info>Files: ' . count ($ files ) . '</> ' );
111+ $ output ->writeln ('<info>Files: ' . count ($ sources ) . '</> ' );
131112 $ output ->writeln ('<info>Time: ' .$ time .' seconds</> ' );
132113 $ style ->newLine ();
133114
134115 return $ exitCode ;
135116 }
117+
118+ /**
119+ * Check how of list is dir and find all files
120+ *
121+ * @param array $sources List of files/dirs
122+ * @return array List of files only
123+ */
124+ public function getAllFiles ($ sources )
125+ {
126+ $ files = array ();
127+ foreach ($ sources as $ source ) {
128+ if (!is_dir ($ source )) {
129+ $ files [] = $ source ;
130+ continue ;
131+ }
132+
133+ $ recursiveFiles = new RecursiveIteratorIterator (
134+ new RecursiveDirectoryIterator ($ source )
135+ );
136+ foreach ($ recursiveFiles as $ file ) {
137+ if ($ file ->isDir ()) {
138+ continue ;
139+ }
140+
141+ $ path = $ file ->getPathname ();
142+ $ info = pathinfo (basename ($ path ));
143+
144+ if (array_key_exists ('extension ' , $ info ) && $ info ['extension ' ] == 'php ' ) {
145+ $ files [] = $ path ;
146+ }
147+ }
148+ }
149+
150+ return $ files ;
151+ }
136152}
0 commit comments