Removed PSR/Container

pull/567/head
fadrian06 10 months ago
parent 598c71d01c
commit 99a7d75440

@ -25,7 +25,6 @@
"require": {
"php": "^7.4|^8.0|^8.1|^8.2|^8.3",
"ext-json": "*",
"psr/container": "^2.0",
"symfony/polyfill-php80": "^1.29"
},
"autoload": {

@ -44,24 +44,34 @@ class Dispatcher
/**
* This is a container for the dependency injection.
*
* @var null|ContainerInterface|(callable(string $classString, array $params): (null|object))
* @var null|ContainerInterface|(callable(string $classString, array<int, mixed> $params): (null|object))
*/
protected $containerHandler = null;
/**
* Sets the dependency injection container handler.
*
* @param ContainerInterface|(callable(string $classString, array $params): (null|object)) $containerHandler
* @param ContainerInterface|(callable(string $classString, array<int, mixed> $params): (null|object)) $containerHandler
* Dependency injection container.
*
* @throws InvalidArgumentException If $containerHandler is not a `callable` or instance of `Psr\Container\ContainerInterface`.
*/
public function setContainerHandler($containerHandler): void
{
$containerInterfaceNS = '\Psr\Container\ContainerInterface';
if (
$containerHandler instanceof ContainerInterface
is_a($containerHandler, $containerInterfaceNS)
|| is_callable($containerHandler)
) {
$this->containerHandler = $containerHandler;
return;
}
throw new InvalidArgumentException(
"\$containerHandler must be of type callable or instance $containerInterfaceNS"
);
}
public function setEngine(Engine $engine): void
@ -200,7 +210,7 @@ class Dispatcher
*
* @param string $name Event name
* @param 'before'|'after' $type Filter type.
* @param callable(array<int, mixed> &$params, string &$output): (void|false) $callback
* @param callable(array<int, mixed> &$params, mixed &$output): (void|false)|callable(mixed &$output): (void|false) $callback
*
* @return $this
*/
@ -430,7 +440,7 @@ class Dispatcher
{
// PSR-11
if (
$this->containerHandler instanceof ContainerInterface
is_a($this->containerHandler, '\Psr\Container\ContainerInterface')
&& $this->containerHandler->has($class)
) {
return $this->containerHandler->get($class);

@ -1,6 +0,0 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#2 \\$callback of method flight\\\\core\\\\Dispatcher\\:\\:set\\(\\) expects Closure\\(\\)\\: mixed, array\\{\\$this\\(flight\\\\Engine\\), literal\\-string&non\\-falsy\\-string\\} given\\.$#"
count: 1
path: flight/Engine.php
Loading…
Cancel
Save