1 | <?php |
||
21 | trait ServicesTrait |
||
22 | { |
||
23 | /** |
||
24 | * @var ServiceManager |
||
25 | */ |
||
26 | private $services; |
||
27 | |||
28 | /** |
||
29 | * @return ServiceManager |
||
30 | */ |
||
31 | public function getServices() |
||
35 | |||
36 | /** |
||
37 | * Return registered service |
||
38 | * |
||
39 | * @param string $service Service name |
||
40 | * @return mixed |
||
41 | * @throws Exception\UnknownServiceException |
||
42 | */ |
||
43 | public function get($service) |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | public function set($service, $factory = null) |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function has($service) |
||
92 | |||
93 | /** |
||
94 | * Require service from services into application |
||
95 | * |
||
96 | * @param string $service Service name |
||
97 | * @throws Exception\DomainException Unable to get service |
||
98 | */ |
||
99 | protected function requireService($service) |
||
107 | |||
108 | /** |
||
109 | * Set optional service from services into application |
||
110 | * |
||
111 | * @param string $service Service name |
||
112 | */ |
||
113 | protected function optionalService($service) |
||
117 | |||
118 | /** |
||
119 | * @param $service |
||
120 | */ |
||
121 | private function setService($service) |
||
125 | |||
126 | /** |
||
127 | * @param string $name |
||
128 | * @param mixed $service |
||
129 | */ |
||
130 | protected function setServicesService($name, $service) |
||
137 | } |
||
138 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.