From 874eb7d2ceb2c2491dcbbdf59796151ec003a88c Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Mon, 28 Nov 2022 18:01:35 -0400 Subject: [PATCH] Fix crashes when XML report is used on PHP 8.1 Fixes vimeo/psalm#8321 --- src/Psalm/Report/XmlReport.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Psalm/Report/XmlReport.php b/src/Psalm/Report/XmlReport.php index 1d657c70cbb..99eef77e0e3 100644 --- a/src/Psalm/Report/XmlReport.php +++ b/src/Psalm/Report/XmlReport.php @@ -29,6 +29,9 @@ static function (IssueData $issue_data): array { ); } + // replace null values, as XML serializers tend to have problems with them + $issue_data['taint_trace'] ??= ''; + if (null !== $issue_data['other_references']) { $issue_data['other_references'] = array_map( static fn(DataFlowNodeData $reference): array => (array) $reference, @@ -36,6 +39,9 @@ static function (IssueData $issue_data): array { ); } + // replace null values, as XML serializers tend to have problems with them + $issue_data['other_references'] ??= ''; + return $issue_data; }, $this->issues_data