Test Failed
Push — master ( 16c39a...9c7d46 )
by Kirill
07:07
created

Argument::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 6
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\Frontend\Record;
11
12
use Railt\SDL\Frontend\Context\ContextInterface;
13
use Railt\SDL\Frontend\Type\TypeInterface;
14
15
/**
16
 * Class Argument
17
 */
18
class Argument implements ArgumentInterface, \JsonSerializable
19
{
20
    /**
21
     * @var string
22
     */
23
    private $name;
24
25
    /**
26
     * @var TypeInterface
27
     */
28
    private $type;
29
30
    /**
31
     * @var ContextInterface
32
     */
33
    private $context;
34
35
    /**
36
     * Argument constructor.
37
     * @param string $name
38
     * @param TypeInterface $type
39
     * @param ContextInterface $context
40
     */
41
    public function __construct(string $name, TypeInterface $type, ContextInterface $context)
42
    {
43
        $this->name = $name;
44
        $this->type = $type;
45
        $this->context = $context->current();
0 ignored issues
show
Documentation Bug introduced by
It seems like $context->current() of type object<Railt\SDL\Frontend\Type\TypeNameInterface> is incompatible with the declared type object<Railt\SDL\Fronten...ntext\ContextInterface> of property $context.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getName(): string
52
    {
53
        return $this->name;
54
    }
55
56
    /**
57
     * @return TypeInterface
58
     */
59
    public function getType(): TypeInterface
60
    {
61
        return $this->type;
62
    }
63
64
    /**
65
     * @return array
66
     */
67
    public function jsonSerialize(): array
68
    {
69
        return [
70
            'name' => $this->name,
71
            'type' => $this->type->getName(),
72
            'ctx'  => $this->context,
73
        ];
74
    }
75
}
76