-
Notifications
You must be signed in to change notification settings - Fork 28
PHP 8: Add support for CurlHandle resource objects #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In PHP 8.0, [Curl resources are changed to CurlHandle class objects](https://php.watch/versions/8.0/resource-CurlHandle#is-resource). This changes DocBlock parameters and other areas where provided handles are checked with `is_resource()`, which now needs to account for the replaced `CurlHandle` class objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot for looking into this!
can you please adjust composer.json to allow ^7.1 || ^8.0
? and add php 7.4 and 8.0 to the list of php versions in .travis.yml so that we see if it completely works?
@@ -80,7 +80,7 @@ public function __construct( | |||
$handle, | |||
ResponseBuilder $responseBuilder | |||
) { | |||
if (!is_resource($handle)) { | |||
if (!is_resource($handle) && !(is_object($handle) && $handle instanceof \GdImage)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am confused by the second part, i assume you meant CurlHandle rather than GdImage?
but i think we should make an explicit check for the php version. something like
if (
PHP_MAJOR_VERSION === 7 && !is_resource($handle)
|| PHP_MAJOR_VERSION > 7 && !$handle instanceof CurlHandle
) {
...
* @param resource $handle cURL handle. | ||
* @param ResponseBuilder $responseBuilder Response builder. | ||
* @param RequestInterface $request HTTP request. | ||
* @param resource|CurlHandle $handle cURL handle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param resource|CurlHandle $handle cURL handle. | |
* @param resource|\CurlHandle $handle cURL handle. |
or add CurlHandle to the use
classes
@@ -89,7 +89,7 @@ public function __construct( | |||
); | |||
} | |||
|
|||
if (get_resource_type($handle) !== 'curl') { | |||
if (is_resource($handle) && get_resource_type($handle) !== 'curl') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check for php version.
maybe we should split all checks into something like this?
if (PHP_MAJOR_VERSION === 7) {
both checks
} else {
class check
}
What's in this PR?
In PHP 8.0, Curl resources are changed to CurlHandle class objects. This changes DocBlock parameters and other areas where provided handles are checked with
is_resource()
, which now needs to account for the replacedCurlHandle
class objects.Why?
Because in PHP 8.0, Curl handles are no longer resources, and this libraries
is_resource
no longer return true for valid Curl handlers.Example Usage
Checklist