Continuous Integration Fixes
Some checks are pending
/ ls (push) Waiting to run

This commit is contained in:
Continuous Integration 2023-11-30 20:39:40 +00:00
parent 28491fd4ea
commit 23d37db8f6
16 changed files with 23 additions and 38 deletions

View file

@ -14,12 +14,12 @@ use function assert;
require_once __DIR__ . '/../vendor/autoload.php';
$cached = false;
$container = (new ContainerBuilder)->addDefinitions(
$container = (new ContainerBuilder())->addDefinitions(
[
Finder::class => static fn (): Finder => new Finder(__DIR__, [], $cached),
Dispatcher::class => static fn (DispatcherFactory $f): Dispatcher
Finder::class => static fn(): Finder => new Finder(__DIR__, [], $cached),
Dispatcher::class => static fn(DispatcherFactory $f): Dispatcher
=> $f->getDispatcher($cached),
HandlerResolver::class => static fn (Dispatcher $d): HandlerResolver
HandlerResolver::class => static fn(Dispatcher $d): HandlerResolver
=> new HandlerResolver($d, $cached),
],
)->build();

View file

@ -11,8 +11,7 @@ final readonly class Lol
{
public function __construct(
private Dispatcher $dispatcher
) {
}
) {}
#[AsHandler(HttpMethod::GET, '/')]
public function lol(): void

View file

@ -14,6 +14,5 @@ final readonly class AsListener
public function __construct(
public string $eventClass,
public int $priority = 0
) {
}
) {}
}

View file

@ -15,8 +15,7 @@ final class Dispatcher
public function __construct(
private readonly InvokerInterface $invoker,
private array $listeners = [],
) {
}
) {}
public function addListener(Listener $listener): void
{
@ -30,7 +29,7 @@ final class Dispatcher
{
return arrayFilter(
$this->listeners,
static fn (Listener $l): bool => $l->eventClass === $event::class,
static fn(Listener $l): bool => $l->eventClass === $event::class,
);
}
@ -42,7 +41,7 @@ final class Dispatcher
$filtered = $this->getListenerForEvent($event);
usort(
$filtered,
static fn (Listener $a, Listener $b): int => $a->priority <=> $b->priority,
static fn(Listener $a, Listener $b): int => $a->priority <=> $b->priority,
);
return $filtered;
}

View file

@ -18,8 +18,7 @@ final readonly class DispatcherFactory
public function __construct(
private Finder $finder,
private InvokerInterface $invoker,
) {
}
) {}
public function getDispatcher(bool $cached = false): Dispatcher
{

View file

@ -15,6 +15,5 @@ final readonly class Listener
public int $priority,
public string $listenerClass,
public string $listenerMethod,
) {
}
) {}
}

View file

@ -34,8 +34,7 @@ final class Finder
private readonly string $path,
private array $classNames = [],
private readonly bool $cached = false,
) {
}
) {}
/**
* @return Listener[]
@ -44,7 +43,7 @@ final class Finder
{
$this->populateClassnames();
return array_map(
static fn (array $h): Listener
static fn(array $h): Listener
=> new Listener($h[0]->eventClass, $h[0]->priority, $h[1], $h[2]),
iterator_to_array($this->getAttributes(AsListener::class)),
);
@ -57,7 +56,7 @@ final class Finder
{
$this->populateClassnames();
return array_map(
static fn (array $h): Handler
static fn(array $h): Handler
=> new Handler($h[0]->method, $h[0]->path, $h[1], $h[2]),
iterator_to_array($this->getAttributes(AsHandler::class)),
);

View file

@ -12,8 +12,7 @@ class HttpKernel
{
public function __construct(
private readonly Dispatcher $dispatcher
) {
}
) {}
public function handle(Request $request): Response
{

View file

@ -13,6 +13,5 @@ final readonly class AsHandler
public function __construct(
public HttpMethod $method,
public string $path
) {
}
) {}
}

View file

@ -13,6 +13,5 @@ final readonly class Handler
public string $path,
public string $handlerClass,
public string $handlerMethod,
) {
}
) {}
}

View file

@ -13,6 +13,5 @@ final class RequestEvent extends GenericEvent
public Request $request,
public Response|null $response = null,
public Handler|null $handler = null,
) {
}
) {}
}

View file

@ -9,8 +9,7 @@ final readonly class AttributeRouteCollector
{
public function __construct(
private Finder $finder
) {
}
) {}
#[AsListener(CollectRoutes::class)]
public function collect(CollectRoutes $event): void

View file

@ -14,6 +14,5 @@ final class CollectRoutes extends GenericEvent
public function __construct(
public readonly bool $cached = false
) {
}
) {}
}

View file

@ -14,8 +14,7 @@ final readonly class HandlerCaller
{
public function __construct(
private InvokerInterface $invoker
) {
}
) {}
#[AsListener(RequestEvent::class, -50)]
public function callHandler(RequestEvent $event): void

View file

@ -21,8 +21,7 @@ final readonly class HandlerResolver
public function __construct(
private Dispatcher $dispatcher,
private bool $cached = false,
) {
}
) {}
#[AsListener(RequestEvent::class, -90)]
public function resolveHandler(RequestEvent $event): void

View file

@ -8,6 +8,5 @@ final class LauschEvent extends GenericEvent
{
public function __construct(
public string $message
) {
}
) {}
}