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|string $type |
||
62 | * @return bool |
||
63 | * @throws ReflectionException |
||
64 | */ |
||
65 | public static function typeOf($type): bool |
||
79 | |||
80 | /** |
||
81 | * @param int $offset |
||
82 | * @return Definition|TypeDefinition|TypeInvocation|$this |
||
83 | */ |
||
84 | 1 | public function withOffset(int $offset): Definition |
|
90 | |||
91 | /** |
||
92 | * @param int $line |
||
93 | * @return Definition|TypeDefinition|TypeInvocation|$this |
||
94 | */ |
||
95 | 9 | public function withLine(?int $line): Definition |
|
101 | /** |
||
102 | * @param int $column |
||
103 | * @return Definition|TypeDefinition|TypeInvocation|$this |
||
104 | */ |
||
105 | public function withColumn(?int $column): Definition |
||
111 | |||
112 | /** |
||
113 | * @return DocumentInterface |
||
114 | */ |
||
115 | 17 | public function getDocument(): DocumentInterface |
|
119 | |||
120 | /** |
||
121 | * @return int |
||
122 | */ |
||
123 | 1 | public function getLine(): int |
|
131 | |||
132 | /** |
||
133 | * @return Readable |
||
134 | */ |
||
135 | 1 | public function getFile(): Readable |
|
139 | |||
140 | /** |
||
141 | * @return int |
||
142 | */ |
||
143 | 2 | public function getColumn(): int |
|
151 | |||
152 | /** |
||
153 | * @return string |
||
154 | */ |
||
155 | public function __toString(): string |
||
159 | |||
160 | /** |
||
161 | * @param string|TypeDefinition $type |
||
162 | * @return TypeDefinition |
||
163 | * @throws ExternalFileException |
||
164 | */ |
||
165 | 10 | protected function fetch($type): TypeDefinition |
|
178 | |||
179 | /** |
||
180 | * @param string|TypeDefinition $type |
||
181 | * @return string|null |
||
182 | * @throws ExternalFileException |
||
183 | */ |
||
184 | 25 | protected function nameOf($type): ?string |
|
197 | |||
198 | /** |
||
199 | * @param string|TypeDefinition|null $type |
||
200 | * @return null|TypeDefinition |
||
201 | * @throws ExternalFileException |
||
202 | */ |
||
203 | protected function fetchOrNull($type): ?TypeDefinition |
||
207 | |||
208 | /** |
||
209 | * @param \Throwable $error |
||
210 | * @return ExternalFileException |
||
211 | */ |
||
212 | protected function error(\Throwable $error): ExternalFileException |
||
220 | } |
||
221 |
As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next
break
.There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.