1 | <?php |
||
25 | abstract class AbstractDefinition implements Definition |
||
26 | { |
||
27 | use Serializable; |
||
28 | |||
29 | /** |
||
30 | * @var Document |
||
31 | */ |
||
32 | protected $document; |
||
33 | |||
34 | /** |
||
35 | * @var int |
||
36 | */ |
||
37 | protected $offset = 0; |
||
38 | |||
39 | /** |
||
40 | * @var int|null |
||
41 | */ |
||
42 | protected $line; |
||
43 | |||
44 | /** |
||
45 | * @var int|null |
||
46 | */ |
||
47 | protected $column; |
||
48 | |||
49 | /** |
||
50 | * AbstractDefinition constructor. |
||
51 | * @param Document $document |
||
52 | */ |
||
53 | 9 | public function __construct(Document $document) |
|
57 | |||
58 | /** |
||
59 | * @param TypeInterface $type |
||
60 | * @return bool |
||
61 | */ |
||
62 | public static function typeOf(TypeInterface $type): bool |
||
66 | |||
67 | /** |
||
68 | * @param int $offset |
||
69 | * @return Definition|TypeDefinition|TypeInvocation|$this |
||
70 | */ |
||
71 | 1 | public function withOffset(int $offset): Definition |
|
77 | |||
78 | /** |
||
79 | * @param int $line |
||
80 | * @return Definition|TypeDefinition|TypeInvocation|$this |
||
81 | */ |
||
82 | 9 | public function withLine(?int $line): Definition |
|
88 | /** |
||
89 | * @param int $column |
||
90 | * @return Definition|TypeDefinition|TypeInvocation|$this |
||
91 | */ |
||
92 | public function withColumn(?int $column): Definition |
||
98 | |||
99 | /** |
||
100 | * @return DocumentInterface |
||
101 | */ |
||
102 | 17 | public function getDocument(): DocumentInterface |
|
106 | |||
107 | /** |
||
108 | * @return int |
||
109 | */ |
||
110 | 65 | public function getLine(): int |
|
118 | |||
119 | /** |
||
120 | * @return Readable |
||
121 | */ |
||
122 | 65 | public function getFile(): Readable |
|
126 | |||
127 | /** |
||
128 | * @return int |
||
129 | */ |
||
130 | 66 | public function getColumn(): int |
|
138 | |||
139 | /** |
||
140 | * @return string |
||
141 | */ |
||
142 | public function __toString(): string |
||
146 | |||
147 | /** |
||
148 | * @param string|TypeDefinition $type |
||
149 | * @return TypeDefinition |
||
150 | * @throws ExternalFileException |
||
151 | */ |
||
152 | 17 | protected function fetch($type): TypeDefinition |
|
165 | |||
166 | /** |
||
167 | * @param string|TypeDefinition|null $type |
||
168 | * @return null|TypeDefinition |
||
169 | * @throws ExternalFileException |
||
170 | */ |
||
171 | protected function fetchOrNull($type): ?TypeDefinition |
||
175 | |||
176 | /** |
||
177 | * @param \Throwable $error |
||
178 | * @return ExternalFileException |
||
179 | */ |
||
180 | 64 | protected function error(\Throwable $error): ExternalFileException |
|
188 | } |
||
189 |