$sanitized_line) { $line_number = $line_num + 1; // Skip if the line is empty in sanitized version if (trim($sanitized_line) === '') { continue; } // Check for public static function if (preg_match('/\bpublic\s+static\s+function\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/', $sanitized_line, $matches)) { $function_name = $matches[1]; // Check if function name starts with double underscore if (str_starts_with($function_name, '__')) { // PHP magic methods are exempt - they must have double underscores $php_magic_methods = [ '__construct', '__destruct', '__call', '__callStatic', '__get', '__set', '__isset', '__unset', '__sleep', '__wakeup', '__serialize', '__unserialize', '__toString', '__invoke', '__set_state', '__clone', '__debugInfo' ]; if (in_array($function_name, $php_magic_methods)) { continue; // Magic methods are exempt } $original_line = $original_lines[$line_num] ?? $sanitized_line; $this->add_violation( $file_path, $line_number, "Public static method '{$function_name}' in RSpade framework must not start with double underscore.", trim($original_line), "Remove one underscore from the method name (change '{$function_name}' to '" . substr($function_name, 1) . "'). " . "Public static methods in the app/RSpade directory are part of the public API and should start with " . "no underscore or a single underscore only. Double underscores are reserved for private/protected methods.", 'high' ); } } } } }