proyectotau /
TAUonDDD
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ProyectoTAU\TAU\Common; |
||
| 4 | |||
| 5 | use League\Container\Definition\DefinitionAggregateInterface; |
||
| 6 | use League\Container\Definition\DefinitionInterface; |
||
| 7 | use League\Container\Inflector\InflectorAggregateInterface; |
||
| 8 | use League\Container\ServiceProvider\ServiceProviderAggregateInterface; |
||
| 9 | |||
| 10 | class ContainerExt extends \League\Container\Container |
||
| 11 | { |
||
| 12 | |||
| 13 | public function __construct( |
||
| 14 | DefinitionAggregateInterface $definitions = null, |
||
| 15 | ServiceProviderAggregateInterface $providers = null, |
||
| 16 | InflectorAggregateInterface $inflectors = null |
||
| 17 | ) |
||
| 18 | { |
||
| 19 | parent::__construct($definitions, $providers, $inflectors); |
||
| 20 | } |
||
| 21 | |||
| 22 | 76 | public function add(string $id, $concrete = null): DefinitionInterface |
|
| 23 | { |
||
| 24 | // \ProyectoTAU\TAU\Common\Logger::debug("$id ".var_export($concrete, true)); |
||
| 25 | |||
| 26 | 76 | if( $this->has($id, $concrete) ) // Replace concrete if id exists |
|
|
0 ignored issues
–
show
|
|||
| 27 | { |
||
| 28 | 76 | $definition = $this->extend($id); |
|
| 29 | 76 | $definition->setConcrete($concrete); |
|
| 30 | 76 | return $definition; |
|
| 31 | |||
| 32 | } |
||
| 33 | |||
| 34 | 36 | return parent::add($id, $concrete); |
|
| 35 | } |
||
| 36 | } |
||
| 37 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.