*/ private array $allowedKeys = [ 'abstract_factories' => true, 'aliases' => true, 'delegators' => true, 'factories' => true, 'initializers' => true, 'invokables' => true, 'lazy_services' => true, 'services' => true, 'shared' => true, ]; /** * @var array * @psalm-var ServiceManagerConfigurationType */ protected $config = [ 'abstract_factories' => [], 'aliases' => [], 'delegators' => [], 'factories' => [], 'initializers' => [], 'invokables' => [], 'lazy_services' => [], 'services' => [], 'shared' => [], ]; /** * @psalm-param ServiceManagerConfigurationType $config */ public function __construct(array $config = []) { // Only merge keys we're interested in foreach (array_keys($config) as $key) { if (! isset($this->allowedKeys[$key])) { unset($config[$key]); } } /** @psalm-suppress ArgumentTypeCoercion */ $this->config = $this->merge($this->config, $config); } /** * @inheritDoc */ public function configureServiceManager(ServiceManager $serviceManager) { return $serviceManager->configure($this->config); } /** * @inheritDoc */ public function toArray() { return $this->config; } /** * @psalm-param ServiceManagerConfigurationType $a * @psalm-param ServiceManagerConfigurationType $b * @psalm-return ServiceManagerConfigurationType * @psalm-suppress MixedReturnTypeCoercion */ private function merge(array $a, array $b) { /** @psalm-suppress MixedReturnTypeCoercion */ return ArrayUtils::merge($a, $b); } }