mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Handle different line endings from baseline.
This commit is contained in:
parent
ef9a06c467
commit
350687dcb7
@ -118,7 +118,7 @@ final class ErrorBaseline
|
||||
|
||||
foreach ($codeSamples as $codeSample) {
|
||||
$files[$fileName][$issueType]['o'] += 1;
|
||||
$files[$fileName][$issueType]['s'][] = trim($codeSample->textContent);
|
||||
$files[$fileName][$issueType]['s'][] = str_replace("\r\n", "\n", trim($codeSample->textContent));
|
||||
}
|
||||
|
||||
// TODO: Remove in Psalm 6
|
||||
|
@ -782,7 +782,7 @@ class LanguageServer extends Dispatcher
|
||||
if ($issue_baseline[$file][$type]['o'] === count($issue_baseline[$file][$type]['s'])) {
|
||||
/** @psalm-suppress MixedArrayAccess, MixedAssignment */
|
||||
$position = array_search(
|
||||
trim($issue_data->selected_text),
|
||||
str_replace("\r\n", "\n", trim($issue_data->selected_text)),
|
||||
$issue_baseline[$file][$type]['s'],
|
||||
true,
|
||||
);
|
||||
|
@ -592,7 +592,7 @@ final 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(
|
||||
trim($issue_data->selected_text),
|
||||
str_replace("\r\n", "\n", trim($issue_data->selected_text)),
|
||||
$issue_baseline[$file][$type]['s'],
|
||||
true,
|
||||
);
|
||||
|
@ -79,11 +79,31 @@ class IssueBufferTest extends TestCase
|
||||
0,
|
||||
),
|
||||
],
|
||||
'/path/four.php' => [
|
||||
new IssueData(
|
||||
"error",
|
||||
0,
|
||||
0,
|
||||
"MissingPropertyType",
|
||||
'Message',
|
||||
"four.php",
|
||||
"/path/four.php",
|
||||
"snippet-4-multiline\r\nwith-carriage-return\r",
|
||||
"snippet-4-multiline\r\nwith-carriage-return\r",
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
),
|
||||
],
|
||||
]);
|
||||
$baseline = [
|
||||
'one.php' => ['MissingPropertyType' => ['o' => 1, 's' => ['snippet-1']] ],
|
||||
'two.php' => ['MissingPropertyType' => ['o' => 1, 's' => ['snippet-2']] ],
|
||||
'three.php' => ['MissingPropertyType' => ['o' => 1, 's' => ['snippet-3-has-carriage-return']] ],
|
||||
'four.php' => ['MissingPropertyType' => ['o' => 1, 's' => ["snippet-4-multiline\nwith-carriage-return"]] ],
|
||||
];
|
||||
|
||||
$analyzer = $this->createMock(Analyzer::class);
|
||||
|
Loading…
Reference in New Issue
Block a user