diff --git a/src/PhpCodeAnalyzer.php b/src/PhpCodeAnalyzer.php index 59bc4be..426dcde 100644 --- a/src/PhpCodeAnalyzer.php +++ b/src/PhpCodeAnalyzer.php @@ -60,7 +60,8 @@ public function setSinceVersion($version){ } public function loadData() { - foreach (glob(dirname(dirname(__FILE__)).'/data/*.php') as $extension_file) { + $extensions = $this->getExtensionFiles(); + foreach ($extensions as $extension_file) { $ext = basename($extension_file, '.php'); $extension_data = include $extension_file; @@ -323,4 +324,20 @@ public function printUsedExtensions() { echo PHP_EOL; } } + + protected function getExtensionFiles() + { + $files = []; + $dir = dirname(dirname(__FILE__)).'/data/'; + $resource = opendir($dir); + + if ($resource === null) + return []; + + while (($file = readdir($resource)) !== false) { + if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') + $files[] = $dir.'/'.$file; + } + return $files; + } }