Skip to content

Commit d780214

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents c7b7912 + ea694ad commit d780214

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/ServiceContainer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Webdevcave\Yadic;
46

57
use Closure;
@@ -49,14 +51,15 @@ public function __construct(CacheInterface $cache = null)
4951
*
5052
* @template T
5153
*
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.
5356
*
5457
* @throws NotFoundExceptionInterface No entry was found for **this** identifier.
5558
* @throws ContainerExceptionInterface Error while retrieving the entry.
5659
*
5760
* @return T
5861
*/
59-
public function get(string $id): mixed
62+
public function get(string $id, array $arguments = []): mixed
6063
{
6164
if (isset($this->singletons[$id])) {
6265
return $this->singletons[$id];
@@ -69,10 +72,9 @@ public function get(string $id): mixed
6972
try {
7073
$className = $this->aliases[$id] ?? $id;
7174
$reflectionClass = new ReflectionClass($className);
72-
$arguments = [];
7375

7476
if ($constructor = $reflectionClass->getConstructor()) {
75-
$arguments = $this->createArguments($constructor);
77+
$arguments = $this->createArguments($constructor, $arguments);
7678
}
7779

7880
$instance = $reflectionClass->newInstanceArgs($arguments);

0 commit comments

Comments
 (0)