From e99cf5f5143387b8814146d3cfb7ba03e9250f18 Mon Sep 17 00:00:00 2001 From: orklah Date: Thu, 7 Jan 2021 15:04:50 +0100 Subject: [PATCH] adds statements list in the event (#4835) --- src/Psalm/Internal/Analyzer/FileAnalyzer.php | 2 +- .../Event/AfterFileAnalysisEvent.php | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/FileAnalyzer.php b/src/Psalm/Internal/Analyzer/FileAnalyzer.php index a1341b43e..9337796ff 100644 --- a/src/Psalm/Internal/Analyzer/FileAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FileAnalyzer.php @@ -271,7 +271,7 @@ class FileAnalyzer extends SourceAnalyzer } } - $event = new AfterFileAnalysisEvent($this, $this->context, $file_storage, $codebase); + $event = new AfterFileAnalysisEvent($this, $this->context, $file_storage, $codebase, $stmts); $codebase->config->eventDispatcher->dispatchAfterFileAnalysis($event); $this->class_analyzers_to_analyze = []; diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterFileAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterFileAnalysisEvent.php index d67158dd6..a02d7795b 100644 --- a/src/Psalm/Plugin/EventHandler/Event/AfterFileAnalysisEvent.php +++ b/src/Psalm/Plugin/EventHandler/Event/AfterFileAnalysisEvent.php @@ -3,6 +3,7 @@ namespace Psalm\Plugin\EventHandler\Event; +use PhpParser\Node\Stmt; use Psalm\Codebase; use Psalm\Context; use Psalm\StatementsSource; @@ -26,20 +27,28 @@ class AfterFileAnalysisEvent * @var Codebase */ private $codebase; + /** + * @var Stmt[] + */ + private $stmts; /** * Called after a file has been checked + * + * @param array $stmts */ public function __construct( StatementsSource $statements_source, Context $file_context, FileStorage $file_storage, - Codebase $codebase + Codebase $codebase, + array $stmts ) { $this->statements_source = $statements_source; $this->file_context = $file_context; $this->file_storage = $file_storage; $this->codebase = $codebase; + $this->stmts = $stmts; } public function getStatementsSource(): StatementsSource @@ -61,4 +70,12 @@ class AfterFileAnalysisEvent { return $this->codebase; } + + /** + * @return Stmt[] + */ + public function getStmts(): array + { + return $this->stmts; + } }