ShiftReduce::state()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of PHP-Yacc 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 PhpYacc\Lalr\Conflict;
11
12
use PhpYacc\Grammar\State;
13
use PhpYacc\Grammar\Symbol;
14
use PhpYacc\Lalr\Conflict;
15
16
/**
17
 * Class ShiftReduce.
18
 */
19
class ShiftReduce extends Conflict
20
{
21
    /**
22
     * @var State
23
     */
24
    protected $state;
25
26
    /**
27
     * @var int
28
     */
29
    protected $reduce;
30
31
    /**
32
     * ShiftReduce constructor.
33
     *
34
     * @param State         $state
35
     * @param int           $reduce
36
     * @param Symbol        $symbol
37
     * @param Conflict|null $next
38
     */
39
    public function __construct(State $state, int $reduce, Symbol $symbol, Conflict $next = null)
40
    {
41
        $this->state = $state;
42
        $this->reduce = $reduce;
43
        parent::__construct($symbol, $next);
0 ignored issues
show
Bug introduced by
It seems like $next defined by parameter $next on line 39 can also be of type object<PhpYacc\Lalr\Conflict>; however, PhpYacc\Lalr\Conflict::__construct() does only seem to accept null|object<self>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and 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...
44
    }
45
46
    /**
47
     * @return bool
48
     */
49
    public function isShiftReduce(): bool
50
    {
51
        return true;
52
    }
53
54
    /**
55
     * @return State
56
     */
57
    public function state(): State
58
    {
59
        return $this->state;
60
    }
61
62
    /**
63
     * @return int
64
     */
65
    public function reduce(): int
66
    {
67
        return $this->reduce;
68
    }
69
}
70