Test Failed
Push — master ( 6bac61...6350a6 )
by Kirill
03:02
created

AbstractContext::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\SDL\Backend\Context;
11
12
use Railt\Reflection\Contracts\Definition\TypeDefinition;
13
14
/**
15
 * Class AbstractContext
16
 */
17
abstract class AbstractContext implements ContextInterface
18
{
19
    /**
20
     * @var array|LocalContext[]
21
     */
22
    protected $types = [];
23
24
    /**
25
     * @param TypeDefinition $type
26
     * @return ContextInterface|LocalContext
27
     */
28
    public function create(TypeDefinition $type): ContextInterface
29
    {
30
        \assert($this instanceof LocalContextInterface);
31
32
        return $this->types[$type->getName()] = new LocalContext($this, $type);
0 ignored issues
show
Documentation introduced by
$this is of type this<Railt\SDL\Backend\Context\AbstractContext>, but the function expects a object<Railt\SDL\Backend...\LocalContextInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
    }
34
35
    /**
36
     * @param string $type
37
     * @return bool
38
     */
39
    protected function has(string $type): bool
40
    {
41
        return isset($this->types[$type]);
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    abstract public function __toString(): string;
48
}
49