Issues (8)

src/Mixins/ContainerAccess.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace PHPKitchen\DI\Mixins;
4
5
use PHPKitchen\DI\Contracts\Container;
6
7
/**
8
 * Injects DI container to target class.
9
 *
10
 * @property Container $container public alias of {@link _diContainer}
11
 *
12
 * @package PHPKitchen\DI\mixins
13
 * @author Dmitry Kolodko <[email protected]>
14
 */
15
trait ContainerAccess {
16
    /**
17
     * @var Container
18
     */
19
    protected $_container;
20
21
    public function getContainer() {
22
        if (!isset($this->_container)) {
23
            $this->initContainer();
24
        }
25
26
        return $this->_container;
27
    }
28
29
    public function setContainer(Container $container) {
30
        $this->_container = $container;
31
    }
32
33
    protected function initContainer() {
34
        $this->setContainer(\Yii::$container);
0 ignored issues
show
Yii::container of type yii\di\Container is incompatible with the type PHPKitchen\DI\Contracts\Container expected by parameter $container of PHPKitchen\DI\Mixins\Con...rAccess::setContainer(). ( Ignorable by Annotation )

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

34
        $this->setContainer(/** @scrutinizer ignore-type */ \Yii::$container);
Loading history...
35
    }
36
}