1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Revert "Implement better progress"

This reverts commit 042070d0fd3280430c4b2b51bc73acf98d02c744.
This commit is contained in:
Matthew Brown 2019-05-27 13:07:02 -04:00
parent e41733d789
commit 4302596654
36 changed files with 299 additions and 374 deletions

View File

@ -6,7 +6,6 @@ use Psalm;
use Psalm\Checker\CommentChecker;
use Psalm\Codebase;
use Psalm\DocComment;
use Psalm\Progress\Progress;
use Psalm\Storage\FileStorage;
class TemplateScanner extends Psalm\Internal\Scanner\FileScanner
@ -15,6 +14,7 @@ class TemplateScanner extends Psalm\Internal\Scanner\FileScanner
/**
* @param bool $storage_from_cache
* @param bool $debug_output
*
* @return void
*/
@ -22,11 +22,11 @@ class TemplateScanner extends Psalm\Internal\Scanner\FileScanner
Codebase $codebase,
FileStorage $file_storage,
$storage_from_cache = false,
Progress $progress = null
$debug_output = false
) {
$stmts = $codebase->statements_provider->getStatementsForFile(
$file_storage->file_path,
$progress
$debug_output
);
if (empty($stmts)) {
@ -62,6 +62,6 @@ class TemplateScanner extends Psalm\Internal\Scanner\FileScanner
$codebase->scanner->queueClassLikeForScanning(self::VIEW_CLASS, $this->file_path);
parent::scan($codebase, $file_storage, $storage_from_cache, $progress);
parent::scan($codebase, $file_storage, $storage_from_cache, $debug_output);
}
}

View File

@ -12,8 +12,6 @@ use Psalm\Internal\Provider\FileReferenceProvider;
use Psalm\Internal\Provider\FileStorageProvider;
use Psalm\Internal\Provider\Providers;
use Psalm\Internal\Provider\StatementsProvider;
use Psalm\Progress\Progress;
use Psalm\Progress\DefaultProgress;
use Psalm\Storage\ClassLikeStorage;
use Psalm\Storage\FileStorage;
use Psalm\Storage\FunctionLikeStorage;
@ -82,9 +80,9 @@ class Codebase
public $statements_provider;
/**
* @var Progress
* @var bool
*/
private $progress;
private $debug_output = false;
/**
* @var array<string, Type\Union>
@ -192,22 +190,22 @@ class Codebase
*/
public $php_minor_version = PHP_MINOR_VERSION;
/**
* @param bool $debug_output
*/
public function __construct(
Config $config,
Providers $providers,
Progress $progress = null
$debug_output = false
) {
if ($progress === null) {
$progress = new DefaultProgress();
}
$this->config = $config;
$this->file_storage_provider = $providers->file_storage_provider;
$this->classlike_storage_provider = $providers->classlike_storage_provider;
$this->progress = $progress;
$this->debug_output = $debug_output;
$this->file_provider = $providers->file_provider;
$this->file_reference_provider = $providers->file_reference_provider;
$this->statements_provider = $providers->statements_provider;
$this->debug_output = $debug_output;
self::$stubbed_constants = [];
@ -220,7 +218,7 @@ class Codebase
$providers->file_provider,
$this->reflection,
$providers->file_reference_provider,
$progress
$debug_output
);
$this->loadAnalyzer();
@ -252,7 +250,7 @@ class Codebase
$providers->file_storage_provider,
$this->classlikes,
$providers->file_reference_provider,
$progress
$debug_output
);
$this->loadAnalyzer();
@ -267,7 +265,7 @@ class Codebase
$this->config,
$this->file_provider,
$this->file_storage_provider,
$this->progress
$this->debug_output
);
}
@ -415,7 +413,7 @@ class Codebase
{
return $this->statements_provider->getStatementsForFile(
$file_path,
$this->progress
$this->debug_output
);
}

View File

@ -17,8 +17,6 @@ use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\Scanner\FileScanner;
use Psalm\Plugin\Hook;
use Psalm\PluginRegistrationSocket;
use Psalm\Progress\Progress;
use Psalm\Progress\DefaultProgress;
use SimpleXMLElement;
class Config
@ -1436,14 +1434,12 @@ class Config
}
/**
* @param bool $debug
*
* @return void
*/
public function visitStubFiles(Codebase $codebase, Progress $progress = null)
public function visitStubFiles(Codebase $codebase, $debug = false)
{
if ($progress === null) {
$progress = new DefaultProgress();
}
$codebase->register_stub_files = true;
// note: don't realpath $generic_stubs_path, or phar version will fail
@ -1472,11 +1468,15 @@ class Config
$codebase->scanner->addFileToShallowScan($file_path);
}
$progress->debug('Registering stub files' . "\n");
if ($debug) {
echo 'Registering stub files' . "\n";
}
$codebase->scanFiles();
$progress->debug('Finished registering stub files' . "\n");
if ($debug) {
echo 'Finished registering stub files' . "\n";
}
$codebase->register_stub_files = false;
}
@ -1546,17 +1546,15 @@ class Config
}
/**
* @param bool $debug
*
* @return void
*
* @psalm-suppress MixedAssignment
* @psalm-suppress MixedArrayAccess
*/
public function visitComposerAutoloadFiles(ProjectAnalyzer $project_analyzer, Progress $progress = null)
public function visitComposerAutoloadFiles(ProjectAnalyzer $project_analyzer, $debug = false)
{
if ($progress === null) {
$progress = new DefaultProgress();
}
$this->collectPredefinedConstants();
$this->collectPredefinedFunctions();
@ -1612,11 +1610,15 @@ class Config
$codebase->scanner->addFileToDeepScan($file_path);
}
$progress->debug('Registering autoloaded files' . "\n");
if ($debug) {
echo 'Registering autoloaded files' . "\n";
}
$codebase->scanner->scanFiles($codebase->classlikes);
$progress->debug('Finished registering autoloaded files' . "\n");
if ($debug) {
echo 'Finished registering autoloaded files' . "\n";
}
$codebase->register_autoload_files = false;
}

View File

