Skip to content

Commit

Permalink
Merge pull request #192 from boesing/backport/psalm-types
Browse files Browse the repository at this point in the history
Backport: Duplicate `ConfigInterface` psalm types in `ServiceManager`
  • Loading branch information
boesing authored May 14, 2023
2 parents e3ac283 + caf3583 commit 7aebff6
Showing 1 changed file with 41 additions and 19 deletions.
60 changes: 41 additions & 19 deletions src/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>|Factory\AbstractFactoryInterface)
* >
* @psalm-type DelegatorsConfiguration = array<
* string,
* array<
* array-key,
* (class-string<Factory\DelegatorFactoryInterface>|Factory\DelegatorFactoryInterface)
* |callable(ContainerInterface,string,callable():object,array<mixed>|null):object
* >
* >
* @psalm-type FactoriesConfiguration = array<
* string,
* (class-string<Factory\FactoryInterface>|Factory\FactoryInterface)
* |callable(ContainerInterface,?string,?array<mixed>|null):object
* >
* @psalm-type InitializersConfiguration = array<
* array-key,
* (class-string<Initializer\InitializerInterface>|Initializer\InitializerInterface)
* |callable(ContainerInterface,object):void
* >
* @psalm-type LazyServicesConfiguration = array{
* class_map?:array<string,class-string>,
* 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<string,string>,
* delegators?: DelegatorsConfigurationType,
* factories?: FactoriesConfigurationType,
* initializers?: InitializersConfigurationType,
* delegators?: DelegatorsConfiguration,
* factories?: FactoriesConfiguration,
* initializers?: InitializersConfiguration,
* invokables?: array<string,string>,
* lazy_services?: LazyServicesConfigurationType,
* lazy_services?: LazyServicesConfiguration,
* services?: array<string,object|array>,
* shared?:array<string,bool>,
* shared_by_default?:bool,
Expand Down Expand Up @@ -99,27 +121,27 @@ class ServiceManager implements ServiceLocatorInterface

/**
* @var string[][]|Factory\DelegatorFactoryInterface[][]
* @psalm-var DelegatorsConfigurationType
* @psalm-var DelegatorsConfiguration
*/
protected $delegators = [];

/**
* 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 = [];

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 7aebff6

Please sign in to comment.