ExpressionLanguage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A registerProviders() 0 6 2
1
<?php
2
3
4
namespace SmartWeb\ModuleTesting\ExpressionLanguage;
5
6
use Psr\Cache\CacheItemPoolInterface;
7
use SmartWeb\ModuleTesting\ExpressionLanguage\Providers\PhpExpressionLanguageProvider;
8
use SmartWeb\ModuleTesting\ExpressionLanguage\Providers\StringExpressionLanguageProvider;
9
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
10
use Symfony\Component\ExpressionLanguage\ExpressionLanguage as BaseExpressionLanguage;
11
use function resolve;
12
13
14
/**
15
 * Class ExpressionLanguage
16
 *
17
 * @package SmartWeb\ModuleTesting\ExpressionLanguage
18
 */
19
class ExpressionLanguage extends BaseExpressionLanguage
20
{
21
    
22
    /**
23
     * @param CacheItemPoolInterface                $cache
24
     * @param ExpressionFunctionProviderInterface[] $providers
25
     */
26
    public function __construct($cache = null, array $providers = [])
27
    {
28
        parent::__construct($cache, $providers);
29
        
30
        $this->registerProviders(
31
            resolve(StringExpressionLanguageProvider::class),
32
            resolve(PhpExpressionLanguageProvider::class)
33
        );
34
    }
35
    
36
    /**
37
     * @param ExpressionFunctionProviderInterface[] ...$providers
38
     */
39
    public function registerProviders(...$providers)
40
    {
41
        foreach ($providers as $provider) {
42
            $this->registerProvider($provider);
0 ignored issues
show
Documentation introduced by
$provider is of type array<integer,object<Sym...tionProviderInterface>>, but the function expects a object<Symfony\Component...ctionProviderInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43
        }
44
    }
45
}
46