Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
SyntaxError
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 jsonSerialize
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2declare( strict_types = 1 );
3
4namespace Wikimedia\WikiPEG;
5
6class SyntaxError extends \Exception implements \JsonSerializable {
7    public array $expected;
8    public ?string $found;
9    public LocationRange $location;
10
11    /**
12     * @param string $message
13     * @param Expectation[] $expected
14     * @param string|null $found
15     * @param LocationRange $location
16     */
17    public function __construct( string $message, array $expected, ?string $found, LocationRange $location ) {
18        parent::__construct( $message );
19        $this->expected = $expected;
20        $this->found    = $found;
21        $this->location = $location;
22    }
23
24    /**
25     * JSON serialization similar to the JavaScript SyntaxError, for testing
26     * @return array
27     */
28    #[\ReturnTypeWillChange]
29    public function jsonSerialize(): array {
30        return [
31            'name' => 'SyntaxError',
32            'message' => $this->message,
33            'expected' => $this->expected,
34            'found' => $this->found,
35            'location' => $this->location
36        ];
37    }
38}