From 7f4550a88901767e2ab666b4e7a39939bd6e11e1 Mon Sep 17 00:00:00 2001 From: orklah Date: Thu, 7 Jan 2021 15:02:05 +0100 Subject: [PATCH] pass args through event (#4864) --- .../Analyzer/FunctionLikeAnalyzer.php | 4 ++- .../Event/AfterFunctionLikeAnalysisEvent.php | 26 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 15ece064e..61e03b550 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -738,7 +738,9 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer $storage, $this, $codebase, - [] + [], + $type_provider, + $context ); if ($codebase->config->eventDispatcher->dispatchAfterFunctionLikeAnalysis($event) === false) { diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterFunctionLikeAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterFunctionLikeAnalysisEvent.php index 1138eb894..c224157ae 100644 --- a/src/Psalm/Plugin/EventHandler/Event/AfterFunctionLikeAnalysisEvent.php +++ b/src/Psalm/Plugin/EventHandler/Event/AfterFunctionLikeAnalysisEvent.php @@ -5,7 +5,9 @@ namespace Psalm\Plugin\EventHandler\Event; use PhpParser\Node; use Psalm\Codebase; +use Psalm\Context; use Psalm\FileManipulation; +use Psalm\NodeTypeProvider; use Psalm\StatementsSource; use Psalm\Storage\FunctionLikeStorage; @@ -31,6 +33,14 @@ class AfterFunctionLikeAnalysisEvent * @var FileManipulation[] */ private $file_replacements; + /** + * @var NodeTypeProvider + */ + private $node_type_provider; + /** + * @var Context + */ + private $context; /** * Called after a statement has been checked @@ -42,13 +52,17 @@ class AfterFunctionLikeAnalysisEvent FunctionLikeStorage $classlike_storage, StatementsSource $statements_source, Codebase $codebase, - array $file_replacements = [] + array $file_replacements, + NodeTypeProvider $node_type_provider, + Context $context ) { $this->stmt = $stmt; $this->classlike_storage = $classlike_storage; $this->statements_source = $statements_source; $this->codebase = $codebase; $this->file_replacements = $file_replacements; + $this->node_type_provider = $node_type_provider; + $this->context = $context; } public function getStmt(): Node\FunctionLike @@ -86,4 +100,14 @@ class AfterFunctionLikeAnalysisEvent { $this->file_replacements = $file_replacements; } + + public function getNodeTypeProvider(): NodeTypeProvider + { + return $this->node_type_provider; + } + + public function getContext(): Context + { + return $this->context; + } }