1010
1111namespace Behat \MinkExtension \ServiceContainer \Driver ;
1212
13+ use GuzzleHttp \ClientInterface ;
1314use Symfony \Component \Config \Definition \Builder \ArrayNodeDefinition ;
1415use 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