diff --git a/src/ConfigAggregator.php b/src/ConfigAggregator.php index f1c79ea..6ae33cc 100644 --- a/src/ConfigAggregator.php +++ b/src/ConfigAggregator.php @@ -81,7 +81,7 @@ public function __construct( return; } - $providers = $this->removeDuplicateProviders($providers); + $providers = $this->validateDuplicateProviders($providers); $providers = $this->preProcessProviders($preProcessors, $providers); $this->config = $this->loadConfigFromProviders($providers); $this->config = $this->postProcessConfig($postProcessors, $this->config); @@ -103,13 +103,19 @@ public function getMergedConfig() * @return ProviderIterable * @throws InvalidConfigProviderException */ - private function removeDuplicateProviders(iterable $providers): iterable + private function validateDuplicateProviders(iterable $providers): iterable { $uniqueProviders = []; foreach ($providers as $provider) { - if (get_debug_type($provider) === 'string' && in_array($provider, $uniqueProviders, true)) { - throw InvalidConfigProviderException::fromDuplicateProvider($provider); + if (! is_string($provider) && ! is_object($provider)) { + continue; + } + + if (in_array($provider, $uniqueProviders, true)) { + throw InvalidConfigProviderException::fromDuplicateProvider( + is_string($provider) ? $provider : get_debug_type($provider) + ); } $uniqueProviders[] = $provider; diff --git a/src/InvalidConfigProviderException.php b/src/InvalidConfigProviderException.php index 65e8d66..07eff57 100644 --- a/src/InvalidConfigProviderException.php +++ b/src/InvalidConfigProviderException.php @@ -10,11 +10,7 @@ class InvalidConfigProviderException extends RuntimeException { - /** - * @param string $provider - * @return self - */ - public static function fromDuplicateProvider($provider) + public static function fromDuplicateProvider(string $provider): self { return new self(sprintf( '%s is registered more than once. Config providers should be unique. In case a specific order is'