1 | <?php |
||
26 | abstract class AbstractDefinition implements Definition, \JsonSerializable |
||
27 | { |
||
28 | use Jsonable; |
||
29 | use Serializable; |
||
30 | |||
31 | /** |
||
32 | * @var Document |
||
33 | */ |
||
34 | protected $document; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | protected $offset = 0; |
||
40 | |||
41 | /** |
||
42 | * @var int|null |
||
43 | */ |
||
44 | protected $line; |
||
45 | |||
46 | /** |
||
47 | * @var int|null |
||
48 | */ |
||
49 | protected $column; |
||
50 | |||
51 | /** |
||
52 | * AbstractDefinition constructor. |
||
53 | * @param Document $document |
||
54 | */ |
||
55 | 9 | public function __construct(Document $document) |
|
59 | |||
60 | /** |
||
61 | * @param TypeInterface $type |
||
62 | * @return bool |
||
63 | */ |
||
64 | public static function typeOf(TypeInterface $type): bool |
||
68 | |||
69 | /** |
||
70 | * @param int $offset |
||
71 | * @return Definition|TypeDefinition|TypeInvocation|$this |
||
72 | */ |
||
73 | 1 | public function withOffset(int $offset): Definition |
|
79 | |||
80 | /** |
||
81 | * @param int $line |
||
82 | * @return Definition|TypeDefinition|TypeInvocation|$this |
||
83 | */ |
||
84 | 9 | public function withLine(?int $line): Definition |
|
90 | /** |
||
91 | * @param int $column |
||
92 | * @return Definition|TypeDefinition|TypeInvocation|$this |
||
93 | */ |
||
94 | public function withColumn(?int $column): Definition |
||
100 | |||
101 | /** |
||
102 | * @return DocumentInterface |
||
103 | */ |
||
104 | 17 | public function getDocument(): DocumentInterface |
|
108 | |||
109 | /** |
||
110 | * @return int |
||
111 | */ |
||
112 | 65 | public function getLine(): int |
|
120 | |||
121 | /** |
||
122 | * @return Readable |
||
123 | */ |
||
124 | 65 | public function getFile(): Readable |
|
128 | |||
129 | /** |
||
130 | * @return int |
||
131 | */ |
||
132 | 66 | public function getColumn(): int |
|
140 | |||
141 | /** |
||
142 | * @return string |
||
143 | */ |
||
144 | public function __toString(): string |
||
148 | |||
149 | /** |
||
150 | * @param string|TypeDefinition $type |
||
151 | * @return TypeDefinition |
||
152 | * @throws ExternalFileException |
||
153 | */ |
||
154 | 10 | protected function fetch($type): TypeDefinition |
|
167 | |||
168 | /** |
||
169 | * @param string|TypeDefinition|null $type |
||
170 | * @return null|TypeDefinition |
||
171 | * @throws ExternalFileException |
||
172 | */ |
||
173 | protected function fetchOrNull($type): ?TypeDefinition |
||
177 | |||
178 | /** |
||
179 | * @param \Throwable $error |
||
180 | * @return ExternalFileException |
||
181 | */ |
||
182 | 64 | protected function error(\Throwable $error): ExternalFileException |
|
190 | } |
||
191 |