🧹 Centralize error JSON generation in Response class#621
🧹 Centralize error JSON generation in Response class#621
Conversation
- Added `Response::errorJson(string $errorCode)` to centralize error formatting. - Refactored `CurlPost`, `Post`, and `SocketPost` to use the new method. - Replaced hardcoded JSON strings with `json_encode` in the new method. - Added appropriate docblocks to the new method. Co-authored-by: rowan-m <108052+rowan-m@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Run |
I have updated the code to address the test failures and PHP version compatibility issues. Specifically, I removed the modern PHP type hints to maintain support for PHP 5.6 and reverted to manual string concatenation in |
|
Do not remove the type hints. The minimum supported PHP version is 8.4. |
I have restored the |
|
Make sure you address the issues raised by |
🎯 What: Duplicated hardcoded JSON error strings for
E_CONNECTION_FAILEDandE_BAD_RESPONSEwere removed from multipleRequestMethodimplementations and replaced with a centralResponse::errorJson()method.💡 Why: This reduces code duplication and ensures consistent error response formatting across all request methods. It also makes it easier to change the error response format in the future if needed.
✅ Verification: A standalone PHP verification script was used to ensure that
Response::errorJson()generates the correct JSON and that it is properly parsed byResponse::fromJson().✨ Result: Improved code maintainability and reduced duplication by centralizing error formatting logic.
PR created automatically by Jules for task 13806251128490405200 started by @rowan-m