diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php index c915a6369..aaa3e1023 100644 --- a/src/Psalm/Config.php +++ b/src/Psalm/Config.php @@ -306,6 +306,12 @@ class Config */ public $after_visit_classlikes = []; + /** + * Static methods to be called after codebase has been populated + * @var class-string[] + */ + public $after_codebase_populated = []; + /** @var array */ private $predefined_constants; diff --git a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php index 9150f3b18..66db07f28 100644 --- a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php @@ -392,6 +392,14 @@ class ProjectAnalyzer $this->config->visitStubFiles($this->codebase, $this->debug_output); + $plugin_classes = $this->config->after_codebase_populated; + + if ($plugin_classes) { + foreach ($plugin_classes as $plugin_fq_class_name) { + $plugin_fq_class_name::afterCodebasePopulated($this->codebase); + } + } + $this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->codebase->alter_code); if ($this->parser_cache_provider) { diff --git a/src/Psalm/Plugin/Hook/AfterCodebasePopulatedInterface.php b/src/Psalm/Plugin/Hook/AfterCodebasePopulatedInterface.php new file mode 100644 index 000000000..d66d1a603 --- /dev/null +++ b/src/Psalm/Plugin/Hook/AfterCodebasePopulatedInterface.php @@ -0,0 +1,13 @@ +