Closed j03k64 closed 2 years ago
@brianlmoon thoughts on how to update the unit test? Do a PHP version check like below:
// Net_Gearman_ConnectionTest.php:19
if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
// PHP 8+ returns a Socket class instead of a resource now
$this->assertInstanceOf('Socket', $connection->socket);
}
else {
$this->assertEquals('socket', strtolower(get_resource_type($connection->socket)));
}
or would you prefer something else?
@j03k64 Makes sense to me to do it that way.
@brianlmoon I don't have an easy way to test this on a PHP 7.X install. I could figure it out, but if you have something readily available that would be appreciated.
@brianlmoon any other comments? (I have this branch in production running on 7.4 fwiw)
PHP 8 Support
This PR adds support for getting this library working on PHP 8. I'm going to leave this open for a bit while I determine if there are other places that need to be addressed as well.
Issue 1
get_resource_type
fails with$this->socket
passed in on PHP8 since it's expecting aresource
instead of aSocket
object.Fix 1
Update
Net/Gearman/Connection.php
to return early if$this->socket
is an instance ofSocket
(which should be only on PHP8+), otherwise falls back to default logic.Issue 2
Unable to run functional tests.
Fix 2
ConnectionTest
andTaskTest
to use more modern code including short array syntax and theassertArray
method introduced in phpunit 7.5. This required a bump of the minimum phpunit to 7.5 from 7.3.ConnectionTest
to check forPHP_VERSION >= 8.0
and if so check for theSocket
object instead ofsocket
string.tests/README.md
for how to run the unit tests.