mirror of
https://github.com/pestphp/pest.git
synced 2026-03-13 03:07:22 +01:00
addresses reviews
This commit is contained in:
@ -7,7 +7,6 @@ namespace Pest\Concerns;
|
|||||||
use BadMethodCallException;
|
use BadMethodCallException;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Pest\Expectation;
|
use Pest\Expectation;
|
||||||
use PHPStan\Type\CallableType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -50,6 +49,9 @@ trait Extendable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register an interceptor that should replace an existing expectation.
|
* Register an interceptor that should replace an existing expectation.
|
||||||
|
*
|
||||||
|
* @param class-string|Closure(mixed $value, mixed ...$arguments): bool $filter
|
||||||
|
* @param Closure(mixed ...$arguments): void $handler
|
||||||
*/
|
*/
|
||||||
public static function intercept(string $name, string|Closure $filter, Closure $handler): void
|
public static function intercept(string $name, string|Closure $filter, Closure $handler): void
|
||||||
{
|
{
|
||||||
@ -58,19 +60,17 @@ trait Extendable
|
|||||||
}
|
}
|
||||||
|
|
||||||
self::pipe($name, function ($next, ...$arguments) use ($handler, $filter): void {
|
self::pipe($name, function ($next, ...$arguments) use ($handler, $filter): void {
|
||||||
/** @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
if ($filter($this->value, ...$arguments)) {
|
if (!$filter($this->value, ...$arguments)) {
|
||||||
/** @phpstan-ignore-next-line */
|
$next();
|
||||||
$handler = $handler->bindTo($this, get_class($this));
|
|
||||||
|
|
||||||
if($handler instanceof Closure){
|
|
||||||
$handler(...$arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$next();
|
/** @phpstan-ignore-next-line */
|
||||||
|
$handler = $handler->bindTo($this, $this::class);
|
||||||
|
|
||||||
|
$handler(...$arguments);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ final class ExpectationPipeline
|
|||||||
return new self($expectationClosure);
|
return new self($expectationClosure);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function send(...$passable): ExpectationPipeline
|
public function send(mixed ...$passable): ExpectationPipeline
|
||||||
{
|
{
|
||||||
$this->passable = $passable;
|
$this->passable = $passable;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user