1 | <?php |
||
9 | final class NewInstance |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $class; |
||
15 | |||
16 | /** |
||
17 | * @var SetterMethods |
||
18 | */ |
||
19 | private $setterMethods; |
||
20 | |||
21 | /** |
||
22 | * @var null|Arguments |
||
23 | */ |
||
24 | private $arguments; |
||
25 | |||
26 | /** |
||
27 | * @var AspectBind |
||
28 | */ |
||
29 | private $bind; |
||
30 | |||
31 | public function __construct( |
||
44 | |||
45 | /** |
||
46 | * @throws \ReflectionException |
||
47 | */ |
||
48 | public function __invoke(Container $container) |
||
49 | { |
||
50 | $instance = $this->arguments instanceof Arguments ? (new \ReflectionClass($this->class))->newInstanceArgs($this->arguments->inject($container)) : new $this->class; |
||
51 | |||
52 | return $this->postNewInstance($container, $instance); |
||
53 | |||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @return string |
||
58 | */ |
||
59 | public function __toString() |
||
60 | { |
||
61 | return $this->class; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @throws \ReflectionException |
||
66 | */ |
||
67 | public function newInstanceArgs(Container $container, array $params) |
||
68 | { |
||
69 | $instance = (new \ReflectionClass($this->class))->newInstanceArgs($params); |
||
70 | |||
71 | return $this->postNewInstance($container, $instance); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @param string $class |
||
76 | */ |
||
77 | public function weaveAspects($class, AopBind $bind) |
||
82 | |||
83 | private function postNewInstance(Container $container, $instance) |
||
84 | { |
||
85 | // setter injection |
||
95 | } |
||
96 |