Skip to content

Commit

Permalink
Fix #4252 - fix xml generation
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 12, 2020
1 parent 662e2ea commit 33e3758
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/Psalm/Internal/Analyzer/IssueData.php
Expand Up @@ -119,7 +119,7 @@ class IssueData
* @var ?string
* @readonly
*/
private $dupe_key;
public $dupe_key;

/**
* @param ?list<ControlFlowNodeData|array{label: string, entry_path_type: string}> $taint_trace
Expand Down Expand Up @@ -166,9 +166,4 @@ public function __construct(
$this->taint_trace = $taint_trace;
$this->dupe_key = $dupe_key;
}

public function getDupeKey() : ?string
{
return $this->dupe_key;
}
}
2 changes: 1 addition & 1 deletion src/Psalm/IssueBuffer.php
Expand Up @@ -412,7 +412,7 @@ public static function addIssues(array $issues_data): void
. '-' . $issue->file_name
. ':' . $issue->line_from
. ':' . $issue->column_from
. ' ' . $issue->getDupeKey();
. ' ' . $issue->dupe_key;

if (!self::alreadyEmitted($emitted_key)) {
self::$issues_data[$file_path][] = $issue;
Expand Down
11 changes: 10 additions & 1 deletion src/Psalm/Report/JsonReport.php
Expand Up @@ -13,6 +13,15 @@ public function create(): string
{
$options = $this->pretty ? Json::PRETTY : Json::DEFAULT;

return Json::encode(array_values($this->issues_data), $options) . "\n";
$issues_data = \array_map(
function ($issue_data): array {
$issue_data = (array) $issue_data;
unset($issue_data['dupe_key']);
return $issue_data;
},
$this->issues_data
);

return Json::encode(array_values($issues_data), $options) . "\n";
}
}
4 changes: 3 additions & 1 deletion src/Psalm/Report/XmlReport.php
Expand Up @@ -15,7 +15,9 @@ public function create(): string
[
'item' => array_map(
function (IssueData $issue_data): array {
return (array) $issue_data;
$issue_data = (array) $issue_data;
unset($issue_data['dupe_key']);
return $issue_data;
},
$this->issues_data
)
Expand Down

0 comments on commit 33e3758

Please sign in to comment.