$sanitized_line) { $line_number = $line_num + 1; // Skip if the line is empty in sanitized version (was a comment) if (trim($sanitized_line) === '') { continue; } // Check for function_exists( usage if (preg_match('/\bfunction_exists\s*\(/i', $sanitized_line)) { $original_line = $original_lines[$line_num] ?? $sanitized_line; $this->add_violation( $file_path, $line_number, "function_exists() is not allowed. The runtime environment is strict and predictable - all expected functions will exist.", trim($original_line), "Remove function_exists() checks. Never conditionally define functions or handle situations differently based on what functions are defined. If a function doesn't exist, let PHP throw an error. For example, never check for ImageMagick and fall back to GD - assume ImageMagick exists and let it fail if the environment is misconfigured.", 'high' ); } } } }