Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| SyntaxError | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| jsonSerialize | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Wikimedia\WikiPEG; |
| 4 | |
| 5 | class SyntaxError extends \Exception implements \JsonSerializable { |
| 6 | public array $expected; |
| 7 | public ?string $found; |
| 8 | public LocationRange $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, ?string $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 | } |