1616
1717final class DependencyResolver
1818{
19- /**
20- * @var ContainerInterface
21- */
22- private $ container ;
19+ private ContainerInterface $ container ;
2320
2421 public function __construct (?ContainerInterface $ container = null )
2522 {
@@ -28,14 +25,14 @@ public function __construct(?ContainerInterface $container = null)
2825
2926 /**
3027 * @param string $className
31- * @return mixed|object|void
28+ * @return mixed
3229 *
3330 * @throws InvalidArgumentException If class does not exist.
3431 * @throws ContainerExceptionInterface If error occurs while retrieving the existing entry from the container.
3532 * @throws ClassCannotBeInstantiated If class cannot be instantiated.
3633 * @throws CannotAutowireDependencyArgument If a dependency (of any nesting level) cannot be resolved.
3734 */
38- public function resolve (string $ className )
35+ public function resolve (string $ className ): mixed
3936 {
4037 if (! class_exists ($ className ) && ! interface_exists ($ className )) {
4138 throw new InvalidArgumentException ("` {$ className }` is not a valid class name. " );
@@ -51,11 +48,12 @@ public function resolve(string $className)
5148 /**
5249 * @param string $className
5350 * @param array $bindings
51+ * @return mixed
5452 *
5553 * @throws ClassCannotBeInstantiated
5654 * @throws CannotAutowireDependencyArgument
5755 */
58- public function construct (string $ className , array $ bindings = [])
56+ public function construct (string $ className , array $ bindings = []): mixed
5957 {
6058 if (! class_exists ($ className ) && ! interface_exists ($ className )) {
6159 throw new InvalidArgumentException ("` {$ className }` is not a valid class name. " );
@@ -84,7 +82,7 @@ public function construct(string $className, array $bindings = [])
8482 * @throws ArgumentCountError
8583 * @throws CannotAutowireArgument
8684 */
87- public function call (callable $ callable , array $ bindings = [])
85+ public function call (callable $ callable , array $ bindings = []): mixed
8886 {
8987 $ reflection = CallableReflection::fromCallable ($ callable );
9088
@@ -130,7 +128,7 @@ private function resolveParameters(array $parameters, array $bindings = []): arr
130128 *
131129 * @throws CannotAutowireArgument
132130 */
133- private function resolveParameter (ParameterReflection $ parameter )
131+ private function resolveParameter (ParameterReflection $ parameter ): mixed
134132 {
135133 foreach ($ parameter ->getTypes () as $ type ) {
136134 if ($ type ->isClassRequirement () && $ this ->container ->has ($ class = $ type ->getClassRequirement ())) {
0 commit comments