| Conditions | 8 |
| Paths | 10 |
| Total Lines | 39 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function process(ContainerBuilder $container) |
||
| 17 | { |
||
| 18 | if (!$container->has('element.provider')) { |
||
| 19 | return; |
||
| 20 | } |
||
| 21 | |||
| 22 | $providerDefinition = $container->findDefinition('element.provider'); |
||
| 23 | |||
| 24 | $elements = []; |
||
| 25 | foreach (array_keys($container->findTaggedServiceIds('element.section')) as $id) { |
||
| 26 | if (!$container->has($id)) { |
||
| 27 | return; |
||
| 28 | } |
||
| 29 | |||
| 30 | $elementDefinition = $container->findDefinition($id); |
||
| 31 | $elementClass = $elementDefinition->getClass(); |
||
|
|
|||
| 32 | |||
| 33 | $reflectionClass = new \ReflectionClass($elementClass); |
||
| 34 | if ($reflectionClass->implementsInterface(RendererAwareInterface::class)) { |
||
| 35 | if (!$container->has('template.renderer')) { |
||
| 36 | return; |
||
| 37 | } |
||
| 38 | |||
| 39 | $elementDefinition->addMethodCall('setRenderer', [new Reference('template.renderer')]); |
||
| 40 | } |
||
| 41 | |||
| 42 | if ($reflectionClass->implementsInterface(DataAwareInterface::class)) { |
||
| 43 | if (!$container->has('data.manager')) { |
||
| 44 | return; |
||
| 45 | } |
||
| 46 | |||
| 47 | $elementDefinition->addMethodCall('setDataManager', [new Reference('data.manager')]); |
||
| 48 | } |
||
| 49 | |||
| 50 | $elements[] = new Reference($id); |
||
| 51 | } |
||
| 52 | |||
| 53 | $providerDefinition->addMethodCall('addElements', [$elements]); |
||
| 54 | } |
||
| 55 | } |
||
| 56 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.