diff --git a/src/Binding.php b/src/Binding.php index 2df1cde..e0b1408 100644 --- a/src/Binding.php +++ b/src/Binding.php @@ -108,6 +108,11 @@ public function resolve(?array $args = null): ?object } $this->isResolving = true; + // resolve arguments only allowed for non singletons + if ($args !== null && $this->type === BindingType::Singleton) { + throw new ResolveException("Ioc get only allow the second argument for multiple bindings!"); + } + // if it's a singleton, resolve object only once if ($this->object !== null && $this->type === BindingType::Singleton) { return $this->object; diff --git a/src/Ioc.php b/src/Ioc.php index ad4c2ed..75c1387 100644 --- a/src/Ioc.php +++ b/src/Ioc.php @@ -133,9 +133,6 @@ public function resolve(string $name, ?array $args = null): ?object throw new ResolveException("Binding \"{$name}\" not found!"); } $binding = $this->bindings[$name]; - if ($args !== null && $binding->type === BindingType::Singleton) { - throw new ResolveException("Ioc get only allow the second argument for multiple bindings!"); - } return $binding->resolve($args); } catch (\Exception $ex) { throw new ResolveException("Ioc: Can't resolve '$name' (".$ex->getMessage().")");