Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Compiler/ResolveBindingsPass.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | 1fec387a4317 |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
13 | 13 |
14 use Symfony\Component\DependencyInjection\Argument\BoundArgument; | 14 use Symfony\Component\DependencyInjection\Argument\BoundArgument; |
15 use Symfony\Component\DependencyInjection\ContainerBuilder; | 15 use Symfony\Component\DependencyInjection\ContainerBuilder; |
16 use Symfony\Component\DependencyInjection\Definition; | 16 use Symfony\Component\DependencyInjection\Definition; |
17 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; | 17 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; |
18 use Symfony\Component\DependencyInjection\Exception\RuntimeException; | |
18 use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper; | 19 use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper; |
19 use Symfony\Component\DependencyInjection\TypedReference; | 20 use Symfony\Component\DependencyInjection\TypedReference; |
20 use Symfony\Component\DependencyInjection\Reference; | 21 use Symfony\Component\DependencyInjection\Reference; |
21 | 22 |
22 /** | 23 /** |
24 */ | 25 */ |
25 class ResolveBindingsPass extends AbstractRecursivePass | 26 class ResolveBindingsPass extends AbstractRecursivePass |
26 { | 27 { |
27 private $usedBindings = array(); | 28 private $usedBindings = array(); |
28 private $unusedBindings = array(); | 29 private $unusedBindings = array(); |
30 private $errorMessages = array(); | |
29 | 31 |
30 /** | 32 /** |
31 * {@inheritdoc} | 33 * {@inheritdoc} |
32 */ | 34 */ |
33 public function process(ContainerBuilder $container) | 35 public function process(ContainerBuilder $container) |
34 { | 36 { |
35 try { | 37 try { |
36 parent::process($container); | 38 parent::process($container); |
37 | 39 |
38 foreach ($this->unusedBindings as list($key, $serviceId)) { | 40 foreach ($this->unusedBindings as list($key, $serviceId)) { |
39 throw new InvalidArgumentException(sprintf('Unused binding "%s" in service "%s".', $key, $serviceId)); | 41 $message = sprintf('Unused binding "%s" in service "%s".', $key, $serviceId); |
42 if ($this->errorMessages) { | |
43 $message .= sprintf("\nCould be related to%s:", 1 < \count($this->errorMessages) ? ' one of' : ''); | |
44 } | |
45 foreach ($this->errorMessages as $m) { | |
46 $message .= "\n - ".$m; | |
47 } | |
48 throw new InvalidArgumentException($message); | |
40 } | 49 } |
41 } finally { | 50 } finally { |
42 $this->usedBindings = array(); | 51 $this->usedBindings = array(); |
43 $this->unusedBindings = array(); | 52 $this->unusedBindings = array(); |
53 $this->errorMessages = array(); | |
44 } | 54 } |
45 } | 55 } |
46 | 56 |
47 /** | 57 /** |
48 * {@inheritdoc} | 58 * {@inheritdoc} |
86 return parent::processValue($value, $isRoot); | 96 return parent::processValue($value, $isRoot); |
87 } | 97 } |
88 | 98 |
89 $calls = $value->getMethodCalls(); | 99 $calls = $value->getMethodCalls(); |
90 | 100 |
91 if ($constructor = $this->getConstructor($value, false)) { | 101 try { |
92 $calls[] = array($constructor, $value->getArguments()); | 102 if ($constructor = $this->getConstructor($value, false)) { |
103 $calls[] = array($constructor, $value->getArguments()); | |
104 } | |
105 } catch (RuntimeException $e) { | |
106 $this->errorMessages[] = $e->getMessage(); | |
107 $this->container->getDefinition($this->currentId)->addError($e->getMessage()); | |
108 | |
109 return parent::processValue($value, $isRoot); | |
93 } | 110 } |
94 | 111 |
95 foreach ($calls as $i => $call) { | 112 foreach ($calls as $i => $call) { |
96 list($method, $arguments) = $call; | 113 list($method, $arguments) = $call; |
97 | 114 |