1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-14 02:07:37 +01:00
psalm/src/CodeInspector/ProjectChecker.php

50 lines
1.2 KiB
PHP
Raw Normal View History

2016-06-10 00:08:25 +02:00
<?php
namespace CodeInspector;
2016-06-13 21:33:18 +02:00
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
2016-06-10 00:08:25 +02:00
class ProjectChecker
{
public static function check($debug = false)
2016-06-13 21:33:18 +02:00
{
foreach (Config::getInstance()->getIncludeDirs() as $dir_name) {
self::checkDir($dir_name, $debug);
}
}
public static function checkDir($dir_name, $debug = false)
2016-06-10 00:08:25 +02:00
{
$config = Config::getInstance();
2016-06-13 21:33:18 +02:00
$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();
}
2016-06-10 00:08:25 +02:00
foreach ($files as $file_name) {
if ($debug) {
echo 'Checking ' . $file_name . PHP_EOL;
}
$file_checker = new FileChecker($file_name);
$file_checker->check(true);
}
}
}