ReduceReduce::reduce1()   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\Symbol;
13
use PhpYacc\Lalr\Conflict;
14
15
/**
16
 * Class ReduceReduce.
17
 */
18
class ReduceReduce extends Conflict
19
{
20
    /**
21
     * @var int
22
     */
23
    protected $reduce1;
24
25
    /**
26
     * @var int
27
     */
28
    protected $reduce2;
29
30
    /**
31
     * ReduceReduce constructor.
32
     *
33
     * @param int           $reduce1
34
     * @param int           $reduce2
35
     * @param Symbol        $symbol
36
     * @param Conflict|null $next
37
     */
38
    public function __construct(int $reduce1, int $reduce2, Symbol $symbol, Conflict $next = null)
39
    {
40
        $this->reduce1 = $reduce1;
41
        $this->reduce2 = $reduce2;
42
        parent::__construct($symbol, $next);
0 ignored issues
show
Bug introduced by
It seems like $next defined by parameter $next on line 38 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...
43
    }
44
45
    /**
46
     * @return bool
47
     */
48
    public function isReduceReduce(): bool
49
    {
50
        return true;
51
    }
52
53
    /**
54
     * @return int
55
     */
56
    public function reduce1(): int
57
    {
58
        return $this->reduce1;
59
    }
60
61
    /**
62
     * @return int
63
     */
64
    public function reduce2(): int
65
    {
66
        return $this->reduce2;
67
    }
68
}
69