fix: guard curl_close() calls for PHP 8.0+ compatibility#7
Open
etrepat wants to merge 3 commits intosequra:masterfrom
Open
fix: guard curl_close() calls for PHP 8.0+ compatibility#7etrepat wants to merge 3 commits intosequra:masterfrom
etrepat wants to merge 3 commits intosequra:masterfrom
Conversation
Since PHP 8.0, CurlHandle is an object that is automatically closed when it goes out of scope or is garbage collected, making explicit curl_close() calls unnecessary. Starting with PHP 8.5, calling curl_close() triggers a deprecation notice. This commit wraps all curl_close() calls in a PHP_VERSION_ID check so they are only executed on PHP < 8.0, avoiding deprecation warnings on modern PHP versions while maintaining backward compatibility with PHP 7.x.
There was a problem hiding this comment.
Pull request overview
This PR updates the PHP client’s cURL cleanup behavior to avoid curl_close() deprecation notices on newer PHP versions, while keeping compatibility with PHP 7.x.
Changes:
- Wrapped all
curl_close($this->ch)calls withif (PHP_VERSION_ID < 80000)guards. - Normalized a few docblock whitespace lines.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds a test that installs an E_DEPRECATED-to-failure error handler and calls `getAvailableDisbursements()` to guard against regressions on PHP 8.5+ where `curl_close()` should emit a deprecation notice.
Replace repeated `curl_close()` guards with a single private `closeCurlHandle()` method. The helper calls `curl_close()` on PHP < 8.0 and always nulls `$this->ch` so the `CurlHandle` may be released on PHP 8+.
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.
What is the goal?
Since PHP 8.0,
CurlHandleis an object that is automatically closed when it goes out of scope or is garbage collected, making explicitcurl_close()calls unnecessary. Starting with PHP 8.5, callingcurl_close()triggers a deprecation notice.This commit wraps all
curl_close()calls in aPHP_VERSION_IDcheck so they are only executed on PHP < 8.0, avoiding deprecation warnings on modern PHP versions while maintaining backward compatibility with PHP 7.x.References
How is it being implemented?
All calls to
curl_close()are now wrapped in aPHP_VERSION_IDcheck so they are only executed on PHP < 8.0, avoiding deprecation warnings on modern PHP versions while maintaining backward compatibility with PHP 7.x.How is it tested?
Test suite runs unmodified.