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
2
3namespace Wikimedia\WikiPEG;
4
5class SyntaxError extends \Exception implements \JsonSerializable {
6    public $expected;
7    public $found;
8    public $location;
9
10    /**
11     * @param string $message
12     * @param Expectation[] $expected
13     * @param string|null $found
14     * @param LocationRange $location
15     */
16    public function __construct( string $message, array $expected, $found, LocationRange $location ) {
17        parent::__construct( $message );
18        $this->expected = $expected;
19        $this->found    = $found;
20        $this->location = $location;
21    }
22
23    /**
24     * JSON serialization similar to the JavaScript SyntaxError, for testing
25     * @return array
26     */
27    #[\ReturnTypeWillChange]
28    public function jsonSerialize(): array {
29        return [
30            'name' => 'SyntaxError',
31            'message' => $this->message,
32            'expected' => $this->expected,
33            'found' => $this->found,
34            'location' => $this->location
35        ];
36    }
37}