From 2eae7d2dddc662230ab04373e745e6ced92111fb Mon Sep 17 00:00:00 2001 From: alnivv-vi <90705227+alnivv-vi@users.noreply.github.com> Date: Mon, 23 Jan 2023 09:28:28 +0300 Subject: [PATCH 1/5] closure fix --- src/Internal/ArgumentAsString.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Internal/ArgumentAsString.php b/src/Internal/ArgumentAsString.php index 26455fe..bbbf274 100644 --- a/src/Internal/ArgumentAsString.php +++ b/src/Internal/ArgumentAsString.php @@ -66,6 +66,21 @@ private function prepareArray(array $argument): array $argument, ); } + + + private function isClosure(object $argument) + { + return $argument instanceof \Closure; + } + + private function prepareObject(object $argument): string + { + if (!$this->isClosure($argument) && isset($argument->__mocked) && is_object($argument->__mocked)) { + $argument = $argument->__mocked; + } + if ($argument instanceof Stringable) { + return (string)$argument; + } private function prepareObject(object $argument): string { From cf76bc19ecd28e862f7df87ab2dc489febd2e076 Mon Sep 17 00:00:00 2001 From: alnivv-vi <90705227+alnivv-vi@users.noreply.github.com> Date: Mon, 23 Jan 2023 10:58:33 +0300 Subject: [PATCH 2/5] Update ArgumentAsString.php --- src/Internal/ArgumentAsString.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Internal/ArgumentAsString.php b/src/Internal/ArgumentAsString.php index bbbf274..f832ea4 100644 --- a/src/Internal/ArgumentAsString.php +++ b/src/Internal/ArgumentAsString.php @@ -81,23 +81,13 @@ private function prepareObject(object $argument): string if ($argument instanceof Stringable) { return (string)$argument; } - - private function prepareObject(object $argument): string - { - if (isset($argument->__mocked) && is_object($argument->__mocked)) { - $argument = $argument->__mocked; - } - if ($argument instanceof Stringable) { - return (string) $argument; - } - + $webdriverByClass = '\Facebook\WebDriver\WebDriverBy'; if (class_exists($webdriverByClass) && is_a($argument, $webdriverByClass)) { return $this->webDriverByAsString($argument); } return trim($argument::class, "\\"); - } public function __toString(): string { From 2a3d947db6c6d42e80a7b558e8aa89794db2cd7b Mon Sep 17 00:00:00 2001 From: alnivv-vi <90705227+alnivv-vi@users.noreply.github.com> Date: Mon, 23 Jan 2023 11:00:02 +0300 Subject: [PATCH 3/5] Update ArgumentAsString.php --- src/Internal/ArgumentAsString.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Internal/ArgumentAsString.php b/src/Internal/ArgumentAsString.php index f832ea4..78f4b4e 100644 --- a/src/Internal/ArgumentAsString.php +++ b/src/Internal/ArgumentAsString.php @@ -88,6 +88,7 @@ private function prepareObject(object $argument): string } return trim($argument::class, "\\"); + } public function __toString(): string { From e61e0eb6325898f42ef27a2f2d08203c01617a96 Mon Sep 17 00:00:00 2001 From: VdovinAV Date: Thu, 26 Jan 2023 13:24:31 +0300 Subject: [PATCH 4/5] linters fix --- src/Internal/ArgumentAsString.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Internal/ArgumentAsString.php b/src/Internal/ArgumentAsString.php index 78f4b4e..3cc09b2 100644 --- a/src/Internal/ArgumentAsString.php +++ b/src/Internal/ArgumentAsString.php @@ -31,7 +31,7 @@ public function __construct( public static function get(mixed $argument): string { - return (string) new self($argument); + return (string)new self($argument); } private function prepareArgument(mixed $argument): mixed @@ -56,19 +56,18 @@ private function prepareString(string $argument): string */ private function prepareResource($argument): string { - return (string) $argument; + return (string)$argument; } private function prepareArray(array $argument): array { return array_map( - fn (mixed $element): mixed => $this->prepareArgument($element), + fn(mixed $element): mixed => $this->prepareArgument($element), $argument, ); } - - - private function isClosure(object $argument) + + private function isClosure(object $argument): bool { return $argument instanceof \Closure; } @@ -81,7 +80,6 @@ private function prepareObject(object $argument): string if ($argument instanceof Stringable) { return (string)$argument; } - $webdriverByClass = '\Facebook\WebDriver\WebDriverBy'; if (class_exists($webdriverByClass) && is_a($argument, $webdriverByClass)) { return $this->webDriverByAsString($argument); @@ -101,11 +99,11 @@ public function __toString(): string private function webDriverByAsString(object $selector): string { $type = method_exists($selector, 'getMechanism') - ? (string) $selector->getMechanism() + ? (string)$selector->getMechanism() : null; $locator = method_exists($selector, 'getValue') - ? (string) $selector->getValue() + ? (string)$selector->getValue() : null; if (!isset($type, $locator)) { From 94d29587a47ec922fc579c460a2630f3b5ef99f3 Mon Sep 17 00:00:00 2001 From: VdovinAV Date: Thu, 23 Mar 2023 09:33:28 +0300 Subject: [PATCH 5/5] cr fix --- src/Internal/ArgumentAsString.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Internal/ArgumentAsString.php b/src/Internal/ArgumentAsString.php index 3cc09b2..6e2fee1 100644 --- a/src/Internal/ArgumentAsString.php +++ b/src/Internal/ArgumentAsString.php @@ -31,7 +31,7 @@ public function __construct( public static function get(mixed $argument): string { - return (string)new self($argument); + return (string) new self($argument); } private function prepareArgument(mixed $argument): mixed @@ -56,7 +56,7 @@ private function prepareString(string $argument): string */ private function prepareResource($argument): string { - return (string)$argument; + return (string) $argument; } private function prepareArray(array $argument): array @@ -78,7 +78,7 @@ private function prepareObject(object $argument): string $argument = $argument->__mocked; } if ($argument instanceof Stringable) { - return (string)$argument; + return (string) $argument; } $webdriverByClass = '\Facebook\WebDriver\WebDriverBy'; if (class_exists($webdriverByClass) && is_a($argument, $webdriverByClass)) { @@ -99,11 +99,11 @@ public function __toString(): string private function webDriverByAsString(object $selector): string { $type = method_exists($selector, 'getMechanism') - ? (string)$selector->getMechanism() + ? (string) $selector->getMechanism() : null; $locator = method_exists($selector, 'getValue') - ? (string)$selector->getValue() + ? (string) $selector->getValue() : null; if (!isset($type, $locator)) {