From d1c5b1157e1bc8d1a7df60d1113ade5bde5464aa Mon Sep 17 00:00:00 2001 From: robertfausk Date: Fri, 23 Aug 2019 09:01:44 +0200 Subject: [PATCH 1/2] Fix calling of self::getClient when not in static context cause it will break when PantherTestCaseTrait is used in a class which implements and uses getClient with object context --- src/PantherTestCaseTrait.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PantherTestCaseTrait.php b/src/PantherTestCaseTrait.php index 6fad0c38..fd3bde74 100644 --- a/src/PantherTestCaseTrait.php +++ b/src/PantherTestCaseTrait.php @@ -159,7 +159,10 @@ protected static function createPantherClient(array $options = [], array $kernel } if (\is_callable([self::class, 'getClient'])) { - return self::getClient(self::$pantherClient); + $rm = new \ReflectionMethod(self::class, 'getClient'); + if ($rm->isStatic()) { + return self::getClient(self::$pantherClient); + } } return self::$pantherClient; From 58cd4f2f18af83ccf317e76e7791136c264e1b65 Mon Sep 17 00:00:00 2001 From: robertfausk Date: Fri, 23 Aug 2019 10:09:42 +0200 Subject: [PATCH 2/2] Merged change to a single line --- src/PantherTestCaseTrait.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/PantherTestCaseTrait.php b/src/PantherTestCaseTrait.php index fd3bde74..fa0fcfd2 100644 --- a/src/PantherTestCaseTrait.php +++ b/src/PantherTestCaseTrait.php @@ -158,11 +158,8 @@ protected static function createPantherClient(array $options = [], array $kernel static::bootKernel($kernelOptions); } - if (\is_callable([self::class, 'getClient'])) { - $rm = new \ReflectionMethod(self::class, 'getClient'); - if ($rm->isStatic()) { - return self::getClient(self::$pantherClient); - } + if (\is_callable([self::class, 'getClient']) && (new \ReflectionMethod(self::class, 'getClient'))->isStatic()) { + return self::getClient(self::$pantherClient); } return self::$pantherClient;