public function visitProviderMethod(ProviderMethodBinding $providerMethod)
 {
     if (in_array($providerMethod, $this->stack)) {
         throw new ConfigurationException("Circular dependency detected");
     }
     array_push($this->stack, $providerMethod);
     $dependencies = $providerMethod->getDependencies();
     foreach ($dependencies as $name => $dependency) {
         if ($dependency instanceof LateBinding) {
             try {
                 $dependency->accept($this);
             } catch (ConfigurationException $e) {
                 $key = $dependency->getKey();
                 try {
                     $this->jitBinder->bind($this->reflection->get($key->getType()));
                 } catch (ConfigurationException $e) {
                     $method = $providerMethod->getMethod();
                     throw new ConfigurationException($e->getMessage() . ", required by parameter \$" . "{$name} in {$method->class}::{$method->name}()");
                 }
                 $dependencies[$name] = $this->bindings->get($key);
                 $providerMethod = new ProviderMethodBinding($key, $providerMethod->getIndex(), $providerMethod->getMethod(), $dependencies);
                 $this->bindings->put($providerMethod);
             }
         }
     }
     array_pop($this->stack);
 }
 public function visitProviderMethod(ProviderMethodBinding $binding)
 {
     $method = $binding->getMethod();
     foreach ($binding->getDependencies() as $name => $dependency) {
         try {
             $dependency->accept($this);
         } catch (ConfigurationException $e) {
             throw new ConfigurationException($e->getMessage() . ", required by parameter \$" . $name . " in " . $method->getType()->name . "::" . $method->name);
         }
     }
 }
 public function visitProviderMethod(ProviderMethodBinding $providerMethod)
 {
     $method = $providerMethod->getMethod();
     $method->isStatic() ? $this->writer->write($method->getType()->name, "::", $method->name) : $this->writer->write('$m[', $providerMethod->getIndex(), ']->', $method->name);
     $this->writer->write("(");
     $dependencies = $providerMethod->getDependencies();
     if ($dependencies) {
         $this->writer->indent();
         array_shift($dependencies)->accept($this);
         foreach ($dependencies as $dependency) {
             $this->writer->writeln(", ");
             $dependency->accept($this);
         }
         $this->writer->outdent();
     }
     $this->writer->write(")");
 }
Example #4
0
 public function __construct(ProviderMethodBinding $delegate)
 {
     parent::__construct($delegate->getKey());
     $this->delegate = $delegate;
 }
Example #5
0
 public function visitProviderMethod(ProviderMethodBinding $providerMethod)
 {
     foreach ($providerMethod->getDependencies() as $dependency) {
         $dependency->accept($this);
     }
 }