1 | <?php |
||
7 | class TypeRegistry |
||
8 | { |
||
9 | /** |
||
10 | * The application instance. |
||
11 | * |
||
12 | * @var \Illuminate\Foundation\Application |
||
13 | */ |
||
14 | protected $app; |
||
15 | |||
16 | /** |
||
17 | * The array of types. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $types = []; |
||
22 | |||
23 | /** |
||
24 | * The array of resolved types. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $instances = []; |
||
29 | |||
30 | /** |
||
31 | * Create a new instance. |
||
32 | * |
||
33 | * @param \Illuminate\Foundation\Application $app |
||
34 | * @param array $types |
||
35 | * @return void |
||
|
|||
36 | */ |
||
37 | public function __construct($app, array $types = []) |
||
45 | |||
46 | /** |
||
47 | * Set type into registry |
||
48 | * |
||
49 | * @param string $class |
||
50 | * @param string $name |
||
51 | */ |
||
52 | public function setType($class, $name = null) |
||
57 | |||
58 | /** |
||
59 | * Resolve type from registry |
||
60 | * |
||
61 | * @param string $type |
||
62 | * @param string $parameters |
||
63 | * @return mixed |
||
64 | * @throws \InvalidArgumentException |
||
65 | */ |
||
66 | protected function resolveType($type, array $parameters) |
||
82 | |||
83 | /** |
||
84 | * Make a new instance of type |
||
85 | * |
||
86 | * @param string $type |
||
87 | * @param string $parameters |
||
88 | * @return mixed |
||
89 | */ |
||
90 | protected function make($type, $parameters) |
||
100 | |||
101 | /** |
||
102 | * Get name from className |
||
103 | * @param string $class |
||
104 | * @param string $name |
||
105 | * @return string |
||
106 | */ |
||
107 | protected function getName($class, $name = null) |
||
123 | |||
124 | /** |
||
125 | * Dynamically call the type instance. |
||
126 | * |
||
127 | * @param string $type |
||
128 | * @param array $parameters |
||
129 | * @return mixed |
||
130 | */ |
||
131 | public function __call($type, $parameters) |
||
135 | } |
||
136 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.