33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-05 21:07:57 +00:00

A simpler way to get line number

This commit is contained in:
Denis Ryabov 2021-01-24 20:32:07 +03:00 committed by GitHub
parent 1f15a51f16
commit 36159b616c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -400,11 +400,7 @@ class JedcheckerRulesJamss extends JEDcheckerRule
*/
private function calculate_line_number($offset, $file_content)
{
// Fetches all the text before the match
list($first_part) = str_split($file_content, $offset);
$line_nr = strlen($first_part) - strlen(str_replace("\n", "", $first_part)) + 1;
return $line_nr;
return substr_count($file_content, "\n", 0, $offset) + 1;
}
/**