Removed PSR/Container

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

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

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