EngineAsArgumentControllerTest::testCanBeCreated()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Symfony-Util package.
5
 *
6
 * (c) Jean-Bernard Addor
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
use PHPUnit\Framework\TestCase;
13
use Symfony\Bridge\Twig\TwigEngine;
14
use Symfony\Component\HttpFoundation\Response;
15
use Symfony\Component\Templating\TemplateNameParser;
16
use SymfonyUtil\Controller\EngineAsArgumentController;
17
18
/**
19
 * @covers \SymfonyUtil\Controller\EngineAsArgumentController
20
 */
21
final class EngineAsArgumentControllerTest extends TestCase
22
{
23
    public function testCanBeCreated()
24
    {
25
        $this->assertInstanceOf(
26
            EngineAsArgumentController::class, // 5.4 < php
27
            new EngineAsArgumentController()
28
        );
29
    }
30
31
    public function testReturnsResponse()
32
    {
33
        $this->assertInstanceOf(
34
            Response::class, // 5.4 < php
35
            (new EngineAsArgumentController())->__invoke(new TwigEngine(
36
                new Twig_Environment(new Twig_Loader_Array(['index.html.twig' => 'Hello World!'])),
0 ignored issues
show
Documentation introduced by
new \Twig_Environment(ne...g' => 'Hello World!'))) is of type object<Twig_Environment>, but the function expects a object<Twig\Environment>.

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...
37
                new TemplateNameParser()
38
            ))
39
        );
40
    }
41
}
42
43
// http://api.symfony.com/3.3/Symfony/Bridge/Twig/TwigEngine.html
44
// http://api.symfony.com/3.3/Symfony/Bundle/TwigBundle/TwigEngine.html
45