Skip to content

Commit

Permalink
Update Container.php
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Oct 4, 2022
1 parent ac91890 commit 3acaa85
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function build(string $class, array $arguments = []): object
$reflectionClass = $reflectionMethod->getDeclaringClass();
$class = $reflectionClass instanceof ReflectionClass ?
$reflectionClass->getName() : '';
$method = $reflectionMethod->getName();
$name = $reflectionMethod->getName();

$isFunction = '' === $class;

Expand All @@ -227,8 +227,8 @@ public function build(string $class, array $arguments = []): object
'Unresolvable %s parameter "$%s" in "%s%s"; does not have a default value.',
$isFunction ? 'function' : 'class',
$parameterName,
$isFunction ? $method : $class,
$isFunction ? '()' : '::' . $method
$isFunction ? $name : $class,
$isFunction ? '()' : '::' . $name
)
);
}
Expand Down Expand Up @@ -256,11 +256,7 @@ public function extend(string $class, callable $extension): void
$factories = $this->services[self::FACTORIES];
$extensions = $this->services[self::EXTENSIONS];

if (
! array_key_exists($class, $extensions)
&& ! array_key_exists($class, $factories)
&& ! class_exists($class)
) {
if (! array_key_exists($class, $extensions) && ! array_key_exists($class, $factories) && ! class_exists($class)) {
throw new ServiceNotFoundException($class);
}

Expand Down Expand Up @@ -355,7 +351,7 @@ function (array $parameters, ReflectionParameter $reflectionParameter) use ($arg
$reflectionClass = $reflectionParameter->getDeclaringClass();
$class = $reflectionClass instanceof ReflectionClass ?
$reflectionClass->getName() : '';
$method = $reflectionParameter->getDeclaringFunction()
$name = $reflectionParameter->getDeclaringFunction()
->getName();

$isFunction = '' === $class;
Expand All @@ -365,8 +361,8 @@ function (array $parameters, ReflectionParameter $reflectionParameter) use ($arg
'Unresolvable %s parameter "$%s" in "%s%s"; does not have a default value.',
$isFunction ? 'function' : 'class',
$parameterName,
$isFunction ? $method : $class,
$isFunction ? '()' : '::' . $method
$isFunction ? $name : $class,
$isFunction ? '()' : '::' . $name
)
);
}
Expand Down

0 comments on commit 3acaa85

Please sign in to comment.