-
-
Notifications
You must be signed in to change notification settings - Fork 312
/
Class1.php
119 lines (98 loc) · 2.27 KB
/
Class1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* PHP-DI
*
* @link http://mnapoli.github.io/PHP-DI/
* @copyright Matthieu Napoli (http://mnapoli.fr/)
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
*/
namespace IntegrationTests\DI\Fixtures;
use DI\Annotation\Inject;
use DI\Annotation\Injectable;
/**
* Fixture class
* @Injectable(scope="prototype")
*/
class Class1
{
/**
* @Inject
* @var Class2
*/
public $property1;
/**
* @Inject
* @var Interface1
*/
public $property2;
/**
* @Inject("namedDependency")
*/
public $property3;
/**
* @Inject(name="foo")
*/
public $property4;
/**
* @Inject(lazy=true)
* @var LazyDependency
*/
public $property5;
public $constructorParam1;
public $constructorParam2;
public $method1Param1;
public $method2Param1;
public $method3Param1;
public $method3Param2;
public $method4Param1;
/**
* @param Class2 $param1
* @param Interface1 $param2
* @throws \Exception
*/
public function __construct(Class2 $param1, Interface1 $param2, $optional = true)
{
$this->constructorParam1 = $param1;
$this->constructorParam2 = $param2;
if ($optional !== true) {
throw new \Exception("Expected optional parameter to not be defined");
}
}
/**
* @Inject
* @param Class2 $param1
* @throws \Exception
*/
public function method1(Class2 $param1, $optional = true)
{
$this->method1Param1 = $param1;
if ($optional !== true) {
throw new \Exception("Expected optional parameter to not be defined");
}
}
/**
* @Inject
* @param Interface1 $param1
*/
public function method2(Interface1 $param1)
{
$this->method2Param1 = $param1;
}
/**
* @Inject({"namedDependency", "foo"})
* @param string $param1
*/
public function method3($param1, $param2)
{
$this->method3Param1 = $param1;
$this->method3Param2 = $param2;
}
/**
* @Inject({"param1" = {"lazy" = true}})
* @param string $param1
*/
public function method4(LazyDependency $param1)
{
$this->method4Param1 = $param1;
}
}