CommandsProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\QueryRepository;
6
7
use Ray\Di\ProviderInterface;
8
9
/** @implements ProviderInterface<array<CommandInterface>> */
10
final class CommandsProvider implements ProviderInterface
11
{
12
    public function __construct(
13
        private readonly RefreshSameCommand $refreshSameCommand,
14
        private readonly RefreshAnnotatedCommand $refreshAnnotatedCommand,
15
    ) {
16
    }
17
18
    /**
19
     * {@inheritDoc}
20
     */
21
    public function get()
22 13
    {
23
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array($this->refr...efreshAnnotatedCommand) returns the type array<integer,BEAR\Query...ory\RefreshSameCommand> which is incompatible with the return type mandated by Ray\Di\ProviderInterface::get() of Ray\Di\T.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
24
            $this->refreshSameCommand,
25
            $this->refreshAnnotatedCommand,
26 13
        ];
27 13
    }
28
}
29