mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Merge pull request #1319 from pestphp/allow-custom-arch-expectations
Allow custom arch expectations
This commit is contained in:
@ -330,7 +330,7 @@ final class Expectation
|
|||||||
* @param array<int, mixed> $parameters
|
* @param array<int, mixed> $parameters
|
||||||
* @return Expectation<TValue>|HigherOrderExpectation<Expectation<TValue>, TValue>
|
* @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 (! self::hasMethod($method)) {
|
||||||
if (! is_object($this->value) && method_exists(PendingArchExpectation::class, $method)) {
|
if (! is_object($this->value) && method_exists(PendingArchExpectation::class, $method)) {
|
||||||
@ -355,6 +355,10 @@ final class Expectation
|
|||||||
$reflectionClosure = new \ReflectionFunction($closure);
|
$reflectionClosure = new \ReflectionFunction($closure);
|
||||||
$expectation = $reflectionClosure->getClosureThis();
|
$expectation = $reflectionClosure->getClosureThis();
|
||||||
|
|
||||||
|
if ($reflectionClosure->getReturnType()?->__toString() === ArchExpectation::class) {
|
||||||
|
return $closure(...$parameters);
|
||||||
|
}
|
||||||
|
|
||||||
assert(is_object($expectation));
|
assert(is_object($expectation));
|
||||||
|
|
||||||
ExpectationPipeline::for($closure)
|
ExpectationPipeline::for($closure)
|
||||||
|
|||||||
Reference in New Issue
Block a user