@@ -68,6 +68,7 @@ protected function configure(): void
6868 ->setDescription ('Check PHP files within a directory for appropriate use of Docblocks. ' )
6969 ->addOption ('exclude ' , 'x ' , InputOption::VALUE_REQUIRED , 'Files and directories to exclude. ' , null )
7070 ->addOption ('directory ' , 'd ' , InputOption::VALUE_REQUIRED , 'Directory to scan. ' , './ ' )
71+ ->addOption ('files ' , 'f ' , InputOption::VALUE_REQUIRED , 'Files to scan. ' , null )
7172 ->addOption ('skip-classes ' , null , InputOption::VALUE_NONE , 'Don \'t check classes for docblocks. ' )
7273 ->addOption ('skip-methods ' , null , InputOption::VALUE_NONE , 'Don \'t check methods for docblocks. ' )
7374 ->addOption ('skip-signatures ' , null , InputOption::VALUE_NONE , 'Don \'t check docblocks against method signatures. ' )
@@ -90,6 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9091 $ exclude = $ input ->getOption ('exclude ' );
9192 $ json = $ input ->getOption ('json ' );
9293 $ this ->basePath = $ input ->getOption ('directory ' );
94+ $ files = $ input ->getOption ('files ' );
9395 $ this ->verbose = !$ json ;
9496 $ this ->output = $ output ;
9597 $ failOnWarnings = $ input ->getOption ('fail-on-warnings ' );
@@ -110,6 +112,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
110112 if (!\is_null ($ exclude )) {
111113 $ this ->exclude = \array_map ('trim ' , \explode (', ' , $ exclude ));
112114 }
115+
116+ // Set up files:
117+ if (!\is_null ($ files )) {
118+ $ this ->files = \array_map ('trim ' , \explode (', ' , $ files ));
119+ }
113120
114121 // Check base path ends with a slash:
115122 if (\substr ($ this ->basePath , -1 ) != '/ ' ) {
@@ -118,7 +125,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
118125
119126 // Get files to check:
120127 $ files = [];
121- $ this ->processDirectory ('' , $ files );
128+ if (count ($ this ->files ) > 0 ) {
129+ $ this ->processFiles ('' , $ this ->files , $ files );
130+ } else {
131+ $ this ->processDirectory ('' , $ files );
132+ }
122133
123134 // Check files:
124135 $ filesPerLine = (int )$ input ->getOption ('files-per-line ' );
@@ -254,6 +265,28 @@ protected function processDirectory(string $path = '', array &$workList = []): v
254265 }
255266 }
256267 }
268+
269+ /**
270+ * Iterate through the files and check them out
271+ *
272+ * @param string $path
273+ * @param string[] $files
274+ * @param string[] $workList
275+ */
276+ protected function processFiles (string $ path = '' , array $ files = [], array &$ workList = []): void
277+ {
278+ foreach ($ files as $ item ) {
279+ $ itemPath = $ path . $ item ;
280+
281+ if (\in_array ($ itemPath , $ this ->exclude )) {
282+ continue ;
283+ }
284+
285+ if (is_file ($ itemPath ) && pathinfo ($ itemPath )["extension " ] == 'php ' ) {
286+ $ workList [] = $ itemPath ;
287+ }
288+ }
289+ }
257290
258291 /**
259292 * Check a specific PHP file for errors.
0 commit comments