refactor(HTTP): split setCURLOptions into category helper methods to reduce complexity#10339
Open
gr8man wants to merge 2 commits into
Open
refactor(HTTP): split setCURLOptions into category helper methods to reduce complexity#10339gr8man wants to merge 2 commits into
gr8man wants to merge 2 commits into
Conversation
0ea2fd3 to
2c5d21c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR refactors the massive
setCURLOptions()method inCodeIgniter\HTTP\CURLRequest(which was a 180+ line method with extremely high cyclomatic complexity) by splitting it into 8 domain-specific private helper methods. This change adheres to the Single Responsibility Principle (SRP) and the Open-Closed Principle (OCP), making the options-building logic significantly cleaner, easier to read, and simpler to maintain without introducing any backward compatibility (BC) breaks.Additionally, static analysis (PHPStan Level 6 with strict rules) and test validation have been integrated for all newly created helper methods.
Proposed Changes
system/HTTP/CURLRequest.php:setCURLOptions()into:applyAuthOptions()applySslOptions()applyProxyOptions()applyDebugOptions()applyRedirectOptions()applyConnectionOptions()applyPayloadOptions()applyMiscOptions()empty()checks with strict comparison operators (isset(),!== '', etc.) inside the new helper methods to comply with strict PHPStan rules.missingType.iterableValuewarnings).tests/system/HTTP/CURLRequestTest.php:testApply*Direct) usinggetPrivateMethodInvokerfor all 8 helper methods to ensure maximum test coverage.assertSametoassertEqualsWithDeltato satisfy Rector rules.utils/phpstan-baseline/empty.notAllowed.neon:empty()constructs forCURLRequestto match the new strict refactoring.Checklist
OK (100 tests, 269 assertions)).[OK] No errors).php-cs-fixer).