@ -1370,9 +1370,9 @@ class ClassAnalyzer extends ClassLikeAnalyzer
&& !$class_context->collect_mutations
&& !$is_fake
) {
$project_analyzer->progress->debug(
'Skipping analysis of pre-analyzed method ' . $analyzed_method_id . "\n"
);
if ($project_analyzer->debug_output) {
echo 'Skipping analysis of pre-analyzed method ' . $analyzed_method_id . "\n";
}
$existing_issues = $codebase->analyzer->getExistingIssuesForFile(
$source->getFilePath(),

View File

@ -26,8 +26,6 @@ use Psalm\Issue\PossiblyUnusedMethod;
use Psalm\Issue\PossiblyUnusedProperty;
use Psalm\Issue\UnusedMethod;
use Psalm\Issue\UnusedProperty;
use Psalm\Progress\Progress;
use Psalm\Progress\DefaultProgress;
use Psalm\Type;
use Psalm\Issue\CodeIssue;
@ -94,9 +92,9 @@ class ProjectAnalyzer
public $output_format;
/**
* @var Progress
* @var bool
*/
public $progress;
public $debug_output = false;
/**
* @var bool
@ -199,6 +197,7 @@ class ProjectAnalyzer
* @param bool $show_info
* @param string $output_format
* @param int $threads
* @param bool $debug_output
* @param string $reports
* @param bool $show_snippet
*/
@ -209,14 +208,10 @@ class ProjectAnalyzer
$show_info = true,
$output_format = self::TYPE_CONSOLE,
$threads = 1,
Progress $progress = null,
$debug_output = false,
$reports = null,
$show_snippet = true
) {
if ($progress === null) {
$progress = new DefaultProgress();
}
$this->parser_cache_provider = $providers->parser_cache_provider;
$this->file_provider = $providers->file_provider;
$this->classlike_storage_provider = $providers->classlike_storage_provider;
@ -224,7 +219,7 @@ class ProjectAnalyzer
$this->use_color = $use_color;
$this->show_info = $show_info;
$this->progress = $progress;
$this->debug_output = $debug_output;
$this->threads = $threads;
$this->config = $config;
$this->show_snippet = $show_snippet;
@ -232,7 +227,7 @@ class ProjectAnalyzer
$this->codebase = new Codebase(
$config,
$providers,
$progress
$debug_output
);
if (!in_array($output_format, self::SUPPORTED_OUTPUT_TYPES, true)) {
@ -443,7 +438,9 @@ class ProjectAnalyzer
}
}
$this->progress->startScanningFiles();
if ($this->output_format === self::TYPE_CONSOLE) {
echo 'Scanning files...' . "\n";
}
if ($diff_files === null
|| $deleted_files === null
@ -462,8 +459,10 @@ class ProjectAnalyzer
$this->codebase->scanFiles($this->threads);
} else {
$this->progress->debug(count($diff_files) . ' changed files: ' . "\n");
$this->progress->debug(' ' . implode("\n ", $diff_files) . "\n");
if ($this->debug_output) {
echo count($diff_files) . ' changed files: ' . "\n";
echo ' ' . implode("\n ", $diff_files) . "\n";
}
if ($diff_files || $this->codebase->find_unused_code) {
$file_list = $this->getReferencedFilesFromDiff($diff_files);
@ -479,9 +478,11 @@ class ProjectAnalyzer
}
}
$this->progress->startAnalyzingFiles();
if ($this->output_format === self::TYPE_CONSOLE) {
echo 'Analyzing files...' . "\n";
}
$this->config->visitStubFiles($this->codebase, $this->progress);
$this->config->visitStubFiles($this->codebase, $this->debug_output);
$plugin_classes = $this->config->after_codebase_populated;
@ -498,8 +499,8 @@ class ProjectAnalyzer
$is_diff ? $this->parser_cache_provider->getLastGoodRun() : $start_checks
);
if ($removed_parser_files) {
$this->progress->debug('Removed ' . $removed_parser_files . ' old parser caches' . "\n");
if ($this->debug_output && $removed_parser_files) {
echo 'Removed ' . $removed_parser_files . ' old parser caches' . "\n";
}
if ($is_diff) {
@ -519,7 +520,7 @@ class ProjectAnalyzer
$this->codebase->classlikes->checkClassReferences(
$this->codebase->methods,
$this->progress
$this->debug_output
);
}
@ -563,15 +564,19 @@ class ProjectAnalyzer
$this->checkDirWithConfig($dir_name, $this->config, true);
$this->progress->startScanningFiles();
if ($this->output_format === self::TYPE_CONSOLE) {
echo 'Scanning files...' . "\n";
}
$this->config->initializePlugins($this);
$this->codebase->scanFiles($this->threads);
$this->config->visitStubFiles($this->codebase, $this->progress);
$this->config->visitStubFiles($this->codebase, $this->debug_output);
$this->progress->startAnalyzingFiles();
if ($this->output_format === self::TYPE_CONSOLE) {
echo 'Analyzing files...' . "\n";
}
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->codebase->alter_code);
}
@ -667,7 +672,9 @@ class ProjectAnalyzer
}
if (!$config->isInProjectDirs($file_path)) {
$this->progress->debug('skipping ' . $file_path . "\n");
if ($this->debug_output) {
echo 'skipping ' . $file_path . "\n";
}
continue;
}
@ -685,7 +692,9 @@ class ProjectAnalyzer
*/
public function checkFile($file_path)
{
$this->progress->debug('Checking ' . $file_path . "\n");
if ($this->debug_output) {
echo 'Checking ' . $file_path . "\n";
}
$this->config->hide_external_errors = $this->config->isInProjectDirs($file_path);
@ -693,15 +702,19 @@ class ProjectAnalyzer
$this->file_reference_provider->loadReferenceCache();
$this->progress->startScanningFiles();
if ($this->output_format === self::TYPE_CONSOLE) {
echo 'Scanning files...' . "\n";
}
$this->config->initializePlugins($this);
$this->codebase->scanFiles($this->threads);
$this->config->visitStubFiles($this->codebase, $this->progress);
$this->config->visitStubFiles($this->codebase, $this->debug_output);
$this->progress->startAnalyzingFiles();
if ($this->output_format === self::TYPE_CONSOLE) {
echo 'Analyzing files...' . "\n";
}
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->codebase->alter_code);
}
@ -713,7 +726,9 @@ class ProjectAnalyzer
public function checkPaths(array $paths_to_check)
{
foreach ($paths_to_check as $path) {
$this->progress->debug('Checking ' . $path . "\n");
if ($this->debug_output) {
echo 'Checking ' . $path . "\n";
}
if (is_dir($path)) {
$this->checkDirWithConfig($path, $this->config, true);
@ -725,25 +740,26 @@ class ProjectAnalyzer
$this->file_reference_provider->loadReferenceCache();
$this->progress->startScanningFiles();
if ($this->output_format === self::TYPE_CONSOLE) {
echo 'Scanning files...' . "\n";
}
$this->config->initializePlugins($this);
$this->codebase->scanFiles($this->threads);
$this->config->visitStubFiles($this->codebase, $this->progress);
$this->config->visitStubFiles($this->codebase, $this->debug_output);
$this->progress->startAnalyzingFiles();
if ($this->output_format === self::TYPE_CONSOLE) {
echo 'Analyzing files...' . "\n";
}
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->codebase->alter_code);
if ($this->output_format === ProjectAnalyzer::TYPE_CONSOLE && $this->codebase->collect_references) {
fwrite(
STDERR,
PHP_EOL . 'To whom it may concern: Psalm cannot detect unused classes, methods and properties'
echo PHP_EOL . 'To whom it may concern: Psalm cannot detect unused classes, methods and properties'
. PHP_EOL . 'when analyzing individual files and folders. Run on the full project to enable'
. PHP_EOL . 'complete unused code detection.' . PHP_EOL
);
. PHP_EOL . 'complete unused code detection.' . PHP_EOL;
}
}

View File

@ -90,10 +90,10 @@ class IncludeAnalyzer
$file_name = $config->shortenFileName($path_to_file);
$nesting = $statements_analyzer->getRequireNesting() + 1;
$current_file_analyzer->project_analyzer->progress->debug(
str_repeat(' ', $nesting) . 'checking ' . $file_name . PHP_EOL
);
if ($current_file_analyzer->project_analyzer->debug_output) {
$nesting = $statements_analyzer->getRequireNesting() + 1;
echo (str_repeat(' ', $nesting) . 'checking ' . $file_name . PHP_EOL);
}
$include_file_analyzer = new \Psalm\Internal\Analyzer\FileAnalyzer(
$current_file_analyzer->project_analyzer,

View File

@ -193,7 +193,7 @@ class StatementsAnalyzer extends SourceAnalyzer implements StatementsSource
}
if ($project_analyzer->debug_lines) {
fwrite(STDERR, $this->getFilePath() . ':' . $stmt->getLine() . "\n");
echo $this->getFilePath() . ':' . $stmt->getLine() . "\n";
}
/*

View File

@ -11,7 +11,6 @@ use Psalm\Internal\FileManipulation\FunctionDocblockManipulator;
use Psalm\IssueBuffer;
use Psalm\Internal\Provider\FileProvider;
use Psalm\Internal\Provider\FileStorageProvider;
use Psalm\Progress\Progress;
/**
* @psalm-type IssueData = array{
@ -78,9 +77,9 @@ class Analyzer
private $file_storage_provider;
/**
* @var Progress
* @var bool
*/
private $progress;
private $debug_output;
/**
* Used to store counts of mixed vs non-mixed variables
@ -135,16 +134,19 @@ class Analyzer
*/
private $type_map = [];
/**
* @param bool $debug_output
*/
public function __construct(
Config $config,
FileProvider $file_provider,
FileStorageProvider $file_storage_provider,
Progress $progress
$debug_output
) {
$this->config = $config;
$this->file_provider = $file_provider;
$this->file_storage_provider = $file_storage_provider;
$this->progress = $progress;
$this->debug_output = $debug_output;
}
/**
@ -197,7 +199,9 @@ class Analyzer
$file_analyzer = new FileAnalyzer($project_analyzer, $file_path, $file_name);
}
$this->progress->debug('Getting ' . $file_path . "\n");
if ($this->debug_output) {
echo 'Getting ' . $file_path . "\n";
}
return $file_analyzer;
}
@ -226,7 +230,9 @@ class Analyzer
function ($_, $file_path) use ($project_analyzer, $filetype_analyzers) {
$file_analyzer = $this->getFileAnalyzer($project_analyzer, $file_path, $filetype_analyzers);
$this->progress->debug('Analyzing ' . $file_analyzer->getFilePath() . "\n");
if ($this->debug_output) {
echo 'Analyzing ' . $file_analyzer->getFilePath() . "\n";
}
$file_analyzer->analyze(null);
};
@ -268,7 +274,9 @@ class Analyzer
$analyzer = $codebase->analyzer;
$file_reference_provider = $codebase->file_reference_provider;
$this->progress->debug('Gathering data for forked process' . "\n");
if ($this->debug_output) {
echo 'Gathering data for forked process' . "\n";
}
return [
'issues' => IssueBuffer::getIssuesData(),
@ -295,7 +303,9 @@ class Analyzer
}
);
$this->progress->debug('Forking analysis' . "\n");
if ($this->debug_output) {
echo 'Forking analysis' . "\n";
}
// Wait for all tasks to complete and collect the results.
/**
@ -303,7 +313,9 @@ class Analyzer
*/
$forked_pool_data = $pool->wait();
$this->progress->debug('Collecting forked analysis results' . "\n");
if ($this->debug_output) {
echo 'Collecting forked analysis results' . "\n";
}
foreach ($forked_pool_data as $pool_data) {
IssueBuffer::addIssues($pool_data['issues']);

View File

@ -17,8 +17,6 @@ use Psalm\Issue\UnusedProperty;
use Psalm\IssueBuffer;
use Psalm\Internal\Provider\ClassLikeStorageProvider;
use Psalm\Internal\Provider\FileReferenceProvider;
use Psalm\Progress\Progress;
use Psalm\Progress\DefaultProgress;
use Psalm\Storage\ClassLikeStorage;
use Psalm\Type;
use ReflectionProperty;
@ -667,14 +665,12 @@ class ClassLikes
/**
* @return void
*/
public function checkClassReferences(Methods $methods, Progress $progress = null)
public function checkClassReferences(Methods $methods, bool $debug_output = false)
{
if ($progress === null) {
$progress = new DefaultProgress();
if ($debug_output) {
echo 'Checking class references' . PHP_EOL;
}
$progress->debug('Checking class references' . PHP_EOL);
foreach ($this->existing_classlikes_lc as $fq_class_name_lc => $_) {
try {
$classlike_storage = $this->classlike_storage_provider->get($fq_class_name_lc);

View File

@ -9,7 +9,6 @@ use Psalm\IssueBuffer;
use Psalm\Internal\Provider\ClassLikeStorageProvider;
use Psalm\Internal\Provider\FileReferenceProvider;
use Psalm\Internal\Provider\FileStorageProvider;
use Psalm\Progress\Progress;
use Psalm\Storage\ClassLikeStorage;
use Psalm\Storage\FileStorage;
use Psalm\Type;
@ -32,9 +31,9 @@ class Populator
private $file_storage_provider;
/**
* @var Progress
* @var bool
*/
private $progress;
private $debug_output;
/**
* @var ClassLikes
@ -51,18 +50,21 @@ class Populator
*/
private $file_reference_provider;
/**
* @param bool $debug_output
*/
public function __construct(
Config $config,
ClassLikeStorageProvider $classlike_storage_provider,
FileStorageProvider $file_storage_provider,
ClassLikes $classlikes,
FileReferenceProvider $file_reference_provider,
Progress $progress
$debug_output
) {
$this->classlike_storage_provider = $classlike_storage_provider;
$this->file_storage_provider = $file_storage_provider;
$this->classlikes = $classlikes;
$this->progress = $progress;
$this->debug_output = $debug_output;
$this->config = $config;
$this->file_reference_provider = $file_reference_provider;
}
@ -72,15 +74,21 @@ class Populator
*/
public function populateCodebase(\Psalm\Codebase $codebase)
{
$this->progress->debug('ClassLikeStorage is populating' . "\n");
if ($this->debug_output) {
echo 'ClassLikeStorage is populating' . "\n";
}
foreach ($this->classlike_storage_provider->getNew() as $class_storage) {
$this->populateClassLikeStorage($class_storage);
}
$this->progress->debug('ClassLikeStorage is populated' . "\n");
if ($this->debug_output) {
echo 'ClassLikeStorage is populated' . "\n";
}
$this->progress->debug('FileStorage is populating' . "\n");
if ($this->debug_output) {
echo 'FileStorage is populating' . "\n";
}
$all_file_storage = $this->file_storage_provider->getNew();
@ -167,7 +175,9 @@ class Populator
}
}
$this->progress->debug('FileStorage is populated' . "\n");
if ($this->debug_output) {
echo 'FileStorage is populated' . "\n";
}
$this->classlike_storage_provider->populated();
$this->file_storage_provider->populated();
@ -261,7 +271,9 @@ class Populator
$this->populateOverriddenMethods($storage);
$this->progress->debug('Have populated ' . $storage->name . "\n");
if ($this->debug_output) {
echo 'Have populated ' . $storage->name . "\n";
}
$storage->populated = true;
}
@ -445,7 +457,9 @@ class Populator
);
$parent_storage = $storage_provider->get($parent_storage_class);
} catch (\InvalidArgumentException $e) {
$this->progress->debug('Populator could not find dependency (' . __LINE__ . ")\n");
if ($this->debug_output) {
echo 'Populator could not find dependency (' . __LINE__ . ")\n";
}
$storage->invalid_dependencies[] = $parent_storage_class;
$parent_storage = null;
@ -557,7 +571,9 @@ class Populator
);
$parent_interface_storage = $storage_provider->get($parent_interface_lc);
} catch (\InvalidArgumentException $e) {
$this->progress->debug('Populator could not find dependency (' . __LINE__ . ")\n");
if ($this->debug_output) {
echo 'Populator could not find dependency (' . __LINE__ . ")\n";
}
$storage->invalid_dependencies[] = $parent_interface_lc;
continue;
@ -645,7 +661,9 @@ class Populator
);
$implemented_interface_storage = $storage_provider->get($implemented_interface_lc);
} catch (\InvalidArgumentException $e) {
$this->progress->debug('Populator could not find dependency (' . __LINE__ . ")\n");
if ($this->debug_output) {
echo 'Populator could not find dependency (' . __LINE__ . ")\n";
}
$storage->invalid_dependencies[] = $implemented_interface_lc;
continue;

View File

@ -7,7 +7,6 @@ use Psalm\Internal\Provider\FileProvider;
use Psalm\Internal\Provider\FileReferenceProvider;
use Psalm\Internal\Provider\FileStorageProvider;
use Psalm\Internal\Scanner\FileScanner;
use Psalm\Progress\Progress;
/**
* @psalm-type IssueData = array{
@ -128,9 +127,9 @@ class Scanner
private $config;
/**
* @var Progress
* @var bool
*/
private $progress;
private $debug_output;
/**
* @var FileStorageProvider
@ -152,6 +151,9 @@ class Scanner
*/
private $is_forked = false;
/**
* @param bool $debug_output
*/
public function __construct(
Codebase $codebase,
Config $config,
@ -159,12 +161,12 @@ class Scanner
FileProvider $file_provider,
Reflection $reflection,
FileReferenceProvider $file_reference_provider,
Progress $progress
$debug_output
) {
$this->codebase = $codebase;
$this->reflection = $reflection;
$this->file_provider = $file_provider;
$this->progress = $progress;
$this->debug_output = $debug_output;
$this->file_storage_provider = $file_storage_provider;
$this->config = $config;
$this->file_reference_provider = $file_reference_provider;
@ -384,14 +386,18 @@ class Scanner
++$i;
}
$this->progress->debug('Forking process for scanning' . PHP_EOL);
if ($this->debug_output) {
echo 'Forking process for scanning' . PHP_EOL;
}
// Run scanning one file at a time, splitting the set of
// files up among a given number of child processes.
$pool = new \Psalm\Internal\Fork\Pool(
$process_file_paths,
function () {
$this->progress->debug('Initialising forked process for scanning' . PHP_EOL);
if ($this->debug_output) {
echo 'Initialising forked process for scanning' . PHP_EOL;
}
$project_analyzer = \Psalm\Internal\Analyzer\ProjectAnalyzer::getInstance();
$codebase = $project_analyzer->getCodebase();
@ -403,14 +409,18 @@ class Scanner
$statements_provider->resetDiffs();
$this->progress->debug('Have initialised forked process for scanning' . PHP_EOL);
if ($this->debug_output) {
echo 'Have initialised forked process for scanning' . PHP_EOL;
}
},
$scanner_worker,
/**
* @return PoolData
*/
function () {
$this->progress->debug('Collecting data from forked scanner process' . PHP_EOL);
if ($this->debug_output) {
echo 'Collecting data from forked scanner process' . PHP_EOL;
}
$project_analyzer = \Psalm\Internal\Analyzer\ProjectAnalyzer::getInstance();
$codebase = $project_analyzer->getCodebase();
@ -510,7 +520,9 @@ class Scanner
continue;
}
$this->progress->debug('Using reflection to get metadata for ' . $fq_classlike_name . "\n");
if ($this->debug_output) {
echo 'Using reflection to get metadata for ' . $fq_classlike_name . "\n";
}
/** @psalm-suppress TypeCoercion */
$reflected_class = new \ReflectionClass($fq_classlike_name);
@ -584,7 +596,7 @@ class Scanner
$this->codebase,
$file_storage,
$from_cache,
$this->progress
$this->debug_output
);
if (!$from_cache) {
@ -698,7 +710,9 @@ class Scanner
$composer_file_path = $this->config->getComposerFilePathForClassLike($fq_class_name);
if ($composer_file_path && file_exists($composer_file_path)) {
$this->progress->debug('Using composer to locate file for ' . $fq_class_name . "\n");
if ($this->debug_output) {
echo 'Using composer to locate file for ' . $fq_class_name . "\n";
}
$classlikes->addFullyQualifiedClassLikeName(
$fq_class_name_lc,
@ -710,10 +724,14 @@ class Scanner
$old_level = error_reporting();
$this->progress->setErrorReporting();
if (!$this->debug_output) {
error_reporting(E_ERROR);
}
try {
$this->progress->debug('Using reflection to locate file for ' . $fq_class_name . "\n");
if ($this->debug_output) {
echo 'Using reflection to locate file for ' . $fq_class_name . "\n";
}
/** @psalm-suppress TypeCoercion */
$reflected_class = new \ReflectionClass($fq_class_name);

View File

@ -184,7 +184,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
$codebase->scanFiles($this->project_analyzer->threads);
$codebase->config->visitStubFiles($codebase, null);
$codebase->config->visitStubFiles($codebase, false);
if ($this->textDocument === null) {
$this->textDocument = new TextDocument(

View File

@ -2,8 +2,6 @@
namespace Psalm\Internal\Provider;
use PhpParser;
use Psalm\Progress\Progress;
use Psalm\Progress\DefaultProgress;
/**
* @internal
@ -67,16 +65,13 @@ class StatementsProvider
}
/**
* @param string $file_path
* @param string $file_path
* @param bool $debug_output
*
* @return array<int, \PhpParser\Node\Stmt>
*/
public function getStatementsForFile($file_path, Progress $progress = null)
public function getStatementsForFile($file_path, $debug_output = false)
{
if ($progress === null) {
$progress = new DefaultProgress();
}
$from_cache = false;
$version = (string) PHP_PARSER_VERSION . $this->this_modified_time;
@ -85,7 +80,9 @@ class StatementsProvider
$modified_time = $this->file_provider->getModifiedTime($file_path);
if (!$this->parser_cache_provider) {
$progress->debug('Parsing ' . $file_path . "\n");
if ($debug_output) {
echo 'Parsing ' . $file_path . "\n";
}
$stmts = self::parseStatements($file_contents, $file_path);
@ -101,7 +98,9 @@ class StatementsProvider
);
if ($stmts === null) {
$progress->debug('Parsing ' . $file_path . "\n");
if ($debug_output) {
echo 'Parsing ' . $file_path . "\n";
}
$existing_statements = $this->parser_cache_provider->loadExistingStatementsFromCache($file_path);

View File

@ -5,8 +5,6 @@ use PhpParser;
use PhpParser\NodeTraverser;
use Psalm\Codebase;
use Psalm\FileSource;
use Psalm\Progress\Progress;
use Psalm\Progress\DefaultProgress;
use Psalm\Storage\FileStorage;
use Psalm\Internal\Visitor\ReflectorVisitor;
@ -44,6 +42,7 @@ class FileScanner implements FileSource
/**
* @param bool $storage_from_cache
* @param bool $debug_output
*
* @return void
*/
@ -51,12 +50,8 @@ class FileScanner implements FileSource
Codebase $codebase,
FileStorage $file_storage,
$storage_from_cache = false,
Progress $progress = null
$debug_output = false
) {
if ($progress === null) {
$progress = new DefaultProgress();
}
if ((!$this->will_analyze || $file_storage->deep_scan)
&& $storage_from_cache
&& !$file_storage->has_trait
@ -68,7 +63,7 @@ class FileScanner implements FileSource
$stmts = $codebase->statements_provider->getStatementsForFile(
$file_storage->file_path,
$progress
$debug_output
);
foreach ($stmts as $stmt) {
@ -82,10 +77,12 @@ class FileScanner implements FileSource
}
}
if ($this->will_analyze) {
$progress->debug('Deep scanning ' . $file_storage->file_path . "\n");
} else {
$progress->debug('Scanning ' . $file_storage->file_path . "\n");
if ($debug_output) {
if ($this->will_analyze) {
echo 'Deep scanning ' . $file_storage->file_path . "\n";
} else {
echo 'Scanning ' . $file_storage->file_path . "\n";
}
}
$traverser = new NodeTraverser();

View File

@ -21,7 +21,7 @@ class Shepherd implements \Psalm\Plugin\Hook\AfterAnalysisInterface
SourceControlInfo $source_control_info = null
) {
if (!function_exists('curl_init')) {
fwrite(STDERR, 'No curl found, cannot send data to ' . $codebase->config->shepherd_host . PHP_EOL);
echo 'No curl found, cannot send data to ' . $codebase->config->shepherd_host . PHP_EOL;
return;
}
@ -67,115 +67,115 @@ class Shepherd implements \Psalm\Plugin\Hook\AfterAnalysisInterface
$return = curl_exec($ch);
if ($return !== '') {
fwrite(STDERR, 'Error with Psalm Shepherd:' . PHP_EOL);
echo 'Error with Psalm Shepherd:' . PHP_EOL;
if ($return === false) {
/** @var array */
$curl_info = curl_getinfo($ch);
if (($curl_info['ssl_verify_result'] ?? 0) !== 0) {
fwrite(STDERR, 'Curl SSL error: ');
echo 'Curl SSL error: ';
switch ($curl_info['ssl_verify_result']) {
case 2:
fwrite(STDERR, 'unable to get issuer certificate');
echo 'unable to get issuer certificate';
break;
case 3:
fwrite(STDERR, 'unable to get certificate CRL');
echo 'unable to get certificate CRL';
break;
case 4:
fwrite(STDERR, 'unable to decrypt certificates signature');
echo 'unable to decrypt certificates signature';
break;
case 5:
fwrite(STDERR, 'unable to decrypt CRLs signature');
echo 'unable to decrypt CRLs signature';
break;
case 6:
fwrite(STDERR, 'unable to decode issuer public key');
echo 'unable to decode issuer public key';
break;
case 7:
fwrite(STDERR, 'certificate signature failure');
echo 'certificate signature failure';
break;
case 8:
fwrite(STDERR, 'CRL signature failure');
echo 'CRL signature failure';
break;
case 9:
fwrite(STDERR, 'certificate is not yet valid');
echo 'certificate is not yet valid';
break;
case 10:
fwrite(STDERR, 'certificate has expired');
echo 'certificate has expired';
break;
case 11:
fwrite(STDERR, 'CRL is not yet valid');
echo 'CRL is not yet valid';
break;
case 12:
fwrite(STDERR, 'CRL has expired');
echo 'CRL has expired';
break;
case 13:
fwrite(STDERR, 'format error in certificates notBefore field');
echo 'format error in certificates notBefore field';
break;
case 14:
fwrite(STDERR, 'format error in certificates notAfter field');
echo 'format error in certificates notAfter field';
break;
case 15:
fwrite(STDERR, 'format error in CRLs lastUpdate field');
echo 'format error in CRLs lastUpdate field';
break;
case 16:
fwrite(STDERR, 'format error in CRLs nextUpdate field');
echo 'format error in CRLs nextUpdate field';
break;
case 17:
fwrite(STDERR, 'out of memory');
echo 'out of memory';
break;
case 18:
fwrite(STDERR, 'self signed certificate');
echo 'self signed certificate';
break;
case 19:
fwrite(STDERR, 'self signed certificate in certificate chain');
echo 'self signed certificate in certificate chain';
break;
case 20:
fwrite(STDERR, 'unable to get local issuer certificate');
echo 'unable to get local issuer certificate';
break;
case 21:
fwrite(STDERR, 'unable to verify the first certificate');
echo 'unable to verify the first certificate';
break;
case 22:
fwrite(STDERR, 'certificate chain too long');
echo 'certificate chain too long';
break;
case 23:
fwrite(STDERR, 'certificate revoked');
echo 'certificate revoked';
break;
case 24:
fwrite(STDERR, 'invalid CA certificate');
echo 'invalid CA certificate';
break;
case 25:
fwrite(STDERR, 'path length constraint exceeded');
echo 'path length constraint exceeded';
break;
case 26:
fwrite(STDERR, 'unsupported certificate purpose');
echo 'unsupported certificate purpose';
break;
case 27:
fwrite(STDERR, 'certificate not trusted');
echo 'certificate not trusted';
break;
case 28:
fwrite(STDERR, 'certificate rejected');
echo 'certificate rejected';
break;
case 29:
fwrite(STDERR, 'subject issuer mismatch');
echo 'subject issuer mismatch';
break;
case 30:
fwrite(STDERR, 'authority and subject key identifier mismatch');
echo 'authority and subject key identifier mismatch';
break;
case 31:
fwrite(STDERR, 'authority and issuer serial number mismatch');
echo 'authority and issuer serial number mismatch';
break;
case 32:
fwrite(STDERR, 'key usage does not include certificate signing');
echo 'key usage does not include certificate signing';
break;
case 50:
fwrite(STDERR, 'application verification failure');
echo 'application verification failure';
break;
}
fwrite(STDERR, PHP_EOL);
echo PHP_EOL;
} else {
echo var_export(curl_getinfo($ch), true) . PHP_EOL;
}

View File

@ -1,26 +0,0 @@
<?php
namespace Psalm\Progress;
class DebugProgress extends Progress
{
public function setErrorReporting(): void
{
error_reporting(E_ALL);
}
public function debug(string $message): void
{
fwrite(STDERR, $message);
}
public function startScanningFiles(): void
{
fwrite(STDERR, 'Scanning files...' . "\n");
}
public function startAnalyzingFiles(): void
{
fwrite(STDERR, 'Analyzing files...' . "\n");
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace Psalm\Progress;
abstract class Progress
{
public function setErrorReporting(): void
{
error_reporting(E_ERROR);
}
public function debug(string $message): void
{
}
public function startScanningFiles(): void
{
}
public function startAnalyzingFiles(): void
{
}
}

View File

@ -64,7 +64,7 @@ function requireAutoloaders($current_dir, $has_explicit_root, $vendor_dir)
. 'to specify a particular project to run Psalm on.';
}
fwrite(STDERR, $error_message . PHP_EOL);
echo $error_message . PHP_EOL;
exit(1);
}
}
@ -88,15 +88,13 @@ function requireAutoloaders($current_dir, $has_explicit_root, $vendor_dir)
if ($first_autoloader === null && !$in_phar) {
if (!$autoload_files) {
fwrite(STDERR, 'Failed to find a valid Composer autoloader' . "\n");
echo 'Failed to find a valid Composer autoloader' . "\n";
} else {
fwrite(STDERR, 'Failed to find a valid Composer autoloader in ' . implode(', ', $autoload_files) . "\n");
echo 'Failed to find a valid Composer autoloader in ' . implode(', ', $autoload_files) . "\n";
}
fwrite(
STDERR,
'Please make sure youve run `composer install` in the current directory before using Psalm.' . "\n"
);
echo 'Please make sure youve run `composer install` in the current directory before using Psalm.' . "\n";
exit(1);
}
@ -196,19 +194,19 @@ function getPathsToCheck($f_paths)
foreach ($filtered_input_paths as $path_to_check) {
if ($path_to_check[0] === '-') {
fwrite(STDERR, 'Invalid usage, expecting psalm [options] [file...]' . PHP_EOL);
echo 'Invalid usage, expecting psalm [options] [file...]' . PHP_EOL;
exit(1);
}
if (!file_exists($path_to_check)) {
fwrite(STDERR, 'Cannot locate ' . $path_to_check . PHP_EOL);
echo 'Cannot locate ' . $path_to_check . PHP_EOL;
exit(1);
}
$path_to_check = realpath($path_to_check);
if (!$path_to_check) {
fwrite(STDERR, 'Error getting realpath for file' . PHP_EOL);
echo 'Error getting realpath for file' . PHP_EOL;
exit(1);
}

View File

@ -52,11 +52,8 @@ array_map(
&& !in_array($arg_name . ':', $valid_long_options)
&& !in_array($arg_name . '::', $valid_long_options)
) {
fwrite(
STDERR,
'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL
);
echo 'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL;
error_log('Bad argument');
exit(1);
}
@ -64,11 +61,8 @@ array_map(
$arg_name = preg_replace('/=.*$/', '', substr($arg, 1));
if (!in_array($arg_name, $valid_short_options) && !in_array($arg_name . ':', $valid_short_options)) {
fwrite(
STDERR,
'Unrecognised argument "-' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL
);
echo 'Unrecognised argument "-' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL;
error_log('Bad argument');
exit(1);
}
@ -99,7 +93,7 @@ if (isset($options['config'])) {
}
if (isset($options['c']) && is_array($options['c'])) {
fwrite(STDERR, 'Too many config files provided' . PHP_EOL);
echo 'Too many config files provided' . PHP_EOL;
exit(1);
}
@ -148,7 +142,7 @@ HELP;
}
if (getcwd() === false) {
fwrite(STDERR, 'Cannot get current working directory' . PHP_EOL);
echo 'Cannot get current working directory' . PHP_EOL;
exit(1);
}
@ -162,10 +156,7 @@ if (isset($options['r']) && is_string($options['r'])) {
$root_path = realpath($options['r']);
if (!$root_path) {
fwrite(
STDERR,
'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL
);
echo 'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL;
exit(1);
}
@ -198,13 +189,13 @@ $path_to_config = isset($options['c']) && is_string($options['c']) ? realpath($o
if ($path_to_config === false) {
/** @psalm-suppress InvalidCast */
fwrite(STDERR, 'Could not resolve path to config ' . (string)$options['c'] . PHP_EOL);
echo 'Could not resolve path to config ' . (string)$options['c'] . PHP_EOL;
exit(1);
}
if (isset($options['tcp'])) {
if (!is_string($options['tcp'])) {
fwrite(STDERR, 'tcp url should be a string' . PHP_EOL);
echo 'tcp url should be a string' . PHP_EOL;
exit(1);
}
}
@ -219,7 +210,7 @@ try {
$config = Config::getConfigForPath($current_dir, $current_dir, $output_format);
}
} catch (Psalm\Exception\ConfigException $e) {
fwrite(STDERR, $e->getMessage());
echo $e->getMessage();
exit(1);
}

View File

@ -6,8 +6,6 @@ use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\Provider;
use Psalm\Config;
use Psalm\IssueBuffer;
use Psalm\Progress\DebugProgress;
use Psalm\Progress\DefaultProgress;
// show all errors
error_reporting(-1);
@ -91,22 +89,16 @@ array_map(
&& !in_array($arg_name . ':', $valid_long_options)
&& !in_array($arg_name . '::', $valid_long_options)
) {
fwrite(
STDERR,
'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL
);
echo 'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL;
exit(1);
}
} elseif (substr($arg, 0, 2) === '-' && $arg !== '-' && $arg !== '--') {
$arg_name = preg_replace('/=.*$/', '', substr($arg, 1));
if (!in_array($arg_name, $valid_short_options) && !in_array($arg_name . ':', $valid_short_options)) {
fwrite(
STDERR,
'Unrecognised argument "-' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL
);
echo 'Unrecognised argument "-' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL;
exit(1);
}
}
@ -141,7 +133,7 @@ if (isset($options['config'])) {
}
if (isset($options['c']) && is_array($options['c'])) {
fwrite(STDERR, 'Too many config files provided' . PHP_EOL);
echo 'Too many config files provided' . PHP_EOL;
exit(1);
}
@ -262,7 +254,7 @@ HELP;
}
if (getcwd() === false) {
fwrite(STDERR, 'Cannot get current working directory' . PHP_EOL);
echo 'Cannot get current working directory' . PHP_EOL;
exit(1);
}
@ -276,10 +268,7 @@ if (isset($options['r']) && is_string($options['r'])) {
$root_path = realpath($options['r']);
if (!$root_path) {
fwrite(
STDERR,
'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL
);
echo 'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL;
exit(1);
}
@ -407,7 +396,7 @@ $path_to_config = isset($options['c']) && is_string($options['c']) ? realpath($o
if ($path_to_config === false) {
/** @psalm-suppress InvalidCast */
fwrite(STDERR, 'Could not resolve path to config ' . (string)$options['c'] . PHP_EOL);
echo 'Could not resolve path to config ' . (string)$options['c'] . PHP_EOL;
exit(1);
}
@ -443,7 +432,7 @@ try {
$config = Config::getConfigForPath($current_dir, $current_dir, $output_format);
}
} catch (Psalm\Exception\ConfigException $e) {
fwrite(STDERR, $e->getMessage() . PHP_EOL);
echo $e->getMessage() . PHP_EOL;
exit(1);
}
@ -482,9 +471,6 @@ if (isset($options['clear-global-cache'])) {
}
$debug = array_key_exists('debug', $options) || array_key_exists('debug-by-line', $options);
$progress = $debug
? new DebugProgress()
: new DefaultProgress();
if (isset($options['no-cache'])) {
$providers = new Provider\Providers(
@ -517,7 +503,7 @@ $project_analyzer = new ProjectAnalyzer(
$show_info,
$output_format,
$threads,
$progress,
$debug,
isset($options['report']) && is_string($options['report']) ? $options['report'] : null,
!isset($options['show-snippet']) || $options['show-snippet'] !== "false"
);
@ -539,11 +525,13 @@ if ($type_map_location) {
$start_time = microtime(true);
$config->visitComposerAutoloadFiles($project_analyzer, $progress);
$config->visitComposerAutoloadFiles($project_analyzer, $debug);
$now_time = microtime(true);
$progress->debug('Visiting autoload files took ' . number_format($now_time - $start_time, 3) . 's' . "\n");
if ($debug) {
echo 'Visiting autoload files took ' . number_format($now_time - $start_time, 3) . 's' . "\n";
}
if (array_key_exists('debug-by-line', $options)) {
$project_analyzer->debug_lines = true;
@ -583,9 +571,11 @@ if ($find_references_to) {
if (isset($options['set-baseline']) && is_string($options['set-baseline'])) {
if ($is_diff) {
fwrite(STDERR, 'Cannot set baseline in --diff mode' . PHP_EOL);
if ($output_format === ProjectAnalyzer::TYPE_CONSOLE) {
echo 'Cannot set baseline in --diff mode' . PHP_EOL;
}
} else {
fwrite(STDERR, 'Writing error baseline to file...' . PHP_EOL);
echo 'Writing error baseline to file...', PHP_EOL;
ErrorBaseline::create(
new \Psalm\Internal\Provider\FileProvider,
@ -593,7 +583,7 @@ if (isset($options['set-baseline']) && is_string($options['set-baseline'])) {
IssueBuffer::getIssuesData()
);
fwrite(STDERR, "Baseline saved to {$options['set-baseline']}.");
echo "Baseline saved to {$options['set-baseline']}.";
/** @var string $configFile */
$configFile = Config::locateConfigFile($path_to_config ?? $current_dir);
@ -609,7 +599,7 @@ if (isset($options['set-baseline']) && is_string($options['set-baseline'])) {
$endPsalmOpenTag = strpos($configFileContents, '>', (int)strpos($configFileContents, '<psalm'));
if (!$endPsalmOpenTag) {
fwrite(STDERR, " Don't forget to set errorBaseline=\"{$options['set-baseline']}\" in your config.");
echo " Don't forget to set errorBaseline=\"{$options['set-baseline']}\" in your config.";
} elseif ($configFileContents[$endPsalmOpenTag - 1] === "\n") {
$amendedConfigFileContents = substr_replace(
$configFileContents,
@ -629,7 +619,7 @@ if (isset($options['set-baseline']) && is_string($options['set-baseline'])) {
file_put_contents($configFile, $amendedConfigFileContents);
fwrite(STDERR, PHP_EOL);
echo PHP_EOL;
}
}
@ -637,7 +627,9 @@ $issue_baseline = [];
if (isset($options['update-baseline'])) {
if ($is_diff) {
fwrite(STDERR, 'Cannot update baseline in --diff mode' . PHP_EOL);
if ($output_format === ProjectAnalyzer::TYPE_CONSOLE) {
echo 'Cannot update baseline in --diff mode' . PHP_EOL;
}
} else {
$baselineFile = Config::getInstance()->error_baseline;
@ -666,8 +658,7 @@ if (isset($options['update-baseline'])) {
echo $total_fixed_issues . ' errors fixed' . "\n";
}
} catch (\Psalm\Exception\ConfigException $exception) {
fwrite(STDERR, 'Could not update baseline file: ' . $exception->getMessage() . PHP_EOL);
exit(1);
die('Could not update baseline file: ' . $exception->getMessage());
}
}
}

View File

@ -4,8 +4,6 @@ require_once('command_functions.php');
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Config;
use Psalm\IssueBuffer;
use Psalm\Progress\DebugProgress;
use Psalm\Progress\DefaultProgress;
// show all errors
error_reporting(-1);
@ -43,22 +41,16 @@ array_map(
&& !in_array($arg_name . ':', $valid_long_options)
&& !in_array($arg_name . '::', $valid_long_options)
) {
fwrite(
STDERR,
'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL
);
echo 'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL;
exit(1);
}
} elseif (substr($arg, 0, 2) === '-' && $arg !== '-' && $arg !== '--') {
$arg_name = preg_replace('/=.*$/', '', substr($arg, 1));
if (!in_array($arg_name, $valid_short_options) && !in_array($arg_name . ':', $valid_short_options)) {
fwrite(
STDERR,
'Unrecognised argument "-' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL
);
echo 'Unrecognised argument "-' . $arg_name . '"' . PHP_EOL
. 'Type --help to see a list of supported arguments'. PHP_EOL;
exit(1);
}
}
@ -203,11 +195,6 @@ if (array_key_exists('list-supported-issues', $options)) {
exit();
}
$debug = array_key_exists('debug', $options);
$progress = $debug
? new DebugProgress()
: new DefaultProgress();
$project_analyzer = new ProjectAnalyzer(
$config,
$providers,
@ -215,7 +202,7 @@ $project_analyzer = new ProjectAnalyzer(
false,
ProjectAnalyzer::TYPE_CONSOLE,
$threads,
$progress
array_key_exists('debug', $options)
);
if (array_key_exists('debug-by-line', $options)) {

View File

@ -5,11 +5,9 @@ use Psalm\Codebase;
use Psalm\Config;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Plugin\Hook\AfterCodebasePopulatedInterface;
use Psalm\PluginRegistrationSocket;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\Progress\VoidProgress;
use Psalm\Tests\TestConfig;
class PluginTest extends \Psalm\Tests\TestCase
@ -57,12 +55,7 @@ class PluginTest extends \Psalm\Tests\TestCase
new \Psalm\Internal\Provider\Providers(
$this->file_provider,
new Provider\FakeParserCacheProvider()
),
true,
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
new VoidProgress()
)
);
}

View File

@ -5,7 +5,6 @@ use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\Provider\Providers;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\Progress\VoidProgress;
use Psalm\Tests\TestConfig;
class AnalyzedMethodTest extends \Psalm\Tests\TestCase
@ -38,7 +37,7 @@ class AnalyzedMethodTest extends \Psalm\Tests\TestCase
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
new VoidProgress()
false
);
$this->project_analyzer->setPhpVersion('7.3');
}

View File

@ -37,7 +37,7 @@ class CachedStorageTest extends \Psalm\Tests\TestCase
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
null
false
);
$this->project_analyzer->setPhpVersion('7.3');
}

View File

@ -37,7 +37,7 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
null
false
);
$this->project_analyzer->setPhpVersion('7.3');
}

View File

@ -38,7 +38,7 @@ class ErrorFixTest extends \Psalm\Tests\TestCase
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
null
false
);
$this->project_analyzer->setPhpVersion('7.3');
}

View File

@ -38,7 +38,7 @@ class TemporaryUpdateTest extends \Psalm\Tests\TestCase
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
null
false
);
$this->project_analyzer->setPhpVersion('7.3');
}

View File

@ -39,7 +39,7 @@ class CompletionTest extends \Psalm\Tests\TestCase
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
null
false
);
$this->project_analyzer->setPhpVersion('7.3');
$this->project_analyzer->getCodebase()->store_node_types = true;

View File

@ -39,7 +39,7 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
null
false
);
$this->project_analyzer->setPhpVersion('7.3');

View File

@ -1,17 +0,0 @@
<?php
namespace Psalm\Tests\Progress;
use Psalm\Progress\Progress;
class EchoProgress extends Progress
{
public function startScanningFiles(): void
{
echo 'Scanning files...' . "\n";
}
public function startAnalyzingFiles(): void
{
echo 'Analyzing files...' . "\n";
}
}

View File

@ -1,8 +0,0 @@
<?php
namespace Psalm\Tests\Progress;
use Psalm\Progress\Progress;
class VoidProgress extends Progress
{
}

View File

@ -4,11 +4,8 @@ namespace Psalm\Tests;
use Psalm\Codebase;
use Psalm\Config;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Plugin\Hook\AfterCodebasePopulatedInterface;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\Progress\EchoProgress;
use Psalm\Tests\Progress\VoidProgress;
class ProjectCheckerTest extends TestCase
{
@ -58,12 +55,7 @@ class ProjectCheckerTest extends TestCase
new Provider\FileStorageInstanceCacheProvider(),
new Provider\ClassLikeStorageInstanceCacheProvider(),
new Provider\FakeFileReferenceCacheProvider()
),
true,
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
new VoidProgress()
)
);
}
@ -84,8 +76,6 @@ class ProjectCheckerTest extends TestCase
)
);
$this->project_analyzer->progress = new EchoProgress();
ob_start();
$this->project_analyzer->check('tests/fixtures/DummyProject');
$output = ob_get_clean();
@ -270,8 +260,6 @@ class Bat
)
);
$this->project_analyzer->progress = new EchoProgress();
ob_start();
$this->project_analyzer->checkDir('tests/fixtures/DummyProject');
$output = ob_get_clean();
@ -305,8 +293,6 @@ class Bat
)
);
$this->project_analyzer->progress = new EchoProgress();
ob_start();
$this->project_analyzer->checkPaths(['tests/fixtures/DummyProject/Bar.php']);
$output = ob_get_clean();
@ -340,8 +326,6 @@ class Bat
)
);
$this->project_analyzer->progress = new EchoProgress();
ob_start();
$this->project_analyzer->checkFile('tests/fixtures/DummyProject/Bar.php');
$output = ob_get_clean();

View File

@ -53,7 +53,7 @@ class ReportOutputTest extends TestCase
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
null,
false,
'/tmp/report' . $extension
);
}
@ -79,7 +79,7 @@ class ReportOutputTest extends TestCase
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
null,
false,
'/tmp/report.log'
);
}

View File

@ -52,7 +52,7 @@ class StubTest extends TestCase
);
$project_analyzer->setPhpVersion('7.3');
$config->visitComposerAutoloadFiles($project_analyzer, null);
$config->visitComposerAutoloadFiles($project_analyzer, false);
return $project_analyzer;
}

View File

@ -63,7 +63,7 @@ class TestCase extends BaseTestCase
true,
ProjectAnalyzer::TYPE_CONSOLE,
1,
null
false
);
$this->project_analyzer->setPhpVersion('7.3');

View File

@ -26,7 +26,7 @@ class TypeParseTest extends TestCase
true,
\Psalm\Internal\Analyzer\ProjectAnalyzer::TYPE_CONSOLE,
1,
null
false
);
}