mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Add checkDir method
This commit is contained in:
parent
82bca7a8b4
commit
01247558d6
@ -3,8 +3,6 @@
|
||||
namespace CodeInspector;
|
||||
|
||||
use CodeInspector\Config\FileFilter;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use SimpleXMLElement;
|
||||
|
||||
class Config
|
||||
@ -108,27 +106,19 @@ class Config
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFilesToCheck()
|
||||
public function getIncludeDirs()
|
||||
{
|
||||
$files = $this->inspect_files->getIncludeFiles();
|
||||
return $this->inspect_files->getIncludeDirs();
|
||||
}
|
||||
|
||||
foreach ($this->inspect_files->getIncludeDirs() as $dir) {
|
||||
/** @var RecursiveDirectoryIterator */
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->base_dir . '/' . $dir));
|
||||
$iterator->rewind();
|
||||
public function getBaseDir()
|
||||
{
|
||||
return $this->base_dir;
|
||||
}
|
||||
|
||||
while ($iterator->valid()) {
|
||||
if (!$iterator->isDot()) {
|
||||
if (in_array($iterator->getExtension(), $this->file_extensions)) {
|
||||
$files[] = $iterator->getRealPath();
|
||||
}
|
||||
}
|
||||
|
||||
$iterator->next();
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
public function getFileExtensions()
|
||||
{
|
||||
return $this->file_extensions;
|
||||
}
|
||||
|
||||
public function getMockClasses()
|
||||
|
@ -2,13 +2,40 @@
|
||||
|
||||
namespace CodeInspector;
|
||||
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
|
||||
class ProjectChecker
|
||||
{
|
||||
public static function check($debug = false)
|
||||
{
|
||||
foreach (Config::getInstance()->getIncludeDirs() as $dir_name) {
|
||||
self::checkDir($dir_name, $debug);
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkDir($dir_name, $debug = false)
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
|
||||
$files = $config->getFilesToCheck();
|
||||
$file_extensions = $config->getFileExtensions();
|
||||
$base_dir = $config->getBaseDir();
|
||||
|
||||
/** @var RecursiveDirectoryIterator */
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($base_dir . '/' . $dir_name));
|
||||
$iterator->rewind();
|
||||
|
||||
$files = [];
|
||||
|
||||
while ($iterator->valid()) {
|
||||
if (!$iterator->isDot()) {
|
||||
if (in_array($iterator->getExtension(), $file_extensions)) {
|
||||
$files[] = $iterator->getRealPath();
|
||||
}
|
||||
}
|
||||
|
||||
$iterator->next();
|
||||
}
|
||||
|
||||
foreach ($files as $file_name) {
|
||||
if ($debug) {
|
||||
@ -18,6 +45,5 @@ class ProjectChecker
|
||||
$file_checker = new FileChecker($file_name);
|
||||
$file_checker->check(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user