From 9ded563e4b16170fbd02029f232a20e999f38b15 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Sun, 19 Feb 2023 11:07:44 +0100 Subject: [PATCH] store interceptors for use with Collision this is a workaround for php bug https://github.com/php/php-src/issues/10623, that prevents Collision to retrieve info about the interceptor handler closure. (see https://github.com/nunomaduro/collision/pull/255) --- src/Concerns/Pipeable.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Concerns/Pipeable.php b/src/Concerns/Pipeable.php index c23427cd..6e5a044b 100644 --- a/src/Concerns/Pipeable.php +++ b/src/Concerns/Pipeable.php @@ -19,6 +19,13 @@ trait Pipeable */ private static array $pipes = []; + /** + * The list of interceptors. + * + * @var array> + */ + private static array $interceptors = []; + /** * Register a pipe to be applied before an expectation is checked. */ @@ -38,6 +45,8 @@ trait Pipeable $filter = fn ($value): bool => $value instanceof $filter; } + self::$interceptors[$name][] = $handler; + $this->pipe($name, function ($next, ...$arguments) use ($handler, $filter): void { /* @phpstan-ignore-next-line */ if ($filter($this->value, ...$arguments)) {