<commit_before><?php

namespace EditorconfigChecker\Fix;

class TrailingWhitespaceFix
{
    /**
     * Insert a final newline at the end of the file
     *
     * @param string $filename
     * @return boolean
     */
    public static function trim($filename)
    {
        if (is_file($filename)) {
            $lines = file($filename);

            foreach ($lines as $index => $line) {
                $lines[$index] = rtrim($line);
            }

            $fp = fopen($filename, 'w');
            fwrite($fp, implode(PHP_EOL, $lines));
            fclose($fp);
<commit_msg>TASK: Use reference instead of index<commit_after><?php

namespace EditorconfigChecker\Fix;

class TrailingWhitespaceFix
{
    /**
     * Insert a final newline at the end of the file
     *
     * @param string $filename
     * @return boolean
     */
    public static function trim($filename)
    {
        if (is_file($filename)) {
            $lines = file($filename);

            foreach ($lines as &$line) {
                $line = rtrim($line);
            }

            $fp = fopen($filename, 'w');
            fwrite($fp, implode(PHP_EOL, $lines));
            fclose($fp);

{'fraction_non_alphanumeric': 0.1268209083119109, 'fraction_numerical': 0.0, 'mean_word_length': 1.934673366834171, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4935293', 'n_tokens_mistral': 341, 'n_tokens_neox': 337, 'n_words': 88}