Skip to content
Permalink
Browse files

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)
  • Loading branch information...
TysonAndre authored and muglug committed Aug 18, 2019
1 parent 62dff20 commit ce03be2dc085b66c05ef2ef0c82badaeac0b2df4
@@ -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 @@ public function analyze(
} 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) {
@@ -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
);
}

0 comments on commit ce03be2

Please sign in to comment.
You can’t perform that action at this time.