From 5331b44a1801960ada896dfc89d4b92db0117e2b Mon Sep 17 00:00:00 2001 From: olivernybroe Date: Wed, 20 Nov 2024 11:54:36 +0100 Subject: [PATCH] Allow custom arch expectations --- src/Expectation.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Expectation.php b/src/Expectation.php index ebfd6302..3951bc04 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -330,7 +330,7 @@ final class Expectation * @param array $parameters * @return Expectation|HigherOrderExpectation, 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)) { @@ -355,6 +355,10 @@ final class Expectation $reflectionClosure = new \ReflectionFunction($closure); $expectation = $reflectionClosure->getClosureThis(); + if ($reflectionClosure->getReturnType()?->__toString() === ArchExpectation::class) { + return $closure(...$parameters); + } + assert(is_object($expectation)); ExpectationPipeline::for($closure)