1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Ray\Di; |
||
6 | |||
7 | use Ray\Aop\ReflectionClass; |
||
8 | |||
9 | final class Untarget |
||
10 | { |
||
11 | /** |
||
12 | * @phpstan-var ReflectionClass<object> |
||
13 | * @psalm-var ReflectionClass |
||
14 | */ |
||
15 | private $class; |
||
16 | |||
17 | /** @var string */ |
||
18 | private $scope = Scope::PROTOTYPE; |
||
19 | |||
20 | /** |
||
21 | * @param class-string $class |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
22 | */ |
||
23 | public function __construct(string $class) |
||
24 | { |
||
25 | $this->class = new ReflectionClass($class); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Bind untargeted binding |
||
30 | */ |
||
31 | public function __invoke(Container $container, Bind $bind): void |
||
32 | { |
||
33 | $bound = (new DependencyFactory())->newAnnotatedDependency($this->class); |
||
34 | $bound->setScope($this->scope); |
||
35 | $bind->setBound($bound); |
||
36 | $container->add($bind); |
||
37 | } |
||
38 | |||
39 | public function setScope(string $scope): void |
||
40 | { |
||
41 | $this->scope = $scope; |
||
42 | } |
||
43 | } |
||
44 |