Skip to content

Commit

Permalink
Merge pull request #9845 from lptn/shepherd-use-list-of-issues
Browse files Browse the repository at this point in the history
Shepherd: send a list of issues (instead of array with int keys)
  • Loading branch information
orklah committed Jun 1, 2023
2 parents 75baaf7 + 7b7d823 commit e55530d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Psalm/Plugin/EventHandler/Event/AfterAnalysisEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class AfterAnalysisEvent
{
private Codebase $codebase;
/**
* @var IssueData[][]
* @var array<string, list<IssueData>> where string key is a filepath
*/
private array $issues;
private array $build_info;
Expand All @@ -19,7 +19,7 @@ final class AfterAnalysisEvent
/**
* Called after analysis is complete
*
* @param array<string, list<IssueData>> $issues
* @param array<string, list<IssueData>> $issues where string key is a filepath
* @internal
*/
public function __construct(
Expand All @@ -40,7 +40,7 @@ public function getCodebase(): Codebase
}

/**
* @return IssueData[][]
* @return array<string, list<IssueData>> where string key is a filepath
*/
public function getIssues(): array
{
Expand Down
8 changes: 4 additions & 4 deletions src/Psalm/Plugin/Shepherd.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ private static function collectPayloadToSend(AfterAnalysisEvent $event): ?array
return null;
}

$issues = $event->getIssues();
$normalized_data = $issues === [] ? [] : array_filter(
array_merge(...array_values($issues)),
$issues_grouped_by_filename = $event->getIssues();
$normalized_data = $issues_grouped_by_filename === [] ? [] : array_values(array_filter(
array_merge(...array_values($issues_grouped_by_filename)), // flatten an array
static fn(IssueData $i): bool => $i->severity === IssueData::SEVERITY_ERROR,
);
));

$codebase = $event->getCodebase();

Expand Down

0 comments on commit e55530d

Please sign in to comment.