package and depencies
This commit is contained in:
@@ -26,9 +26,9 @@ class_exists(NotFoundExceptionInterface::class);
|
||||
*/
|
||||
trait ServiceLocatorTrait
|
||||
{
|
||||
private $factories;
|
||||
private $loading = [];
|
||||
private $providedTypes;
|
||||
private array $factories;
|
||||
private array $loading = [];
|
||||
private array $providedTypes;
|
||||
|
||||
/**
|
||||
* @param callable[] $factories
|
||||
@@ -38,22 +38,12 @@ trait ServiceLocatorTrait
|
||||
$this->factories = $factories;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $id)
|
||||
public function has(string $id): bool
|
||||
{
|
||||
return isset($this->factories[$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $id)
|
||||
public function get(string $id): mixed
|
||||
{
|
||||
if (!isset($this->factories[$id])) {
|
||||
throw $this->createNotFoundException($id);
|
||||
@@ -75,12 +65,9 @@ trait ServiceLocatorTrait
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getProvidedServices(): array
|
||||
{
|
||||
if (null === $this->providedTypes) {
|
||||
if (!isset($this->providedTypes)) {
|
||||
$this->providedTypes = [];
|
||||
|
||||
foreach ($this->factories as $name => $factory) {
|
||||
|
Reference in New Issue
Block a user