@@ -46,6 +46,7 @@ protected function configure(): void
4646 ->setDescription ('Check PHP files within a directory for appropriate use of Docblocks. ' )
4747 ->addOption ('exclude ' , 'x ' , InputOption::VALUE_REQUIRED , 'Files and directories to exclude. ' , null )
4848 ->addOption ('directory ' , 'd ' , InputOption::VALUE_REQUIRED , 'Directory to scan. ' , './ ' )
49+ ->addOption ('files ' , 'f ' , InputOption::VALUE_REQUIRED , 'Files to scan. ' , null )
4950 ->addOption ('skip-classes ' , null , InputOption::VALUE_NONE , 'Don \'t check classes for docblocks. ' )
5051 ->addOption ('skip-methods ' , null , InputOption::VALUE_NONE , 'Don \'t check methods for docblocks. ' )
5152 ->addOption ('skip-signatures ' , null , InputOption::VALUE_NONE , 'Don \'t check docblocks against method signatures. ' )
@@ -68,6 +69,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6869 $ exclude = $ input ->getOption ('exclude ' );
6970 $ json = $ input ->getOption ('json ' );
7071 $ this ->basePath = $ input ->getOption ('directory ' );
72+ $ files = $ input ->getOption ('files ' );
7173 $ this ->verbose = !$ json ;
7274 $ this ->output = $ output ;
7375 $ failOnWarnings = $ input ->getOption ('fail-on-warnings ' );
@@ -88,6 +90,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8890 if (!\is_null ($ exclude )) {
8991 $ this ->exclude = \array_map ('trim ' , \explode (', ' , $ exclude ));
9092 }
93+
94+ // Set up files:
95+ if (!\is_null ($ files )) {
96+ $ this ->files = \array_map ('trim ' , \explode (', ' , $ files ));
97+ }
9198
9299 // Check base path ends with a slash:
93100 if (\substr ($ this ->basePath , -1 ) != '/ ' ) {
@@ -96,7 +103,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
96103
97104 // Get files to check:
98105 $ files = [];
99- $ this ->processDirectory ('' , $ files );
106+ if (count ($ this ->files ) > 0 ) {
107+ $ this ->processFiles ('' , $ this ->files , $ files );
108+ } else {
109+ $ this ->processDirectory ('' , $ files );
110+ }
100111
101112 // Check files:
102113 $ filesPerLine = (int )$ input ->getOption ('files-per-line ' );
@@ -232,6 +243,28 @@ protected function processDirectory(string $path = '', array &$workList = []): v
232243 }
233244 }
234245 }
246+
247+ /**
248+ * Iterate through the files and check them out
249+ *
250+ * @param string $path
251+ * @param string[] $files
252+ * @param string[] $workList
253+ */
254+ protected function processFiles (string $ path = '' , array $ files = [], array &$ workList = []): void
255+ {
256+ foreach ($ files as $ item ) {
257+ $ itemPath = $ path . $ item ;
258+
259+ if (\in_array ($ itemPath , $ this ->exclude )) {
260+ continue ;
261+ }
262+
263+ if (is_file ($ itemPath ) && pathinfo ($ itemPath )["extension " ] == 'php ' ) {
264+ $ workList [] = $ itemPath ;
265+ }
266+ }
267+ }
235268
236269 /**
237270 * Check a specific PHP file for errors.
0 commit comments