Completed
Push — master ( a13c2f...df1c7f )
by Kamil
9s
created

PhpcrContext::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Tests\Lakion\SyliusCmsBundle\Behat\Context\Hook;
4
5
use Behat\Behat\Context\Context;
6
use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
7
use Doctrine\Common\DataFixtures\Purger\PHPCRPurger;
8
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
9
10
final class PhpcrContext implements Context
11
{
12
    /**
13
     * @var DocumentManagerInterface
14
     */
15
    private $documentManager;
16
17
    /**
18
     * @var InitializerManager
19
     */
20
    private $initializerManager;
21
22
    /**
23
     * @param DocumentManagerInterface $documentManager
24
     * @param InitializerManager $initializerManager
25
     */
26
    public function __construct(DocumentManagerInterface $documentManager, InitializerManager $initializerManager)
27
    {
28
        $this->documentManager = $documentManager;
29
        $this->initializerManager = $initializerManager;
30
    }
31
32
    /**
33
     * @BeforeScenario
34
     */
35
    public function purgeAndInitializeDatabase()
36
    {
37
        $purger = new PHPCRPurger($this->documentManager);
0 ignored issues
show
Documentation introduced by
$this->documentManager is of type object<Doctrine\ODM\PHPC...cumentManagerInterface>, but the function expects a null|object<Doctrine\ODM\PHPCR\DocumentManager>.

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...
38
        $purger->purge();
39
40
        $this->documentManager->clear();
41
42
        $this->initializerManager->initialize();
43
    }
44
}
45