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

Fixes: PHP 8.0: Argument #3 ($offset) must be contained in argument #1 ($haystack)

This commit is contained in:
Your Name 2021-08-02 16:49:09 -07:00
parent 0196afc758
commit 9f3f366cf3

View File

@ -1817,7 +1817,14 @@ class Codebase
{ {
$file_contents = substr($file_contents, 0, $offset); $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( return new Position(
substr_count($file_contents, "\n"), substr_count($file_contents, "\n"),