$line) { $line_number = $line_num + 1; // Skip comments $trimmed_line = trim($line); if (str_starts_with($trimmed_line, '//') || str_starts_with($trimmed_line, '*')) { continue; } // Check for 'var' keyword at the beginning of a line or after ( or ; // This catches var declarations in for loops and inline declarations if (preg_match('/(?:^\s*|[\(;]\s*)var\s+/', $line)) { $this->add_violation( $file_path, $line_number, "Use of 'var' keyword is not allowed. Use 'let' or 'const' instead for better scoping and immutability.", trim($line), "Replace 'var' with 'let' for mutable variables or 'const' for immutable values.", 'medium' ); } } } }