CommandsProvider::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
ccs 0
cts 0
cp 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\QueryRepository;
6
7
use Override;
8
use Ray\Di\ProviderInterface;
9
10
/** @implements ProviderInterface<array<CommandInterface>> */
11
final class CommandsProvider implements ProviderInterface
12
{
13
    public function __construct(
14
        private readonly RefreshSameCommand $refreshSameCommand,
15
        private readonly RefreshAnnotatedCommand $refreshAnnotatedCommand,
16
    ) {
17
    }
18
19
    /**
20
     * {@inheritDoc}
21
     */
22
    #[Override]
23
    public function get()
24
    {
25
        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...
26
            $this->refreshSameCommand,
27
            $this->refreshAnnotatedCommand,
28
        ];
29
    }
30
}
31