Skip to content

Fix PHP 8.5 curl_close() deprecation and TypeError on failed curl_init() - #145

Open
Buzka91 wants to merge 1 commit into
smsapi:masterfrom
Buzka91:fix/php85-curl-close-deprecation
Open

Buzka91 wants to merge 1 commit into
smsapi:masterfrom
Buzka91:fix/php85-curl-close-deprecation

Conversation

@Buzka91

@Buzka91 Buzka91 commented Oct 1, 2026

Copy link
Copy Markdown
  • call curl_close() only on PHP < 8.0 (no-op since 8.0, deprecated since 8.5)
  • do not pass false to curl_error() when curl_init() fails, which threw TypeError instead of NetworkException on PHP 8

- call curl_close() only on PHP < 8.0 (no-op since 8.0, deprecated since 8.5)
- do not pass false to curl_error() when curl_init() fails, which threw TypeError instead of NetworkException on PHP 8
@Buzka91

Buzka91 commented Oct 1, 2026

Copy link
Copy Markdown
Author

Hi @maciejlew,

Could you take a look at this PR when you have a moment? It's a small, backward-compatible fix:

  • curl_close() has been a no-op since PHP 8.0 and emits E_DEPRECATED on PHP 8.5, so it's now called only when PHP_VERSION_ID < 80000. PHP 7 behaviour is unchanged.
  • When curl_init() fails, curl_error() was called with false, which throws a TypeError on PHP 8 instead of the intended NetworkException.

Since the library already declares PHP 8.5 support, every request made through the bundled cURL client currently triggers a deprecation notice on 8.5. We're running PHP 8.5 in production and use this as a workaround on our side for now. A patch release (e.g. 4.0.1) with this fix would let us drop the workaround.

Thanks for maintaining the library!

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.

1 participant