1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00

Merge pull request #6716 from orklah/fatal

fix Uncaught ValueError: strrpos()
This commit is contained in:
orklah 2021-10-21 21:36:53 +02:00 committed by GitHub
commit 1b9f84970d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -297,8 +297,12 @@ class CodeLocation
$this->text = mb_strcut($file_contents, $this->selection_start, $this->selection_end - $this->selection_start);
// reset preview start to beginning of line
$this->column_from = $this->selection_start -
(int)strrpos($file_contents, "\n", $this->selection_start - strlen($file_contents));
if ($file_contents !== '') {
$this->column_from = $this->selection_start -
(int)strrpos($file_contents, "\n", $this->selection_start - strlen($file_contents));
} else {
$this->column_from = $this->selection_start;
}
$newlines = substr_count($this->text, "\n");