Completed
Push — master ( 5072ee...8ba455 )
by WEBEWEB
07:23
created

Extension/Utility/AbstractUtilityTwigExtension.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the bootstrap-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\BootstrapBundle\Twig\Extension\Utility;
13
14
use Symfony\Component\Translation\TranslatorInterface;
15
use Twig\Environment;
16
use WBW\Bundle\BootstrapBundle\Twig\Extension\AbstractTwigExtension;
17
use WBW\Bundle\CoreBundle\Service\TranslatorTrait;
18
19
/**
20
 * Abstract utility Twig extension.
21
 *
22
 * @author webeweb <https://github.com/webeweb/>
23
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Utility
24
 * @abstract
25
 */
26
abstract class AbstractUtilityTwigExtension extends AbstractTwigExtension {
27
28
    use TranslatorTrait;
29
30
    /**
31
     * Constructor.
32
     *
33
     * @param Environment $twigEnvironment The Twig environment.
34
     * @param TranslatorInterface $translator The translator.
35
     */
36
    public function __construct(Environment $twigEnvironment, TranslatorInterface $translator) {
37
        parent::__construct($twigEnvironment);
38
        $this->setTranslator($translator);
0 ignored issues
show
$translator is of type object<Symfony\Component...on\TranslatorInterface>, but the function expects a null|object<WBW\Bundle\C...aseTranslatorInterface>.

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...
39
    }
40
}
41