From 140cf01a9180c8d22db32c5ac8057914e69ac14a Mon Sep 17 00:00:00 2001 From: Barney Laurance Date: Sun, 27 Jun 2021 10:33:09 +0100 Subject: [PATCH] Trim issue snippet at time of comparison with baseline, not in IssueData constructor --- src/Psalm/Internal/Analyzer/IssueData.php | 4 +--- src/Psalm/IssueBuffer.php | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/IssueData.php b/src/Psalm/Internal/Analyzer/IssueData.php index 4dddfbb74..363e8578e 100644 --- a/src/Psalm/Internal/Analyzer/IssueData.php +++ b/src/Psalm/Internal/Analyzer/IssueData.php @@ -2,8 +2,6 @@ namespace Psalm\Internal\Analyzer; -use function trim; - class IssueData { /** @@ -156,7 +154,7 @@ class IssueData $this->file_name = $file_name; $this->file_path = $file_path; $this->snippet = $snippet; - $this->selected_text = trim($selected_text); + $this->selected_text = $selected_text; $this->from = $from; $this->to = $to; $this->snippet_from = $snippet_from; diff --git a/src/Psalm/IssueBuffer.php b/src/Psalm/IssueBuffer.php index bc5492b27..f9954a9cf 100644 --- a/src/Psalm/IssueBuffer.php +++ b/src/Psalm/IssueBuffer.php @@ -48,6 +48,7 @@ use function sha1; use function sprintf; use function str_repeat; use function str_replace; +use function trim; use function usort; use const DEBUG_BACKTRACE_IGNORE_ARGS; @@ -518,7 +519,7 @@ class IssueBuffer if (isset($issue_baseline[$file][$type]) && $issue_baseline[$file][$type]['o'] > 0) { if ($issue_baseline[$file][$type]['o'] === count($issue_baseline[$file][$type]['s'])) { $position = array_search( - $issue_data->selected_text, + trim($issue_data->selected_text), $issue_baseline[$file][$type]['s'], true );