@@ -29,6 +29,8 @@ class CheckerCommand extends Command
2929 protected array $ warnings = [];
3030
3131 protected array $ exclude = [];
32+
33+ protected array $ files = [];
3234
3335 protected OutputInterface $ output ;
3436
@@ -46,6 +48,7 @@ protected function configure(): void
4648 ->setDescription ('Check PHP files within a directory for appropriate use of Docblocks. ' )
4749 ->addOption ('exclude ' , 'x ' , InputOption::VALUE_REQUIRED , 'Files and directories to exclude. ' , null )
4850 ->addOption ('directory ' , 'd ' , InputOption::VALUE_REQUIRED , 'Directory to scan. ' , './ ' )
51+ ->addOption ('files ' , 'f ' , InputOption::VALUE_REQUIRED , 'Files to scan. ' , null )
4952 ->addOption ('skip-classes ' , null , InputOption::VALUE_NONE , 'Don \'t check classes for docblocks. ' )
5053 ->addOption ('skip-methods ' , null , InputOption::VALUE_NONE , 'Don \'t check methods for docblocks. ' )
5154 ->addOption ('skip-signatures ' , null , InputOption::VALUE_NONE , 'Don \'t check docblocks against method signatures. ' )
@@ -68,6 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6871 $ exclude = $ input ->getOption ('exclude ' );
6972 $ json = $ input ->getOption ('json ' );
7073 $ this ->basePath = $ input ->getOption ('directory ' );
74+ $ files = $ input ->getOption ('files ' );
7175 $ this ->verbose = !$ json ;
7276 $ this ->output = $ output ;
7377 $ failOnWarnings = $ input ->getOption ('fail-on-warnings ' );
@@ -88,6 +92,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8892 if (!\is_null ($ exclude )) {
8993 $ this ->exclude = \array_map ('trim ' , \explode (', ' , $ exclude ));
9094 }
95+
96+ // Set up files:
97+ if (!\is_null ($ files )) {
98+ $ this ->files = \array_map ('trim ' , \explode (', ' , $ files ));
99+ }
91100
92101 // Check base path ends with a slash:
93102 if (\substr ($ this ->basePath , -1 ) != '/ ' ) {
@@ -96,7 +105,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
96105
97106 // Get files to check:
98107 $ files = [];
99- $ this ->processDirectory ('' , $ files );
108+ if (count ($ this ->files ) > 0 ) {
109+ $ this ->processFiles ('' , $ this ->files , $ files );
110+ } else {
111+ $ this ->processDirectory ('' , $ files );
112+ }
100113
101114 // Check files:
102115 $ filesPerLine = (int )$ input ->getOption ('files-per-line ' );
@@ -232,6 +245,28 @@ protected function processDirectory(string $path = '', array &$workList = []): v
232245 }
233246 }
234247 }
248+
249+ /**
250+ * Iterate through the files and check them out
251+ *
252+ * @param string $path
253+ * @param string[] $files
254+ * @param string[] $workList
255+ */
256+ protected function processFiles (string $ path = '' , array $ files = [], array &$ workList = []): void
257+ {
258+ foreach ($ files as $ item ) {
259+ $ itemPath = $ path . $ item ;
260+
261+ if (\in_array ($ itemPath , $ this ->exclude )) {
262+ continue ;
263+ }
264+
265+ if (is_file ($ itemPath ) && pathinfo ($ itemPath )["extension " ] == 'php ' ) {
266+ $ workList [] = $ itemPath ;
267+ }
268+ }
269+ }
235270
236271 /**
237272 * Check a specific PHP file for errors.
0 commit comments