mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
preserve analyzers until the end of file (#4834)
* preserve analyzers until the end of file * remove unused variable
This commit is contained in:
parent
fadb3a76e7
commit
1c2650fe65
@ -18,7 +18,7 @@ class TemplateAnalyzer extends Psalm\Internal\Analyzer\FileAnalyzer
|
|||||||
{
|
{
|
||||||
const VIEW_CLASS = 'Your\\View\\Class';
|
const VIEW_CLASS = 'Your\\View\\Class';
|
||||||
|
|
||||||
public function analyze(?Context $file_context = null, bool $preserve_analyzers = false, ?Context $global_context = null): void
|
public function analyze(?Context $file_context = null, ?Context $global_context = null): void
|
||||||
{
|
{
|
||||||
$codebase = $this->project_analyzer->getCodebase();
|
$codebase = $this->project_analyzer->getCodebase();
|
||||||
$stmts = $codebase->getStatementsForFile($this->file_path);
|
$stmts = $codebase->getStatementsForFile($this->file_path);
|
||||||
|
@ -123,7 +123,6 @@ class FileAnalyzer extends SourceAnalyzer
|
|||||||
|
|
||||||
public function analyze(
|
public function analyze(
|
||||||
?Context $file_context = null,
|
?Context $file_context = null,
|
||||||
bool $preserve_analyzers = false,
|
|
||||||
?Context $global_context = null
|
?Context $global_context = null
|
||||||
): void {
|
): void {
|
||||||
$codebase = $this->project_analyzer->getCodebase();
|
$codebase = $this->project_analyzer->getCodebase();
|
||||||
@ -211,11 +210,6 @@ class FileAnalyzer extends SourceAnalyzer
|
|||||||
$class_analyzer->analyze(null, $this->context);
|
$class_analyzer->analyze(null, $this->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$preserve_analyzers) {
|
|
||||||
$this->class_analyzers_to_analyze = [];
|
|
||||||
$this->interface_analyzers_to_analyze = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($codebase->config->check_for_throws_in_global_scope) {
|
if ($codebase->config->check_for_throws_in_global_scope) {
|
||||||
$uncaught_throws = $statements_analyzer->getUncaughtThrows($this->context);
|
$uncaught_throws = $statements_analyzer->getUncaughtThrows($this->context);
|
||||||
foreach ($uncaught_throws as $possibly_thrown_exception => $codelocations) {
|
foreach ($uncaught_throws as $possibly_thrown_exception => $codelocations) {
|
||||||
@ -277,6 +271,9 @@ class FileAnalyzer extends SourceAnalyzer
|
|||||||
foreach ($codebase->config->after_file_checks as $plugin_class) {
|
foreach ($codebase->config->after_file_checks as $plugin_class) {
|
||||||
$plugin_class::afterAnalyzeFile($this, $this->context, $file_storage, $codebase);
|
$plugin_class::afterAnalyzeFile($this, $this->context, $file_storage, $codebase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->class_analyzers_to_analyze = [];
|
||||||
|
$this->interface_analyzers_to_analyze = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,7 +178,6 @@ class IncludeAnalyzer
|
|||||||
try {
|
try {
|
||||||
$include_file_analyzer->analyze(
|
$include_file_analyzer->analyze(
|
||||||
$context,
|
$context,
|
||||||
false,
|
|
||||||
$global_context
|
$global_context
|
||||||
);
|
);
|
||||||
} catch (\Psalm\Exception\UnpreparedAnalysisException $e) {
|
} catch (\Psalm\Exception\UnpreparedAnalysisException $e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user