File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ declare (strict_types=1 );
4
+
3
5
namespace Webdevcave \Yadic ;
4
6
5
7
use Closure ;
@@ -49,14 +51,15 @@ public function __construct(CacheInterface $cache = null)
49
51
*
50
52
* @template T
51
53
*
52
- * @param T $id Identifier of the entry to look for.
54
+ * @param T $id Identifier of the entry to look for.
55
+ * @param array $arguments Predefined arguments.
53
56
*
54
57
* @throws NotFoundExceptionInterface No entry was found for **this** identifier.
55
58
* @throws ContainerExceptionInterface Error while retrieving the entry.
56
59
*
57
60
* @return T
58
61
*/
59
- public function get (string $ id ): mixed
62
+ public function get (string $ id, array $ arguments = [] ): mixed
60
63
{
61
64
if (isset ($ this ->singletons [$ id ])) {
62
65
return $ this ->singletons [$ id ];
@@ -69,10 +72,9 @@ public function get(string $id): mixed
69
72
try {
70
73
$ className = $ this ->aliases [$ id ] ?? $ id ;
71
74
$ reflectionClass = new ReflectionClass ($ className );
72
- $ arguments = [];
73
75
74
76
if ($ constructor = $ reflectionClass ->getConstructor ()) {
75
- $ arguments = $ this ->createArguments ($ constructor );
77
+ $ arguments = $ this ->createArguments ($ constructor, $ arguments );
76
78
}
77
79
78
80
$ instance = $ reflectionClass ->newInstanceArgs ($ arguments );
You can’t perform that action at this time.
0 commit comments