mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix #4603 - fix arithmetic to prevent end column 0
This commit is contained in:
parent
a48f686695
commit
e1c3959f5a
@ -308,13 +308,17 @@ class CodeLocation
|
||||
$newlines = substr_count($this->text, "\n");
|
||||
|
||||
if ($newlines) {
|
||||
$this->column_to = $this->selection_end -
|
||||
(int)strrpos($file_contents, "\n", $this->selection_end - strlen($file_contents));
|
||||
$last_newline_pos = strrpos($file_contents, "\n", $this->selection_end - strlen($file_contents) - 1);
|
||||
$this->column_to = $this->selection_end - (int)$last_newline_pos;
|
||||
} else {
|
||||
$this->column_to = $this->column_from + strlen($this->text);
|
||||
}
|
||||
|
||||
$this->end_line_number = $this->getLineNumber() + $newlines;
|
||||
|
||||
if ($this->column_to === 0) {
|
||||
throw new \UnexpectedValueException('bad');
|
||||
}
|
||||
}
|
||||
|
||||
public function getLineNumber(): int
|
||||
|
Loading…
Reference in New Issue
Block a user