|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +declare(strict_types=1); |
| 4 | + |
3 | 5 | /* |
4 | 6 | * This file is part of the BazingaGeocoderBundle package. |
5 | 7 | * For the full copyright and license information, please view the LICENSE |
@@ -61,7 +63,7 @@ private function loadProviders(ContainerBuilder $container, array $config) |
61 | 63 | foreach ($config['providers'] as $providerName => $providerConfig) { |
62 | 64 | $factoryService = $container->getDefinition($providerConfig['factory']); |
63 | 65 | $factoryClass = $factoryService->getClass() ?: $providerConfig['factory']; |
64 | | - if (!class_implements($factoryClass, ProviderFactoryInterface::class)) { |
| 66 | + if (!$this->implementsPoviderFactory($factoryClass)) { |
65 | 67 | throw new \LogicException(sprintf('Provider factory "%s" must implement ProviderFactoryInterface', $providerConfig['factory'])); |
66 | 68 | } |
67 | 69 | $factoryClass::validate($providerConfig['options'], $providerName); |
@@ -198,16 +200,30 @@ public function getConfiguration(array $config, ContainerBuilder $container) |
198 | 200 | * |
199 | 201 | * @return array |
200 | 202 | */ |
201 | | - private function findReferences(array $options) |
| 203 | + private function findReferences(array $options): array |
202 | 204 | { |
203 | 205 | foreach ($options as $key => $value) { |
204 | 206 | if (is_array($value)) { |
205 | 207 | $options[$key] = $this->findReferences($value); |
206 | | - } elseif (substr($key, -8) === '_service' || strpos($value, '@') === 0 || $key === 'service') { |
| 208 | + } elseif (substr((string) $key, -8) === '_service' || strpos((string) $value, '@') === 0 || $key === 'service') { |
207 | 209 | $options[$key] = new Reference(ltrim($value, '@')); |
208 | 210 | } |
209 | 211 | } |
210 | 212 |
|
211 | 213 | return $options; |
212 | 214 | } |
| 215 | + |
| 216 | + /** |
| 217 | + * @param mixed $factoryClass |
| 218 | + * |
| 219 | + * @return bool |
| 220 | + */ |
| 221 | + private function implementsPoviderFactory($factoryClass): bool |
| 222 | + { |
| 223 | + if (false === $interfaces = class_implements($factoryClass)) { |
| 224 | + return false; |
| 225 | + } |
| 226 | + |
| 227 | + return in_array(ProviderFactoryInterface::class, $interfaces); |
| 228 | + } |
213 | 229 | } |
0 commit comments