Skip to content

Commit 5331b44

Browse files
committed
Allow custom arch expectations
1 parent 91afc81 commit 5331b44

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Expectation.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public function when(callable|bool $condition, callable $callback): self
330330
* @param array<int, mixed> $parameters
331331
* @return Expectation<TValue>|HigherOrderExpectation<Expectation<TValue>, TValue>
332332
*/
333-
public function __call(string $method, array $parameters): Expectation|HigherOrderExpectation|PendingArchExpectation
333+
public function __call(string $method, array $parameters): Expectation|HigherOrderExpectation|PendingArchExpectation|ArchExpectation
334334
{
335335
if (! self::hasMethod($method)) {
336336
if (! is_object($this->value) && method_exists(PendingArchExpectation::class, $method)) {
@@ -355,6 +355,10 @@ public function __call(string $method, array $parameters): Expectation|HigherOrd
355355
$reflectionClosure = new \ReflectionFunction($closure);
356356
$expectation = $reflectionClosure->getClosureThis();
357357

358+
if ($reflectionClosure->getReturnType()?->__toString() === ArchExpectation::class) {
359+
return $closure(...$parameters);
360+
}
361+
358362
assert(is_object($expectation));
359363

360364
ExpectationPipeline::for($closure)

0 commit comments

Comments
 (0)