Issues (20)

src/TAU/Common/ContainerExt.php (1 issue)

Severity
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
The call to League\Container\Container::has() has too many arguments starting with $concrete. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        if( $this->/** @scrutinizer ignore-call */ has($id, $concrete) ) // Replace concrete if id exists

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.

Loading history...
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