Debian Codegraph @

vendor/wikimedia/wikipeg/src/SyntaxError.php

raw
1 <?php
2
3 namespace Wikimedia\WikiPEG;
4
5 class 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 }