Phan\Phan::expandedFileList PHP Méthode

expandedFileList() public static méthode

public static expandedFileList ( CodeBase $code_base, array $file_path_list ) : array
$code_base CodeBase A code base needs to be passed in because we require it to be initialized before any classes or files are loaded.
$file_path_list array A set of files to expand with the set of dependencies on those files.
Résultat array Get an expanded list of files and dependencies for the given file list
    public static function expandedFileList(CodeBase $code_base, array $file_path_list) : array
    {
        $file_count = count($file_path_list);
        // We'll construct a set of files that we'll
        // want to run an analysis on
        $dependency_file_path_list = [];
        foreach ($file_path_list as $i => $file_path) {
            CLI::progress('dependencies', ($i + 1) / $file_count);
            // Add the file itself to the list
            $dependency_file_path_list[] = $file_path;
            // Add any files that depend on this file
            $dependency_file_path_list = array_merge($dependency_file_path_list, $code_base->dependencyListForFile($file_path));
        }
        return array_unique($dependency_file_path_list);
    }

Usage Example

Exemple #1
0
declare (strict_types=1);
// Phan does a ton of GC and this offers a major speed
// improvment if your system can handle it (which it
// should be able to)
gc_disable();
// Check the environment to make sure Phan can run successfully
require_once __DIR__ . '/requirements.php';
// Build a code base based on PHP internally defined
// functions, methods and classes before loading our
// own
$code_base = (require_once __DIR__ . '/codebase.php');
require_once __DIR__ . '/Phan/Bootstrap.php';
use Phan\CLI;
use Phan\CodeBase;
use Phan\Config;
use Phan\Phan;
// Create our CLI interface and load arguments
$cli = new CLI();
$file_list = $cli->getFileList();
// If requested, expand the file list to a set of
// all files that should be re-analyzed
if (Config::get()->expand_file_list) {
    assert((bool) Config::get()->stored_state_file_path, 'Requesting an expanded dependency list can only ' . ' be done if a state-file is defined');
    // Analyze the file list provided via the CLI
    $file_list = Phan::expandedFileList($code_base, $file_list);
}
// Analyze the file list provided via the CLI
$is_issue_found = Phan::analyzeFileList($code_base, $file_list);
// Provide an exit status code based on if
// issues were found
exit($is_issue_found ? EXIT_ISSUES_FOUND : EXIT_SUCCESS);