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

Commit e9477f3

Browse files
committed
Compatibility with guzzle 7.
1 parent e206d2c commit e9477f3

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactory.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Behat\MinkExtension\ServiceContainer\Driver;
1212

13+
use GuzzleHttp\ClientInterface;
1314
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1415
use Symfony\Component\DependencyInjection\Definition;
1516

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

119-
if ($refl->getClass() && 'Guzzle\Http\ClientInterface' === $refl->getClass()->getName()) {
120+
$type = $refl->getType();
121+
if ($type instanceof \ReflectionNamedType && 'Guzzle\Http\ClientInterface' === $type->getName()) {
120122
return true;
121123
}
122124

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

126128
private function isGuzzle6()
127129
{
128-
return interface_exists('GuzzleHttp\ClientInterface') &&
129-
version_compare(\GuzzleHttp\ClientInterface::VERSION, '6.0.0', '>=');
130+
if (!interface_exists(ClientInterface::class)) {
131+
return false;
132+
}
133+
$rc = new \ReflectionClass(ClientInterface::class);
134+
// This constant was removed in Guzzle 7.
135+
if ($rc->hasConstant('VERSION')) {
136+
return version_compare(ClientInterface::VERSION, '6.0.0', '>=');
137+
}
138+
// This constant was added in Guzzle 7.
139+
if ($rc->hasConstant('MAJOR_VERSION')) {
140+
ClientInterface::MAJOR_VERSION >= 6;
141+
}
142+
return false;
130143
}
131144
}

0 commit comments

Comments
 (0)