public function bindMethod(Method $method, $index) { $key = Key::ofProvider($method); $provides = $method->getAnnotation("Spot\\Inject\\Provides"); if (!$provides->overrides && ($configured = $this->bindings->get($key)) && $configured instanceof ModuleBinding) { throw new ConfigurationException("Binding for {$key} in " . $method->getFileName() . ":" . $method->getStartLine() . " is already configured in " . $configured->getSource() . ", use @Provides(overrides = true)"); } $dependencies = []; foreach ($method->getParameters() as $parameter) { $dependencies[$parameter->name] = $this->bindParameter($parameter); } $binding = new ProviderMethodBinding($key, $index, $method, $dependencies); if ($method->isAnnotatedWith("Spot\\Inject\\Singleton")) { $binding = new SingletonBinding($binding); } if ($key->isCollection()) { $collection = $this->bindings->get($key); if (empty($collection)) { $collection = new CollectionBinding($key); $this->bindings->put($collection); } $collection->addElement($binding); } else { $this->bindings->put($binding); } }