Passed
Push — master ( ee28da...1c3e2f )
by Alexander
14:20 queued 13:06
created

FakeGenerator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Yiisoft\Yii\Cycle\Tests\Generator\Stub;
4
5
use Cycle\Schema\GeneratorInterface;
6
use Cycle\Schema\Registry;
7
8
class FakeGenerator implements GeneratorInterface
9
{
10
    private string $originClass;
11
12
    public function __construct(string $originClass)
13
    {
14
        $this->originClass = $originClass;
15
    }
16
17
    public function run(Registry $registry): Registry
18
    {
19
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Cycle\Schema\Registry. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
20
21
    public function originClass(): string
22
    {
23
        return $this->originClass;
24
    }
25
}
26