Skip to content

Commit 1189ac8

Browse files
committed
Switching to Symfony/finder for file scanning
1 parent 1427a4e commit 1189ac8

File tree

4 files changed

+58
-58
lines changed

4 files changed

+58
-58
lines changed

generator/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"phpoffice/phpspreadsheet": "^1.4",
1313
"ext-json": "^1.5",
1414
"symfony/console": "^4.1.4",
15-
"symfony/process": "^4.1"
15+
"symfony/process": "^4.1",
16+
"symfony/finder": "^4.1"
1617
},
1718
"require-dev": {
1819
"phpunit/phpunit": "^7",

generator/composer.lock

Lines changed: 50 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generator/src/GenerateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
2727
$excludedModules = [
2828
'snmp'
2929
];
30-
$scanner = new Scanner(__DIR__ . '/../doc/doc-en/en/reference/*', $excludedModules);
30+
$scanner = new Scanner(__DIR__ . '/../doc/doc-en/en/reference/', $excludedModules);
3131

3232
[
3333
'functions' => $functions,

generator/src/Scanner.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace Safe;
44

55
use function array_merge;
6+
use function iterator_to_array;
67
use Safe\PhpStanFunctions\PhpStanFunctionMapReader;
8+
use Symfony\Component\Finder\Finder;
79

810
class Scanner
911
{
@@ -32,13 +34,10 @@ public function __construct(string $_path, array $excludedModules)
3234
*/
3335
public function getPaths(): array
3436
{
35-
$incompletePaths = glob($this->path, GLOB_ONLYDIR);
37+
$finder = new Finder();
38+
$finder->in($this->path.'*/functions/')->name('*.xml')->sortByName();
3639

37-
$paths = [];
38-
foreach ($incompletePaths as $incompletePath) {
39-
$paths = array_merge($paths, glob($incompletePath.'/functions/*.xml'));
40-
}
41-
return $paths;
40+
return iterator_to_array($finder);
4241
}
4342

4443
private $ignoredFunctions;

0 commit comments

Comments
 (0)