Skip to content

Commit

Permalink
fixed exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 13, 2023
1 parent e22a353 commit 355cefb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/DI/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function addDefinition(?string $name, ?Definition $definition = null): De
$name = '0' . $i; // prevents converting to integer in array key

} elseif (is_int(key([$name => 1])) || !preg_match('#^\w+(\.\w+)*$#D', $name)) {
throw new Nette\InvalidArgumentException(sprintf('Service name must be a alpha-numeric string and not a number, %s given.', gettype($name)));
throw new Nette\InvalidArgumentException(sprintf("Service name must be a alpha-numeric string and not a number, '%s' given.", $name));

} else {
$name = $this->aliases[$name] ?? $name;
Expand Down Expand Up @@ -176,10 +176,10 @@ public function hasDefinition(string $name): bool
public function addAlias(string $alias, string $service): void
{
if (!$alias) { // builder is not ready for falsy names such as '0'
throw new Nette\InvalidArgumentException(sprintf('Alias name must be a non-empty string, %s given.', gettype($alias)));
throw new Nette\InvalidArgumentException(sprintf("Alias name must be a non-empty string, '%s' given.", $alias));

} elseif (!$service) { // builder is not ready for falsy names such as '0'
throw new Nette\InvalidArgumentException(sprintf('Service name must be a non-empty string, %s given.', gettype($service)));
throw new Nette\InvalidArgumentException(sprintf("Service name must be a non-empty string, '%s' given.", $service));

} elseif (isset($this->aliases[$alias])) {
throw new Nette\InvalidStateException(sprintf("Alias '%s' has already been added.", $alias));
Expand Down

0 comments on commit 355cefb

Please sign in to comment.