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)
This commit is contained in:
Fabio Ivona
2023-02-19 11:07:44 +01:00
parent 15ef5f12b8
commit 9ded563e4b

View File

@ -19,6 +19,13 @@ trait Pipeable
*/
private static array $pipes = [];
/**
* The list of interceptors.
*
* @var array<string, array<Closure(Closure, mixed ...$arguments): void>>
*/
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)) {