Issues (166)

src/Framework/ConfigResolverAwareTrait.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework;
6
7
use Gacela\Framework\ClassResolver\Config\ConfigResolver;
8
9
/**
10
 * @template TConfig of AbstractConfig
11
 */
12
trait ConfigResolverAwareTrait
13 33
{
14
    /** @var TConfig|null */
15 33
    private ?AbstractConfig $config = null;
16 24
17
    /**
18
     * @return TConfig
19 33
     */
20
    public function getConfig(): AbstractConfig
21
    {
22
        if ($this->config === null) {
23
            $resolved = (new ConfigResolver())->resolve($this);
24
            /** @var TConfig $resolved */
25
            $this->config = $resolved;
26
        }
27
28
        return $this->config;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->config could return the type null which is incompatible with the type-hinted return Gacela\Framework\AbstractConfig. Consider adding an additional type-check to rule them out.
Loading history...
29
    }
30
}
31