Skip to content

Commit 30c3c7b

Browse files
committed
Refactor type hints in InstanceContainer, MethodInvoker, and ObjectFactory
1 parent 9c0fccd commit 30c3c7b

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/InstanceContainer.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ interface InstanceContainer {
99
* If no matching class could be found, it must throw an Ioc\Exceptions\DefinitionNotFoundException.
1010
* $className must be an fully qualified class-name.
1111
*
12-
* @param string $className
12+
* @template T of object
13+
* @param class-string<T> $className
1314
* @throws DefinitionNotFoundException
14-
* @return object
15+
* @return T
1516
*/
16-
public function get($className);
17+
public function get(string $className);
1718
}

src/MethodInvoker.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ interface MethodInvoker {
2222
* mixed together. Scalar-types and array-types can not be determined automatically. They must be provided through
2323
* $arguments.
2424
*
25-
* @param callable $callable
26-
* @param array $arguments Must be an array were the keys match to the Variable-Names of the __construct'ors parameters.
27-
* @return mixed
28-
*@throws MissingParameterException
25+
* @template T
26+
* @param callable(mixed ...$args): T $callable
27+
* @param list<mixed> $arguments Must be an array were the keys match to the Variable-Names of the __construct'ors parameters.
28+
* @return T
29+
* @throws MissingParameterException
2930
* @throws DefinitionNotFoundException
3031
*/
31-
public function invoke($callable, array $arguments = array());
32+
public function invoke($callable, array $arguments = []);
3233
}

src/ObjectFactory.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ interface ObjectFactory {
1010
* arguments were missing in $arguments, the method-invoker tries to fill the missing arguments by itself.
1111
* If no matching class could be found, it must throw an Ioc\Exceptions\DefinitionNotFoundException.
1212
*
13-
* @param string $className Must be an fully qualified class-name.
14-
* @param array $arguments Must be an array were the keys match to the Variable-Names of the __construct'ors parameters.
15-
* @return mixed
16-
*@throws MissingParameterException
13+
* @template T of object
14+
* @param class-string<T> $className Must be an fully qualified class-name.
15+
* @param list<mixed> $arguments Must be an array were the keys match to the Variable-Names of the __construct'ors parameters.
16+
* @return T
17+
* @throws MissingParameterException
1718
* @throws DefinitionNotFoundException
1819
*/
19-
public function create($className, array $arguments = array());
20+
public function create(string $className, array $arguments = []);
2021
}

0 commit comments

Comments
 (0)