mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Add BeforeAnalyzeFileInterface (#2034)
This is a prerequisite of the plugin I mentioned in #378 This may be useful for other types of plugins (e.g. checking raw file contents or file names)
This commit is contained in:
parent
62dff200d5
commit
ce03be2dc0
@ -422,6 +422,12 @@ class Config
|
||||
*/
|
||||
public $after_analysis = [];
|
||||
|
||||
/**
|
||||
* Static methods to be called after codebase has been populated
|
||||
* @var class-string<Hook\BeforeAnalyzeFileInterface>[]
|
||||
*/
|
||||
public $before_analyze_file = [];
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
private $predefined_constants;
|
||||
|
||||
|
@ -163,6 +163,9 @@ class FileAnalyzer extends SourceAnalyzer implements StatementsSource
|
||||
} catch (PhpParser\Error $e) {
|
||||
return;
|
||||
}
|
||||
foreach ($codebase->config->before_analyze_file as $plugin_class) {
|
||||
$plugin_class::beforeAnalyzeFile($this);
|
||||
}
|
||||
|
||||
if ($codebase->alter_code) {
|
||||
foreach ($stmts as $stmt) {
|
||||
|
14
src/Psalm/Plugin/Hook/BeforeAnalyzeFileInterface.php
Normal file
14
src/Psalm/Plugin/Hook/BeforeAnalyzeFileInterface.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Psalm\Plugin\Hook;
|
||||
|
||||
use Psalm\Internal\Analyzer\FileAnalyzer;
|
||||
|
||||
interface BeforeAnalyzeFileInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function beforeAnalyzeFile(
|
||||
FileAnalyzer $file_analyzer
|
||||
);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user