Skip to content

Commit

Permalink
add support for arguments of type closure (fixes #109, via #110)
Browse files Browse the repository at this point in the history
  • Loading branch information
alnivv-vi authored Mar 27, 2023
1 parent 6202e5b commit 8855689
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Internal/ArgumentAsString.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,24 @@ private function prepareResource($argument): string
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): bool
{
return $argument instanceof \Closure;
}

private function prepareObject(object $argument): string
{
if (isset($argument->__mocked) && is_object($argument->__mocked)) {
if (!$this->isClosure($argument) && 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);
Expand Down

0 comments on commit 8855689

Please sign in to comment.