#!/usr/bin/env php getMessage()); self::printUsage(1); } $files_to_analyze = array_slice($argv, $optind); if (count($files_to_analyze) < 1) { fwrite(STDERR, "ERROR: Expected 1 or more arguments with the phpt files to check\n"); self::printUsage(1); } $extra_files_to_parse = ($options['add-parse-file'] ?? []) ?: []; if (!is_array($extra_files_to_parse)) { $extra_files_to_parse = [$extra_files_to_parse]; } $files_to_parse = array_merge($files_to_analyze, $extra_files_to_parse); foreach ($files_to_parse as $file) { $file = Config::projectPath($file); if (!is_file($file)) { fprintf(STDERR, "Warning: %s does not exist\n", var_representation($file)); } } Config::setValue('file_list', $files_to_analyze); // exclude_file_list is currently redundant to add but harmless. Config::setValue('exclude_file_list', array_diff($extra_files_to_parse, $files_to_analyze)); Config::setValue('include_analysis_file_list', $files_to_analyze); $cli_builder = new CLIBuilder(); $cli_builder->setOption('no-config-file', false); $cli_builder->setOption('allow-polyfill-parser', false); if ($has_any_option('p', 'progress-bar')) { $cli_builder->setOption('progress-bar'); } else { $cli_builder->setOption('no-progress-bar'); } $default_target_php_version = $options['target-php-version'] ?? sprintf('%d.%d', PHP_MAJOR_VERSION, PHP_MINOR_VERSION); $options['target-php-version'] = $default_target_php_version; $options['minimum-target-php-version'] = $options['minimum-target-php-version'] ?? $default_target_php_version; foreach ([ 'debug', 'color', 'no-color', 'color-scheme', 'output-mode', 'target-php-version', 'minimum-target-php-version', ] as $option_name) { if (array_key_exists($option_name, $options)) { $cli_builder->setOption($option_name, $options[$option_name]); } } if (array_key_exists('debug', $options)) { $cli_builder->setOption('debug'); } // CLIBuilder::build will set config options as a side effect // @phan-suppress-next-line PhanThrowTypeAbsentForCall $cli_builder->build(); Config::setValue('analyzed_file_extensions', ['phpt', 'php', 'inc']); // Generate codebase info after parsing configs (e.g. included_extension_subset) $code_base = require(__DIR__ . '/../src/codebase.php'); // @phan-suppress-next-line PhanThrowTypeAbsentForCall Phan::analyzeFileList($code_base, /** @return string[] */ static function () use($files_to_parse) : array { return $files_to_parse; }); } } AnalyzePhpt::main();