Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / symfony / dependency-injection / Compiler / ResolveBindingsPass.php
index 024523e15585c709258124051377edc7850efb80..bcf265ab472358ac415c7ca1960a7847d0b5dc50 100644 (file)
@@ -17,8 +17,8 @@ use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
 use Symfony\Component\DependencyInjection\Exception\RuntimeException;
 use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
-use Symfony\Component\DependencyInjection\TypedReference;
 use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\TypedReference;
 
 /**
  * @author Guilhem Niot <guilhem.niot@gmail.com>
@@ -27,6 +27,7 @@ class ResolveBindingsPass extends AbstractRecursivePass
 {
     private $usedBindings = array();
     private $unusedBindings = array();
+    private $errorMessages = array();
 
     /**
      * {@inheritdoc}
@@ -37,11 +38,19 @@ class ResolveBindingsPass extends AbstractRecursivePass
             parent::process($container);
 
             foreach ($this->unusedBindings as list($key, $serviceId)) {
-                throw new InvalidArgumentException(sprintf('Unused binding "%s" in service "%s".', $key, $serviceId));
+                $message = sprintf('Unused binding "%s" in service "%s".', $key, $serviceId);
+                if ($this->errorMessages) {
+                    $message .= sprintf("\nCould be related to%s:", 1 < \count($this->errorMessages) ? ' one of' : '');
+                }
+                foreach ($this->errorMessages as $m) {
+                    $message .= "\n - ".$m;
+                }
+                throw new InvalidArgumentException($message);
             }
         } finally {
             $this->usedBindings = array();
             $this->unusedBindings = array();
+            $this->errorMessages = array();
         }
     }
 
@@ -79,7 +88,7 @@ class ResolveBindingsPass extends AbstractRecursivePass
             }
 
             if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition) {
-                throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, an instance of %s or an instance of %s, %s given.', $key, $this->currentId, Reference::class, Definition::class, gettype($bindingValue)));
+                throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, an instance of %s or an instance of %s, %s given.', $key, $this->currentId, Reference::class, Definition::class, \gettype($bindingValue)));
             }
         }
 
@@ -94,6 +103,7 @@ class ResolveBindingsPass extends AbstractRecursivePass
                 $calls[] = array($constructor, $value->getArguments());
             }
         } catch (RuntimeException $e) {
+            $this->errorMessages[] = $e->getMessage();
             $this->container->getDefinition($this->currentId)->addError($e->getMessage());
 
             return parent::processValue($value, $isRoot);