Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
peterGdot committed Oct 30, 2024
1 parent a617ee4 commit 79ef71c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/Binding.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions src/Ioc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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().")");
Expand Down

0 comments on commit 79ef71c

Please sign in to comment.