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'; require_once __DIR__ . '/../vendor/autoload.php';
$cached = false; $cached = false;
$container = (new ContainerBuilder)->addDefinitions( $container = (new ContainerBuilder())->addDefinitions(
[ [
Finder::class => static fn (): Finder => new Finder(__DIR__, [], $cached), Finder::class => static fn(): Finder => new Finder(__DIR__, [], $cached),
Dispatcher::class => static fn (DispatcherFactory $f): Dispatcher Dispatcher::class => static fn(DispatcherFactory $f): Dispatcher
=> $f->getDispatcher($cached), => $f->getDispatcher($cached),
HandlerResolver::class => static fn (Dispatcher $d): HandlerResolver HandlerResolver::class => static fn(Dispatcher $d): HandlerResolver
=> new HandlerResolver($d, $cached), => new HandlerResolver($d, $cached),
], ],
)->build(); )->build();

View file

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

View file

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

View file

@ -15,8 +15,7 @@ final class Dispatcher
public function __construct( public function __construct(
private readonly InvokerInterface $invoker, private readonly InvokerInterface $invoker,
private array $listeners = [], private array $listeners = [],
) { ) {}
}
public function addListener(Listener $listener): void public function addListener(Listener $listener): void
{ {
@ -30,7 +29,7 @@ final class Dispatcher
{ {
return arrayFilter( return arrayFilter(
$this->listeners, $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); $filtered = $this->getListenerForEvent($event);
usort( usort(
$filtered, $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; return $filtered;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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