@@ -46,6 +46,7 @@ protected function configure(): void
46
46
->setDescription ('Check PHP files within a directory for appropriate use of Docblocks. ' )
47
47
->addOption ('exclude ' , 'x ' , InputOption::VALUE_REQUIRED , 'Files and directories to exclude. ' , null )
48
48
->addOption ('directory ' , 'd ' , InputOption::VALUE_REQUIRED , 'Directory to scan. ' , './ ' )
49
+ ->addOption ('files ' , 'f ' , InputOption::VALUE_REQUIRED , 'Files to scan. ' , null )
49
50
->addOption ('skip-classes ' , null , InputOption::VALUE_NONE , 'Don \'t check classes for docblocks. ' )
50
51
->addOption ('skip-methods ' , null , InputOption::VALUE_NONE , 'Don \'t check methods for docblocks. ' )
51
52
->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
68
69
$ exclude = $ input ->getOption ('exclude ' );
69
70
$ json = $ input ->getOption ('json ' );
70
71
$ this ->basePath = $ input ->getOption ('directory ' );
72
+ $ files = $ input ->getOption ('files ' );
71
73
$ this ->verbose = !$ json ;
72
74
$ this ->output = $ output ;
73
75
$ failOnWarnings = $ input ->getOption ('fail-on-warnings ' );
@@ -88,6 +90,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
88
90
if (!\is_null ($ exclude )) {
89
91
$ this ->exclude = \array_map ('trim ' , \explode (', ' , $ exclude ));
90
92
}
93
+
94
+ // Set up files:
95
+ if (!\is_null ($ files )) {
96
+ $ this ->files = \array_map ('trim ' , \explode (', ' , $ files ));
97
+ }
91
98
92
99
// Check base path ends with a slash:
93
100
if (\substr ($ this ->basePath , -1 ) != '/ ' ) {
@@ -96,7 +103,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
96
103
97
104
// Get files to check:
98
105
$ files = [];
99
- $ this ->processDirectory ('' , $ files );
106
+ if (count ($ this ->files ) > 0 ) {
107
+ $ this ->processFiles ('' , $ this ->files , $ files );
108
+ } else {
109
+ $ this ->processDirectory ('' , $ files );
110
+ }
100
111
101
112
// Check files:
102
113
$ filesPerLine = (int )$ input ->getOption ('files-per-line ' );
@@ -232,6 +243,28 @@ protected function processDirectory(string $path = '', array &$workList = []): v
232
243
}
233
244
}
234
245
}
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
+ }
235
268
236
269
/**
237
270
* Check a specific PHP file for errors.
0 commit comments