Passed
Push — master ( 9676b0...44a032 )
by Anton
02:07
created

src/Promise/Collection/CollectionPromise.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Cycle DataMapper ORM
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
declare(strict_types=1);
9
10
namespace Cycle\ORM\Promise\Collection;
11
12
use Cycle\ORM\Promise\PromiseInterface;
13
use Doctrine\Common\Collections\AbstractLazyCollection;
14
use Doctrine\Common\Collections\ArrayCollection;
15
16
/**
17
 * LazyLoading collection build at top of data promise.
18
 */
19
class CollectionPromise extends AbstractLazyCollection implements CollectionPromiseInterface
20
{
21
    /** @var PromiseInterface */
22
    protected $promise;
23
24
    /**
25
     * @param PromiseInterface $promise
26
     */
27
    public function __construct(PromiseInterface $promise)
28
    {
29
        $this->promise = $promise;
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function getPromise(): PromiseInterface
36
    {
37
        return $this->promise;
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    protected function doInitialize()
44
    {
45
        $this->collection = new ArrayCollection($this->promise->__resolve());
0 ignored issues
show
It seems like $this->promise->__resolve() can also be of type null; however, parameter $elements of Doctrine\Common\Collecti...llection::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

45
        $this->collection = new ArrayCollection(/** @scrutinizer ignore-type */ $this->promise->__resolve());
Loading history...
46
    }
47
}