Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
Compatibility with guzzle 7.
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed May 1, 2023
1 parent e206d2c commit e9477f3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Behat\MinkExtension\ServiceContainer\Driver;

use GuzzleHttp\ClientInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\Definition;

Expand Down Expand Up @@ -116,7 +117,8 @@ private function isGoutte1()
{
$refl = new \ReflectionParameter(array('Goutte\Client', 'setClient'), 0);

if ($refl->getClass() && 'Guzzle\Http\ClientInterface' === $refl->getClass()->getName()) {
$type = $refl->getType();
if ($type instanceof \ReflectionNamedType && 'Guzzle\Http\ClientInterface' === $type->getName()) {
return true;
}

Expand All @@ -125,7 +127,18 @@ private function isGoutte1()

private function isGuzzle6()
{
return interface_exists('GuzzleHttp\ClientInterface') &&
version_compare(\GuzzleHttp\ClientInterface::VERSION, '6.0.0', '>=');
if (!interface_exists(ClientInterface::class)) {
return false;
}
$rc = new \ReflectionClass(ClientInterface::class);
// This constant was removed in Guzzle 7.
if ($rc->hasConstant('VERSION')) {
return version_compare(ClientInterface::VERSION, '6.0.0', '>=');
}
// This constant was added in Guzzle 7.
if ($rc->hasConstant('MAJOR_VERSION')) {
ClientInterface::MAJOR_VERSION >= 6;
}
return false;
}
}

0 comments on commit e9477f3

Please sign in to comment.