@@ -27,6 +27,7 @@ class ResolveBindingsPass extends AbstractRecursivePass
2727{
2828 private $ usedBindings = array ();
2929 private $ unusedBindings = array ();
30+ private $ errorMessages = array ();
3031
3132 /**
3233 * {@inheritdoc}
@@ -37,11 +38,19 @@ public function process(ContainerBuilder $container)
3738 parent ::process ($ container );
3839
3940 foreach ($ this ->unusedBindings as list ($ key , $ serviceId )) {
40- 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 );
4149 }
4250 } finally {
4351 $ this ->usedBindings = array ();
4452 $ this ->unusedBindings = array ();
53+ $ this ->errorMessages = array ();
4554 }
4655 }
4756
@@ -94,6 +103,7 @@ protected function processValue($value, $isRoot = false)
94103 $ calls [] = array ($ constructor , $ value ->getArguments ());
95104 }
96105 } catch (RuntimeException $ e ) {
106+ $ this ->errorMessages [] = $ e ->getMessage ();
97107 $ this ->container ->getDefinition ($ this ->currentId )->addError ($ e ->getMessage ());
98108
99109 return parent ::processValue ($ value , $ isRoot );
0 commit comments