| @@ -64,11 +64,14 @@ | ||
| 64 | 64 | * |
| 65 | 65 | * @return int The line number at the specified offset. |
| 66 | 66 | */ |
| 67 | 67 | public static function get_line_from_offset( $content, $offset ): int { |
| 68 | + if ( '' === (string) $content ) { | |
| 69 | + return 1; | |
| 70 | + } | |
| 68 | 71 | // Polyfill for PHP version < 8.0. |
| 69 | 72 | $offset = max( $offset, 1 ); |
| 70 | - [ $before ] = str_split( $content, $offset ); | |
| 73 | + [ $before ] = str_split( (string) $content, $offset ); | |
| 71 | 74 | |
| 72 | 75 | return strlen( $before ) - strlen( str_replace( PHP_EOL, '', $before ) ) + 1; |
| 73 | 76 | } |
| 74 | 77 | |