1 | <?php |
||
17 | class ServiceProvider extends \PEIP\Service\ServiceContainer |
||
18 | { |
||
19 | const |
||
20 | /* Headers */ |
||
21 | HEADER_KEY = 'KEY', |
||
22 | HEADER_SERVICE = 'SERVICE', |
||
23 | HEADER_MESSAGE = 'MESSAGE', |
||
24 | HEADER_NODE = 'NODE', |
||
25 | HEADER_NODE_CONFIG = 'NODE_CONFIG', |
||
26 | HEADER_NODE_NAME = 'NODE_NAME', |
||
27 | HEADER_NODE_ID = 'NODE_ID', |
||
28 | HEADER_COUNT_CONFIG = 'COUNT_CONFIG', |
||
29 | /* Events */ |
||
30 | EVENT_BEFORE_BUILD_NODE = 'before_build_node', |
||
31 | EVENT_BUILD_NODE_SUCCESS = 'success_build_node', |
||
32 | EVENT_BUILD_NODE_ERROR = 'error_build_node', |
||
33 | EVENT_BEFORE_ADD_CONFIG = 'before_add_config', |
||
34 | EVENT_AFTER_ADD_CONFIG = 'after_add_config', |
||
35 | EVENT_BEFORE_PROVIDE_SERVICE = 'before_provide_service', |
||
36 | EVENT_AFTER_PROVIDE_SERVICE = 'after_provide_service', |
||
37 | EVENT_BEFORE_CREATE_SERVICE = 'before_create_service', |
||
38 | EVENT_CREATE_SERVICE_SUCCESS = 'success_create_service', |
||
39 | EVENT_CREATE_SERVICE_ERROR = 'error_create_service'; |
||
40 | |||
41 | protected $config = [], |
||
42 | $ids = [], |
||
43 | $nodeBuilders = [], |
||
44 | $idAttribute; |
||
45 | |||
46 | public function __construct(array $config = [], $idAttribute = 'id') |
||
54 | |||
55 | /** |
||
56 | * returns all registered services. |
||
57 | * |
||
58 | * @return array registered services |
||
59 | */ |
||
60 | public function getServices() |
||
64 | |||
65 | /** |
||
66 | * Registers a callable as builder for given node-name. |
||
67 | * |
||
68 | * @implements \PEIP\INF\Context\Context |
||
69 | * |
||
70 | * @param string $nodeName the name of the node |
||
71 | * @param callable $callable a callable which creates instances for node-name |
||
72 | */ |
||
73 | public function registerNodeBuilder($nodeName, $callable) |
||
77 | |||
78 | /** |
||
79 | * Registers the build-methods for the main-components with this context. |
||
80 | * Note: This method and subsequent registered methods of this class are |
||
81 | * candidates for refactoring. Because this class has grown much to large |
||
82 | * and for better design and flexibility the core builder-methods should be |
||
83 | * put into a core context-plugin. |
||
84 | * |
||
85 | * @see XMLContext::includeContext |
||
86 | */ |
||
87 | protected function initNodeBuilders() |
||
96 | |||
97 | public function addConfig($config) |
||
116 | |||
117 | public function provideService($key) |
||
136 | |||
137 | protected function createService($key) |
||
169 | |||
170 | public function getServiceConfig($key) |
||
178 | |||
179 | /** |
||
180 | * Builds a specific configuration-node. Calls the build-method which |
||
181 | * is registered with the node-name. If none is registered does nothing. |
||
182 | * |
||
183 | * @param object $config configuration-node |
||
184 | * |
||
185 | * @return void |
||
186 | */ |
||
187 | protected function buildNode($config) |
||
219 | |||
220 | protected function getIdFromConfig($config) |
||
229 | |||
230 | protected function getCountConfig() |
||
234 | |||
235 | protected function doAddConfig($config) |
||
242 | |||
243 | protected function doRegisterConfig($config) |
||
252 | } |
||
253 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.