Skip to content

Commit 8855689

Browse files
authored
add support for arguments of type closure (fixes #109, via #110)
1 parent 6202e5b commit 8855689

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Internal/ArgumentAsString.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,24 @@ private function prepareResource($argument): string
6262
private function prepareArray(array $argument): array
6363
{
6464
return array_map(
65-
fn (mixed $element): mixed => $this->prepareArgument($element),
65+
fn(mixed $element): mixed => $this->prepareArgument($element),
6666
$argument,
6767
);
6868
}
6969

70+
private function isClosure(object $argument): bool
71+
{
72+
return $argument instanceof \Closure;
73+
}
74+
7075
private function prepareObject(object $argument): string
7176
{
72-
if (isset($argument->__mocked) && is_object($argument->__mocked)) {
77+
if (!$this->isClosure($argument) && isset($argument->__mocked) && is_object($argument->__mocked)) {
7378
$argument = $argument->__mocked;
7479
}
7580
if ($argument instanceof Stringable) {
7681
return (string) $argument;
7782
}
78-
7983
$webdriverByClass = '\Facebook\WebDriver\WebDriverBy';
8084
if (class_exists($webdriverByClass) && is_a($argument, $webdriverByClass)) {
8185
return $this->webDriverByAsString($argument);

0 commit comments

Comments
 (0)