mirror of
https://github.com/pestphp/pest.git
synced 2026-03-11 18:27:23 +01:00
improves static analysis
This commit is contained in:
@ -20,7 +20,7 @@ trait Extendable
|
|||||||
*/
|
*/
|
||||||
private static array $extends = [];
|
private static array $extends = [];
|
||||||
|
|
||||||
/** @var array<string, array<Closure(Closure $next, mixed ...$arguments): void>> */
|
/** @var array<string, array<Closure(Closure, mixed ...$arguments): void>> */
|
||||||
private static array $pipes = [];
|
private static array $pipes = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,14 +74,6 @@ trait Extendable
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if pipes are registered for a given expectation.
|
|
||||||
*/
|
|
||||||
private static function hasPipes(string $name): bool
|
|
||||||
{
|
|
||||||
return array_key_exists($name, static::$pipes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the pipes that have been registered for a given expectation and binds them to a context and a scope.
|
* Gets the pipes that have been registered for a given expectation and binds them to a context and a scope.
|
||||||
*
|
*
|
||||||
@ -89,20 +81,7 @@ trait Extendable
|
|||||||
*/
|
*/
|
||||||
private function pipes(string $name, object $context, string $scope): array
|
private function pipes(string $name, object $context, string $scope): array
|
||||||
{
|
{
|
||||||
if (!self::hasPipes($name)) {
|
return array_map(fn (Closure $pipe) => $pipe->bindTo($context, $scope), self::$pipes[$name] ?? []);
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$pipes = [];
|
|
||||||
foreach (self::$pipes[$name] as $pipe) {
|
|
||||||
$pipe = $pipe->bindTo($context, $scope);
|
|
||||||
|
|
||||||
if ($pipe instanceof Closure) {
|
|
||||||
$pipes[] = $pipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $pipes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user