Test Failed
Push — master ( e081e8...a6938b )
by Kirill
02:31
created

ArgumentDefinitionNode::getType()   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 0
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\Frontend\AST\Dependent;
11
12
use Railt\Reflection\Contracts\TypeInterface;
13
use Railt\Reflection\Type;
14
use Railt\SDL\Frontend\AST\ProvidesTypeHint;
15
use Railt\SDL\Frontend\AST\Support\TypeHintProvider;
16
use Railt\SDL\Frontend\Context;
17
use Railt\SDL\Frontend\IR\Opcode\AddDefinitionOpcode;
18
use Railt\SDL\Frontend\IR\OpcodeInterface;
19
use Railt\SDL\Frontend\IR\Value\StringValue;
20
use Railt\SDL\Frontend\IR\Value\ValueInterface;
21
22
/**
23
 * Class ArgumentDefinitionNode
24
 */
25
class ArgumentDefinitionNode extends DependentTypeDefinitionNode implements ProvidesTypeHint
26
{
27
    use TypeHintProvider;
28
29
    /**
30
     * @return TypeInterface
31
     */
32
    public function getType(): TypeInterface
33
    {
34
        return Type::of(Type::ARGUMENT);
35
    }
36
37
    /**
38
     * @return ValueInterface
39
     */
40
    public function getKey(): ValueInterface
41
    {
42
        return new StringValue($this->getFullName(), $this->getOffset());
43
    }
44
45
    /**
46
     * @param Context $context
47
     * @return iterable|OpcodeInterface[]
48
     */
49 View Code Duplication
    public function getOpcodes(Context $context): iterable
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50
    {
51
        yield from \iterator_each(parent::getOpcodes($context), function($result) {
0 ignored issues
show
Documentation introduced by
parent::getOpcodes($context) is of type object<Generator>, but the function expects a object<iterable>.

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...
52
            if ($result instanceof AddDefinitionOpcode) {
53
                $result->rebind(OpcodeInterface::RL_ADD_ARGUMENT);
54
            }
55
        });
56
    }
57
}
58