Completed
Push — master ( b2a65d...63a169 )
by Kirill
02:18
created

NullValueBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A match() 0 4 1
A reduce() 0 4 1
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\Builder\Value;
11
12
use Railt\Parser\Ast\RuleInterface;
13
use Railt\SDL\Frontend\AST\Value\AstValueInterface;
14
use Railt\SDL\Frontend\Builder\BaseBuilder;
15
use Railt\SDL\Frontend\Context\ContextInterface;
16
use Railt\SDL\IR\SymbolTable\Value;
17
use Railt\SDL\IR\Type;
18
19
/**
20
 * Class NullValueBuilder
21
 */
22
class NullValueBuilder extends BaseBuilder
23
{
24
    /**
25
     * @param RuleInterface $rule
26
     * @return bool
27
     */
28
    public function match(RuleInterface $rule): bool
29
    {
30
        return $rule->getName() === 'NullValue';
31
    }
32
33
    /**
34
     * @param ContextInterface $ctx
35
     * @param RuleInterface|AstValueInterface $rule
36
     * @return mixed|Value
37
     */
38
    public function reduce(ContextInterface $ctx, RuleInterface $rule)
39
    {
40
        return new Value(null, Type::null());
0 ignored issues
show
Bug introduced by
It seems like \Railt\SDL\IR\Type::null() targeting Railt\SDL\IR\Type\TypeCo...ypeConstructors::null() can also be of type object<Railt\SDL\IR\Type...untimeTypeConstructors>; however, Railt\SDL\IR\SymbolTable\Value::__construct() does only seem to accept object<Railt\SDL\IR\Type\TypeInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
41
    }
42
}
43