| Conditions | 5 |
| Paths | 5 |
| Total Lines | 28 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function process(ContainerBuilder $container) |
||
| 27 | { |
||
| 28 | if (!$container->has($this->registryId)) { |
||
| 29 | return; |
||
| 30 | } |
||
| 31 | |||
| 32 | $taggedIds = $container->findTaggedServiceIds($this->serviceTag); |
||
| 33 | $registryDef = $container->getDefinition($this->registryId); |
||
| 34 | |||
| 35 | foreach ($taggedIds as $serviceId => $attributes) { |
||
| 36 | $attributes = $attributes[0]; |
||
| 37 | |||
| 38 | if ($this->registerByAlias) { |
||
| 39 | if (!isset($attributes['alias'])) { |
||
| 40 | throw new InvalidArgumentException(sprintf( |
||
| 41 | $this->context . ' "%s" has no "alias" attribute in its tag', |
||
|
|
|||
| 42 | $serviceId |
||
| 43 | )); |
||
| 44 | } |
||
| 45 | |||
| 46 | $alias = $attributes['alias']; |
||
| 47 | } else { |
||
| 48 | $alias = $container->getDefinition($serviceId)->getClass(); |
||
| 49 | } |
||
| 50 | |||
| 51 | $registryDef->addMethodCall('register', [$alias, new Reference($serviceId)]); |
||
| 52 | } |
||
| 53 | } |
||
| 54 | } |
||
| 55 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: