Skip to content

Commit

Permalink
Only create after analysis event if they exist
Browse files Browse the repository at this point in the history
Fixes vimeo#5008 - this does some git execing, so we don’t want it to always run
  • Loading branch information
muglug authored and danog committed Jan 29, 2021
1 parent 8954c12 commit 2fbfc42
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/Psalm/IssueBuffer.php
Expand Up @@ -544,21 +544,25 @@ function (IssueData $d1, IssueData $d2) : int {
$source_control_info = null;
$build_info = (new \Psalm\Internal\ExecutionEnvironment\BuildInfoCollector($_SERVER))->collect();

try {
$source_control_info = (new \Psalm\Internal\ExecutionEnvironment\GitInfoCollector())->collect();
} catch (\RuntimeException $e) {
// do nothing
}
if ($codebase->config->eventDispatcher->after_analysis
|| $codebase->config->eventDispatcher->legacy_after_analysis
) {
try {
$source_control_info = (new \Psalm\Internal\ExecutionEnvironment\GitInfoCollector())->collect();
} catch (\RuntimeException $e) {
// do nothing
}

/** @psalm-suppress ArgumentTypeCoercion due to Psalm bug */
$event = new AfterAnalysisEvent(
$codebase,
$issues_data,
$build_info,
$source_control_info
);
/** @psalm-suppress ArgumentTypeCoercion due to Psalm bug */
$event = new AfterAnalysisEvent(
$codebase,
$issues_data,
$build_info,
$source_control_info
);

$codebase->config->eventDispatcher->dispatchAfterAnalysis($event);
$codebase->config->eventDispatcher->dispatchAfterAnalysis($event);
}

foreach ($project_analyzer->generated_report_options as $report_options) {
if (!$report_options->output_path) {
Expand Down

0 comments on commit 2fbfc42

Please sign in to comment.