diff --git a/src/ServiceManager.php b/src/ServiceManager.php index de94d202..e7d3c706 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -53,20 +53,42 @@ * * @see ConfigInterface * - * @psalm-import-type ServiceManagerConfigurationType from ConfigInterface - * @psalm-import-type AbstractFactoriesConfigurationType from ConfigInterface - * @psalm-import-type DelegatorsConfigurationType from ConfigInterface - * @psalm-import-type FactoriesConfigurationType from ConfigInterface - * @psalm-import-type InitializersConfigurationType from ConfigInterface - * @psalm-import-type LazyServicesConfigurationType from ConfigInterface + * @psalm-type AbstractFactoriesConfiguration = array< + * array-key, + * (class-string|Factory\AbstractFactoryInterface) + * > + * @psalm-type DelegatorsConfiguration = array< + * string, + * array< + * array-key, + * (class-string|Factory\DelegatorFactoryInterface) + * |callable(ContainerInterface,string,callable():object,array|null):object + * > + * > + * @psalm-type FactoriesConfiguration = array< + * string, + * (class-string|Factory\FactoryInterface) + * |callable(ContainerInterface,?string,?array|null):object + * > + * @psalm-type InitializersConfiguration = array< + * array-key, + * (class-string|Initializer\InitializerInterface) + * |callable(ContainerInterface,object):void + * > + * @psalm-type LazyServicesConfiguration = array{ + * class_map?:array, + * proxies_namespace?:non-empty-string, + * proxies_target_dir?:non-empty-string, + * write_proxy_files?:bool + * } * @psalm-type ServiceManagerConfiguration = array{ - * abstract_factories?: AbstractFactoriesConfigurationType, + * abstract_factories?: AbstractFactoriesConfiguration, * aliases?: array, - * delegators?: DelegatorsConfigurationType, - * factories?: FactoriesConfigurationType, - * initializers?: InitializersConfigurationType, + * delegators?: DelegatorsConfiguration, + * factories?: FactoriesConfiguration, + * initializers?: InitializersConfiguration, * invokables?: array, - * lazy_services?: LazyServicesConfigurationType, + * lazy_services?: LazyServicesConfiguration, * services?: array, * shared?:array, * shared_by_default?:bool, @@ -99,7 +121,7 @@ class ServiceManager implements ServiceLocatorInterface /** * @var string[][]|Factory\DelegatorFactoryInterface[][] - * @psalm-var DelegatorsConfigurationType + * @psalm-var DelegatorsConfiguration */ protected $delegators = []; @@ -107,19 +129,19 @@ class ServiceManager implements ServiceLocatorInterface * A list of factories (either as string name or callable) * * @var string[]|callable[] - * @psalm-var FactoriesConfigurationType + * @psalm-var FactoriesConfiguration */ protected $factories = []; /** * @var Initializer\InitializerInterface[]|callable[] - * @psalm-var InitializersConfigurationType + * @psalm-var InitializersConfiguration */ protected $initializers = []; /** * @var array - * @psalm-var LazyServicesConfigurationType + * @psalm-var LazyServicesConfiguration */ protected $lazyServices = []; @@ -512,7 +534,7 @@ public function setShared($name, $flag) /** * Instantiate initializers for to avoid checks during service construction. * - * @psalm-param InitializersConfigurationType $initializers + * @psalm-param InitializersConfiguration $initializers */ private function resolveInitializers(array $initializers): void { @@ -689,8 +711,8 @@ private function createLazyServiceDelegatorFactory(): LazyServiceFactory * It works with strings and class instances. * It's not possible to de-duple anonymous functions * - * @psalm-param DelegatorsConfigurationType $config - * @psalm-return DelegatorsConfigurationType + * @psalm-param DelegatorsConfiguration $config + * @psalm-return DelegatorsConfiguration */ private function mergeDelegators(array $config): array { @@ -745,7 +767,7 @@ private function createAliasesAndFactoriesForInvokables(array $invokables): arra * a given service name we do not have a service instance * in the cache OR override is explicitly allowed. * - * @psalm-param ServiceManagerConfigurationType $config + * @psalm-param ServiceManagerConfiguration $config * @throws ContainerModificationsNotAllowedException If any * service key is invalid. */