comparison vendor/symfony/dependency-injection/Loader/XmlFileLoader.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
10 */ 10 */
11 11
12 namespace Symfony\Component\DependencyInjection\Loader; 12 namespace Symfony\Component\DependencyInjection\Loader;
13 13
14 use Symfony\Component\Config\Util\XmlUtils; 14 use Symfony\Component\Config\Util\XmlUtils;
15 use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
16 use Symfony\Component\DependencyInjection\ContainerInterface;
17 use Symfony\Component\DependencyInjection\Alias; 15 use Symfony\Component\DependencyInjection\Alias;
18 use Symfony\Component\DependencyInjection\Argument\BoundArgument; 16 use Symfony\Component\DependencyInjection\Argument\BoundArgument;
19 use Symfony\Component\DependencyInjection\Argument\IteratorArgument; 17 use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
20 use Symfony\Component\DependencyInjection\Definition; 18 use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
21 use Symfony\Component\DependencyInjection\ChildDefinition; 19 use Symfony\Component\DependencyInjection\ChildDefinition;
22 use Symfony\Component\DependencyInjection\ContainerBuilder; 20 use Symfony\Component\DependencyInjection\ContainerBuilder;
23 use Symfony\Component\DependencyInjection\Reference; 21 use Symfony\Component\DependencyInjection\ContainerInterface;
22 use Symfony\Component\DependencyInjection\Definition;
24 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; 23 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
25 use Symfony\Component\DependencyInjection\Exception\RuntimeException; 24 use Symfony\Component\DependencyInjection\Exception\RuntimeException;
25 use Symfony\Component\DependencyInjection\Reference;
26 use Symfony\Component\ExpressionLanguage\Expression; 26 use Symfony\Component\ExpressionLanguage\Expression;
27 27
28 /** 28 /**
29 * XmlFileLoader loads XML files service definitions. 29 * XmlFileLoader loads XML files service definitions.
30 * 30 *
61 61
62 // services 62 // services
63 try { 63 try {
64 $this->parseDefinitions($xml, $path, $defaults); 64 $this->parseDefinitions($xml, $path, $defaults);
65 } finally { 65 } finally {
66 $this->instanceof = array(); 66 $this->instanceof = [];
67 } 67 }
68 } 68 }
69 69
70 /** 70 /**
71 * {@inheritdoc} 71 * {@inheritdoc}
72 */ 72 */
73 public function supports($resource, $type = null) 73 public function supports($resource, $type = null)
74 { 74 {
75 if (!is_string($resource)) { 75 if (!\is_string($resource)) {
76 return false; 76 return false;
77 } 77 }
78 78
79 if (null === $type && 'xml' === pathinfo($resource, PATHINFO_EXTENSION)) { 79 if (null === $type && 'xml' === pathinfo($resource, PATHINFO_EXTENSION)) {
80 return true; 80 return true;
109 109
110 if (false === $imports = $xpath->query('//container:imports/container:import')) { 110 if (false === $imports = $xpath->query('//container:imports/container:import')) {
111 return; 111 return;
112 } 112 }
113 113
114 $defaultDirectory = dirname($file); 114 $defaultDirectory = \dirname($file);
115 foreach ($imports as $import) { 115 foreach ($imports as $import) {
116 $this->setCurrentDir($defaultDirectory); 116 $this->setCurrentDir($defaultDirectory);
117 $this->import($import->getAttribute('resource'), XmlUtils::phpize($import->getAttribute('type')) ?: null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file); 117 $this->import($import->getAttribute('resource'), XmlUtils::phpize($import->getAttribute('type')) ?: null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file);
118 } 118 }
119 } 119 }
130 $xpath->registerNamespace('container', self::NS); 130 $xpath->registerNamespace('container', self::NS);
131 131
132 if (false === $services = $xpath->query('//container:services/container:service|//container:services/container:prototype')) { 132 if (false === $services = $xpath->query('//container:services/container:service|//container:services/container:prototype')) {
133 return; 133 return;
134 } 134 }
135 $this->setCurrentDir(dirname($file)); 135 $this->setCurrentDir(\dirname($file));
136 136
137 $this->instanceof = array(); 137 $this->instanceof = [];
138 $this->isLoadingInstanceof = true; 138 $this->isLoadingInstanceof = true;
139 $instanceof = $xpath->query('//container:services/container:instanceof'); 139 $instanceof = $xpath->query('//container:services/container:instanceof');
140 foreach ($instanceof as $service) { 140 foreach ($instanceof as $service) {
141 $this->setDefinition((string) $service->getAttribute('id'), $this->parseDefinition($service, $file, array())); 141 $this->setDefinition((string) $service->getAttribute('id'), $this->parseDefinition($service, $file, []));
142 } 142 }
143 143
144 $this->isLoadingInstanceof = false; 144 $this->isLoadingInstanceof = false;
145 foreach ($services as $service) { 145 foreach ($services as $service) {
146 if (null !== $definition = $this->parseDefinition($service, $file, $defaults)) { 146 if (null !== $definition = $this->parseDefinition($service, $file, $defaults)) {
162 { 162 {
163 $xpath = new \DOMXPath($xml); 163 $xpath = new \DOMXPath($xml);
164 $xpath->registerNamespace('container', self::NS); 164 $xpath->registerNamespace('container', self::NS);
165 165
166 if (null === $defaultsNode = $xpath->query('//container:services/container:defaults')->item(0)) { 166 if (null === $defaultsNode = $xpath->query('//container:services/container:defaults')->item(0)) {
167 return array(); 167 return [];
168 } 168 }
169 $defaults = array( 169 $defaults = [
170 'tags' => $this->getChildren($defaultsNode, 'tag'), 170 'tags' => $this->getChildren($defaultsNode, 'tag'),
171 'bind' => array_map(function ($v) { return new BoundArgument($v); }, $this->getArgumentsAsPhp($defaultsNode, 'bind', $file)), 171 'bind' => array_map(function ($v) { return new BoundArgument($v); }, $this->getArgumentsAsPhp($defaultsNode, 'bind', $file)),
172 ); 172 ];
173 173
174 foreach ($defaults['tags'] as $tag) { 174 foreach ($defaults['tags'] as $tag) {
175 if ('' === $tag->getAttribute('name')) { 175 if ('' === $tag->getAttribute('name')) {
176 throw new InvalidArgumentException(sprintf('The tag name for tag "<defaults>" in %s must be a non-empty string.', $file)); 176 throw new InvalidArgumentException(sprintf('The tag name for tag "<defaults>" in %s must be a non-empty string.', $file));
177 } 177 }
251 } 251 }
252 if (isset($defaults['autoconfigure'])) { 252 if (isset($defaults['autoconfigure'])) {
253 $definition->setAutoconfigured($defaults['autoconfigure']); 253 $definition->setAutoconfigured($defaults['autoconfigure']);
254 } 254 }
255 255
256 $definition->setChanges(array()); 256 $definition->setChanges([]);
257 } 257 }
258 258
259 foreach (array('class', 'public', 'shared', 'synthetic', 'lazy', 'abstract') as $key) { 259 foreach (['class', 'public', 'shared', 'synthetic', 'lazy', 'abstract'] as $key) {
260 if ($value = $service->getAttribute($key)) { 260 if ($value = $service->getAttribute($key)) {
261 $method = 'set'.$key; 261 $method = 'set'.$key;
262 $definition->$method(XmlUtils::phpize($value)); 262 $definition->$method(XmlUtils::phpize($value));
263 } 263 }
264 } 264 }
295 $class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); 295 $class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE);
296 } else { 296 } else {
297 $class = $factory->hasAttribute('class') ? $factory->getAttribute('class') : null; 297 $class = $factory->hasAttribute('class') ? $factory->getAttribute('class') : null;
298 } 298 }
299 299
300 $definition->setFactory(array($class, $factory->getAttribute('method'))); 300 $definition->setFactory([$class, $factory->getAttribute('method')]);
301 } 301 }
302 } 302 }
303 303
304 if ($configurators = $this->getChildren($service, 'configurator')) { 304 if ($configurators = $this->getChildren($service, 'configurator')) {
305 $configurator = $configurators[0]; 305 $configurator = $configurators[0];
310 $class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); 310 $class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE);
311 } else { 311 } else {
312 $class = $configurator->getAttribute('class'); 312 $class = $configurator->getAttribute('class');
313 } 313 }
314 314
315 $definition->setConfigurator(array($class, $configurator->getAttribute('method'))); 315 $definition->setConfigurator([$class, $configurator->getAttribute('method')]);
316 } 316 }
317 } 317 }
318 318
319 foreach ($this->getChildren($service, 'call') as $call) { 319 foreach ($this->getChildren($service, 'call') as $call) {
320 $definition->addMethodCall($call->getAttribute('method'), $this->getArgumentsAsPhp($call, 'argument', $file)); 320 $definition->addMethodCall($call->getAttribute('method'), $this->getArgumentsAsPhp($call, 'argument', $file));
325 if (!empty($defaults['tags'])) { 325 if (!empty($defaults['tags'])) {
326 $tags = array_merge($tags, $defaults['tags']); 326 $tags = array_merge($tags, $defaults['tags']);
327 } 327 }
328 328
329 foreach ($tags as $tag) { 329 foreach ($tags as $tag) {
330 $parameters = array(); 330 $parameters = [];
331 foreach ($tag->attributes as $name => $node) { 331 foreach ($tag->attributes as $name => $node) {
332 if ('name' === $name) { 332 if ('name' === $name) {
333 continue; 333 continue;
334 } 334 }
335 335
379 * @throws InvalidArgumentException When loading of XML file returns error 379 * @throws InvalidArgumentException When loading of XML file returns error
380 */ 380 */
381 private function parseFileToDOM($file) 381 private function parseFileToDOM($file)
382 { 382 {
383 try { 383 try {
384 $dom = XmlUtils::loadFile($file, array($this, 'validateSchema')); 384 $dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
385 } catch (\InvalidArgumentException $e) { 385 } catch (\InvalidArgumentException $e) {
386 throw new InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e); 386 throw new InvalidArgumentException(sprintf('Unable to parse file "%s": %s', $file, $e->getMessage()), $e->getCode(), $e);
387 } 387 }
388 388
389 $this->validateExtensions($dom, $file); 389 $this->validateExtensions($dom, $file);
390 390
391 return $dom; 391 return $dom;
398 * @param string $file 398 * @param string $file
399 * @param array $defaults 399 * @param array $defaults
400 */ 400 */
401 private function processAnonymousServices(\DOMDocument $xml, $file, $defaults) 401 private function processAnonymousServices(\DOMDocument $xml, $file, $defaults)
402 { 402 {
403 $definitions = array(); 403 $definitions = [];
404 $count = 0; 404 $count = 0;
405 $suffix = ContainerBuilder::hash($file); 405 $suffix = '~'.ContainerBuilder::hash($file);
406 406
407 $xpath = new \DOMXPath($xml); 407 $xpath = new \DOMXPath($xml);
408 $xpath->registerNamespace('container', self::NS); 408 $xpath->registerNamespace('container', self::NS);
409 409
410 // anonymous services as arguments/properties 410 // anonymous services as arguments/properties
411 if (false !== $nodes = $xpath->query('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)]|//container:bind[not(@id)]|//container:factory[not(@service)]|//container:configurator[not(@service)]')) { 411 if (false !== $nodes = $xpath->query('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)]|//container:bind[not(@id)]|//container:factory[not(@service)]|//container:configurator[not(@service)]')) {
412 foreach ($nodes as $node) { 412 foreach ($nodes as $node) {
413 if ($services = $this->getChildren($node, 'service')) { 413 if ($services = $this->getChildren($node, 'service')) {
414 // give it a unique name 414 // give it a unique name
415 $id = sprintf('%d_%s', ++$count, preg_replace('/^.*\\\\/', '', $services[0]->getAttribute('class')).'~'.$suffix); 415 $id = sprintf('%d_%s', ++$count, preg_replace('/^.*\\\\/', '', $services[0]->getAttribute('class')).$suffix);
416 $node->setAttribute('id', $id); 416 $node->setAttribute('id', $id);
417 $node->setAttribute('service', $id); 417 $node->setAttribute('service', $id);
418 418
419 $definitions[$id] = array($services[0], $file, false); 419 $definitions[$id] = [$services[0], $file, false];
420 $services[0]->setAttribute('id', $id); 420 $services[0]->setAttribute('id', $id);
421 421
422 // anonymous services are always private 422 // anonymous services are always private
423 // we could not use the constant false here, because of XML parsing 423 // we could not use the constant false here, because of XML parsing
424 $services[0]->setAttribute('public', 'false'); 424 $services[0]->setAttribute('public', 'false');
432 @trigger_error(sprintf('Top-level anonymous services are deprecated since Symfony 3.4, the "id" attribute will be required in version 4.0 in %s at line %d.', $file, $node->getLineNo()), E_USER_DEPRECATED); 432 @trigger_error(sprintf('Top-level anonymous services are deprecated since Symfony 3.4, the "id" attribute will be required in version 4.0 in %s at line %d.', $file, $node->getLineNo()), E_USER_DEPRECATED);
433 433
434 // give it a unique name 434 // give it a unique name
435 $id = sprintf('%d_%s', ++$count, preg_replace('/^.*\\\\/', '', $node->getAttribute('class')).$suffix); 435 $id = sprintf('%d_%s', ++$count, preg_replace('/^.*\\\\/', '', $node->getAttribute('class')).$suffix);
436 $node->setAttribute('id', $id); 436 $node->setAttribute('id', $id);
437 $definitions[$id] = array($node, $file, true); 437 $definitions[$id] = [$node, $file, true];
438 } 438 }
439 } 439 }
440 440
441 // resolve definitions 441 // resolve definitions
442 uksort($definitions, 'strnatcmp'); 442 uksort($definitions, 'strnatcmp');
443 foreach (array_reverse($definitions) as $id => list($domElement, $file, $wild)) { 443 foreach (array_reverse($definitions) as $id => list($domElement, $file, $wild)) {
444 if (null !== $definition = $this->parseDefinition($domElement, $file, $wild ? $defaults : array())) { 444 if (null !== $definition = $this->parseDefinition($domElement, $file, $wild ? $defaults : [])) {
445 $this->setDefinition($id, $definition); 445 $this->setDefinition($id, $definition);
446 } 446 }
447 447
448 if (true === $wild) { 448 if (true === $wild) {
449 $tmpDomElement = new \DOMElement('_services', null, self::NS); 449 $tmpDomElement = new \DOMElement('_services', null, self::NS);
463 * 463 *
464 * @return mixed 464 * @return mixed
465 */ 465 */
466 private function getArgumentsAsPhp(\DOMElement $node, $name, $file, $lowercase = true, $isChildDefinition = false) 466 private function getArgumentsAsPhp(\DOMElement $node, $name, $file, $lowercase = true, $isChildDefinition = false)
467 { 467 {
468 $arguments = array(); 468 $arguments = [];
469 foreach ($this->getChildren($node, $name) as $arg) { 469 foreach ($this->getChildren($node, $name) as $arg) {
470 if ($arg->hasAttribute('name')) { 470 if ($arg->hasAttribute('name')) {
471 $arg->setAttribute('key', $arg->getAttribute('name')); 471 $arg->setAttribute('key', $arg->getAttribute('name'));
472 } 472 }
473 473
494 $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; 494 $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
495 } 495 }
496 496
497 switch ($arg->getAttribute('type')) { 497 switch ($arg->getAttribute('type')) {
498 case 'service': 498 case 'service':
499 if (!$arg->getAttribute('id')) { 499 if ('' === $arg->getAttribute('id')) {
500 throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" has no or empty "id" attribute in "%s".', $name, $file)); 500 throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" has no or empty "id" attribute in "%s".', $name, $file));
501 } 501 }
502 if ($arg->hasAttribute('strict')) { 502 if ($arg->hasAttribute('strict')) {
503 @trigger_error(sprintf('The "strict" attribute used when referencing the "%s" service is deprecated since Symfony 3.3 and will be removed in 4.0.', $arg->getAttribute('id')), E_USER_DEPRECATED); 503 @trigger_error(sprintf('The "strict" attribute used when referencing the "%s" service is deprecated since Symfony 3.3 and will be removed in 4.0.', $arg->getAttribute('id')), E_USER_DEPRECATED);
504 } 504 }
531 break; 531 break;
532 case 'string': 532 case 'string':
533 $arguments[$key] = $arg->nodeValue; 533 $arguments[$key] = $arg->nodeValue;
534 break; 534 break;
535 case 'constant': 535 case 'constant':
536 $arguments[$key] = constant(trim($arg->nodeValue)); 536 $arguments[$key] = \constant(trim($arg->nodeValue));
537 break; 537 break;
538 default: 538 default:
539 $arguments[$key] = XmlUtils::phpize($arg->nodeValue); 539 $arguments[$key] = XmlUtils::phpize($arg->nodeValue);
540 } 540 }
541 } 541 }
547 * Get child elements by name. 547 * Get child elements by name.
548 * 548 *
549 * @param \DOMNode $node 549 * @param \DOMNode $node
550 * @param mixed $name 550 * @param mixed $name
551 * 551 *
552 * @return array 552 * @return \DOMElement[]
553 */ 553 */
554 private function getChildren(\DOMNode $node, $name) 554 private function getChildren(\DOMNode $node, $name)
555 { 555 {
556 $children = array(); 556 $children = [];
557 foreach ($node->childNodes as $child) { 557 foreach ($node->childNodes as $child) {
558 if ($child instanceof \DOMElement && $child->localName === $name && self::NS === $child->namespaceURI) { 558 if ($child instanceof \DOMElement && $child->localName === $name && self::NS === $child->namespaceURI) {
559 $children[] = $child; 559 $children[] = $child;
560 } 560 }
561 } 561 }
572 * 572 *
573 * @throws RuntimeException When extension references a non-existent XSD file 573 * @throws RuntimeException When extension references a non-existent XSD file
574 */ 574 */
575 public function validateSchema(\DOMDocument $dom) 575 public function validateSchema(\DOMDocument $dom)
576 { 576 {
577 $schemaLocations = array('http://symfony.com/schema/dic/services' => str_replace('\\', '/', __DIR__.'/schema/dic/services/services-1.0.xsd')); 577 $schemaLocations = ['http://symfony.com/schema/dic/services' => str_replace('\\', '/', __DIR__.'/schema/dic/services/services-1.0.xsd')];
578 578
579 if ($element = $dom->documentElement->getAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation')) { 579 if ($element = $dom->documentElement->getAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation')) {
580 $items = preg_split('/\s+/', $element); 580 $items = preg_split('/\s+/', $element);
581 for ($i = 0, $nb = count($items); $i < $nb; $i += 2) { 581 for ($i = 0, $nb = \count($items); $i < $nb; $i += 2) {
582 if (!$this->container->hasExtension($items[$i])) { 582 if (!$this->container->hasExtension($items[$i])) {
583 continue; 583 continue;
584 } 584 }
585 585
586 if (($extension = $this->container->getExtension($items[$i])) && false !== $extension->getXsdValidationBasePath()) { 586 if (($extension = $this->container->getExtension($items[$i])) && false !== $extension->getXsdValidationBasePath()) {
587 $path = str_replace($extension->getNamespace(), str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/', $items[$i + 1]); 587 $path = str_replace($extension->getNamespace(), str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/', $items[$i + 1]);
588 588
589 if (!is_file($path)) { 589 if (!is_file($path)) {
590 throw new RuntimeException(sprintf('Extension "%s" references a non-existent XSD file "%s"', get_class($extension), $path)); 590 throw new RuntimeException(sprintf('Extension "%s" references a non-existent XSD file "%s"', \get_class($extension), $path));
591 } 591 }
592 592
593 $schemaLocations[$items[$i]] = $path; 593 $schemaLocations[$items[$i]] = $path;
594 } 594 }
595 } 595 }
596 } 596 }
597 597
598 $tmpfiles = array(); 598 $tmpfiles = [];
599 $imports = ''; 599 $imports = '';
600 foreach ($schemaLocations as $namespace => $location) { 600 foreach ($schemaLocations as $namespace => $location) {
601 $parts = explode('/', $location); 601 $parts = explode('/', $location);
602 $locationstart = 'file:///'; 602 $locationstart = 'file:///';
603 if (0 === stripos($location, 'phar://')) { 603 if (0 === stripos($location, 'phar://')) {
609 } else { 609 } else {
610 array_shift($parts); 610 array_shift($parts);
611 $locationstart = 'phar:///'; 611 $locationstart = 'phar:///';
612 } 612 }
613 } 613 }
614 $drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : ''; 614 $drive = '\\' === \DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
615 $location = $locationstart.$drive.implode('/', array_map('rawurlencode', $parts)); 615 $location = $locationstart.$drive.implode('/', array_map('rawurlencode', $parts));
616 616
617 $imports .= sprintf(' <xsd:import namespace="%s" schemaLocation="%s" />'."\n", $namespace, $location); 617 $imports .= sprintf(' <xsd:import namespace="%s" schemaLocation="%s" />'."\n", $namespace, $location);
618 } 618 }
619 619
648 * @param string $file 648 * @param string $file
649 */ 649 */
650 private function validateAlias(\DOMElement $alias, $file) 650 private function validateAlias(\DOMElement $alias, $file)
651 { 651 {
652 foreach ($alias->attributes as $name => $node) { 652 foreach ($alias->attributes as $name => $node) {
653 if (!in_array($name, array('alias', 'id', 'public'))) { 653 if (!\in_array($name, ['alias', 'id', 'public'])) {
654 @trigger_error(sprintf('Using the attribute "%s" is deprecated for the service "%s" which is defined as an alias in "%s". Allowed attributes for service aliases are "alias", "id" and "public". The XmlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported attributes.', $name, $alias->getAttribute('id'), $file), E_USER_DEPRECATED); 654 @trigger_error(sprintf('Using the attribute "%s" is deprecated for the service "%s" which is defined as an alias in "%s". Allowed attributes for service aliases are "alias", "id" and "public". The XmlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported attributes.', $name, $alias->getAttribute('id'), $file), E_USER_DEPRECATED);
655 } 655 }
656 } 656 }
657 657
658 foreach ($alias->childNodes as $child) { 658 foreach ($alias->childNodes as $child) {
678 } 678 }
679 679
680 // can it be handled by an extension? 680 // can it be handled by an extension?
681 if (!$this->container->hasExtension($node->namespaceURI)) { 681 if (!$this->container->hasExtension($node->namespaceURI)) {
682 $extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getNamespace(); }, $this->container->getExtensions())); 682 $extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getNamespace(); }, $this->container->getExtensions()));
683 throw new InvalidArgumentException(sprintf( 683 throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', $node->tagName, $file, $node->namespaceURI, $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none'));
684 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
685 $node->tagName,
686 $file,
687 $node->namespaceURI,
688 $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none'
689 ));
690 } 684 }
691 } 685 }
692 } 686 }
693 687
694 /** 688 /**
702 if (!$node instanceof \DOMElement || self::NS === $node->namespaceURI) { 696 if (!$node instanceof \DOMElement || self::NS === $node->namespaceURI) {
703 continue; 697 continue;
704 } 698 }
705 699
706 $values = static::convertDomElementToArray($node); 700 $values = static::convertDomElementToArray($node);
707 if (!is_array($values)) { 701 if (!\is_array($values)) {
708 $values = array(); 702 $values = [];
709 } 703 }
710 704
711 $this->container->loadFromExtension($node->namespaceURI, $values); 705 $this->container->loadFromExtension($node->namespaceURI, $values);
712 } 706 }
713 } 707 }