1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Merge pull request #6231 from tm1000/patch-get-position-from-offset-error-php80

This commit is contained in:
Bruce Weirdan 2021-08-03 04:06:02 +03:00 committed by GitHub
commit 9d68e2e39c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1817,7 +1817,14 @@ class Codebase
{
$file_contents = substr($file_contents, 0, $offset);
$before_newline_count = strrpos($file_contents, "\n", $offset - strlen($file_contents));
$offsetLength = $offset - strlen($file_contents);
//PHP 8.0: Argument #3 ($offset) must be contained in argument #1 ($haystack)
if (($textlen = strlen($file_contents)) < $offsetLength) {
$offsetLength = $textlen;
}
$before_newline_count = strrpos($file_contents, "\n", $offsetLength);
return new Position(
substr_count($file_contents, "\n"),