Skip to content

Commit

Permalink
Allow custom arch expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
olivernybroe committed Nov 20, 2024
1 parent 91afc81 commit 5331b44
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public function when(callable|bool $condition, callable $callback): self
* @param array<int, mixed> $parameters
* @return Expectation<TValue>|HigherOrderExpectation<Expectation<TValue>, TValue>
*/
public function __call(string $method, array $parameters): Expectation|HigherOrderExpectation|PendingArchExpectation
public function __call(string $method, array $parameters): Expectation|HigherOrderExpectation|PendingArchExpectation|ArchExpectation
{
if (! self::hasMethod($method)) {
if (! is_object($this->value) && method_exists(PendingArchExpectation::class, $method)) {
Expand All @@ -355,6 +355,10 @@ public function __call(string $method, array $parameters): Expectation|HigherOrd
$reflectionClosure = new \ReflectionFunction($closure);
$expectation = $reflectionClosure->getClosureThis();

if ($reflectionClosure->getReturnType()?->__toString() === ArchExpectation::class) {
return $closure(...$parameters);
}

assert(is_object($expectation));

ExpectationPipeline::for($closure)
Expand Down

0 comments on commit 5331b44

Please sign in to comment.