AbstractParser::err()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * For licensing information, please see the LICENSE file accompanied with this file.
4
 *
5
 * @author Gerard van Helden <[email protected]>
6
 * @copyright 2012 Gerard van Helden <http://melp.nl>
7
 */
8
9
namespace Zicht\Tool\Script;
10
11
/**
12
 * Base class for parsing.
13
 */
14
abstract class AbstractParser implements ParserInterface
15
{
16
    /**
17
     * Constructs the parser with an optional parent parser
18
     *
19
     * @param ParserInterface $parent
20
     */
21 13
    public function __construct(ParserInterface $parent = null)
22
    {
23 13
        $this->parent = $parent;
0 ignored issues
show
Bug introduced by
The property parent does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24 13
    }
25
26
    /**
27
     * Triggers a parse error
28
     *
29
     * @param TokenStream $stream
30
     * @return void
31
     */
32
    final public function err(TokenStream $stream)
33
    {
34
        throw new \UnexpectedValueException(
35
            "Unexpected input near {$stream->current()->value} at offset {$stream->key()}"
36
        );
37
    }
38
}