Passed
Push — master ( 81686d...1595cb )
by Kirill
04:41
created

ArgumentNode   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of Railt package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Railt\SDL\Frontend\Ast\Executable;
13
14
use Railt\SDL\Frontend\Ast\DefinitionNode;
15
use Railt\SDL\Frontend\Ast\Identifier;
16
use Railt\SDL\Frontend\Ast\Node;
17
use Railt\TypeSystem\Value\ValueInterface;
18
19
/**
20
 * Class ArgumentNode
21
 *
22
 * <code>
23
 *  export interface ArgumentNode {
24
 *      readonly kind: 'Argument';
25
 *      readonly loc?: Location;
26
 *      readonly name: IdentifierNode;
27
 *      readonly value: ValueNode;
28
 *  }
29
 * </code>
30
 */
31
class ArgumentNode extends DefinitionNode
32
{
33
    /**
34
     * @var Identifier
35
     */
36
    public Identifier $name;
37
38
    /**
39
     * @var ValueInterface
40
     */
41
    public ValueInterface $value;
42
43
    /**
44
     * ArgumentNode constructor.
45
     *
46
     * @param Identifier $name
47
     * @param ValueInterface $value
48
     */
49
    public function __construct(Identifier $name, ValueInterface $value)
50
    {
51
        $this->name = $name;
52
        $this->value = $value;
53
    }
54
55
    /**
56
     * @param array|Node[] $children
57
     * @return static
58
     */
59
    public static function create(array $children): self
60
    {
61
        return new static(...$children);
0 ignored issues
show
Bug introduced by
The call to Railt\SDL\Frontend\Ast\E...mentNode::__construct() has too few arguments starting with value. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

61
        return /** @scrutinizer ignore-call */ new static(...$children);

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
62
    }
63
}
64