Skip to content

fix: guard curl_close() calls for PHP 8.0+ compatibility#7

Open
etrepat wants to merge 3 commits intosequra:masterfrom
etrepat:fix-php85-deprecations
Open

fix: guard curl_close() calls for PHP 8.0+ compatibility#7
etrepat wants to merge 3 commits intosequra:masterfrom
etrepat:fix-php85-deprecations

Conversation

@etrepat
Copy link

@etrepat etrepat commented Feb 27, 2026

What is the goal?

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.

References

How is it being implemented?

All calls to curl_close() are now wrapped 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.

How is it tested?

Test suite runs unmodified.

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.
Copilot AI review requested due to automatic review settings February 27, 2026 10:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with if (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+.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants