better handling of unserialization with annotations
[awesomized/ext-ion] / ion.stub.php
1 <?php
2
3 /** @generate-class-entries */
4
5 namespace ion;
6 enum Type : int {
7 case Null = 0x000;
8 case Bool = 0x100;
9 case Int = 0x200;
10 case Float = 0x400;
11 case Decimal = 0x500;
12 case Timestamp = 0x600;
13 case Symbol = 0x700;
14 case String = 0x800;
15 case CLob = 0x900;
16 case BLob = 0xa00;
17 case AList = 0xb00;
18 case SExp = 0xc00;
19 case Struct = 0xd00;
20 case Datagram = 0xf00;
21
22 case EOF =-0x100;
23 case NONE =-0x200;
24 }
25
26 enum Annotation : string {
27 case PHP = "PHP";
28
29 case REFERENCE = "R";
30 case BACKREF = "r";
31
32 case OBJECT = "o";
33 case CLASS_OBJ = "c";
34 case MAGIC_OBJ = "O";
35 case CUSTOM_OBJ = "C";
36 case SERIALIZABLE = "S";
37 case ENUM = "E";
38
39 case FIELD_NAME_INT = "i";
40 }
41
42 namespace ion\Symbol;
43 class ImportLocation {
44 public function __construct(
45 public readonly string $name,
46 public readonly int $location,
47 ) {}
48 }
49
50 namespace ion\Symbol;
51 enum System : string {
52 case Ion = '$ion';
53 case Ivm_1_0 = '$ion_1_0';
54 case IonSymbolTable = '$ion_symbol_table';
55 case Name = 'name';
56 case Version = 'version';
57 case Imports = 'imports';
58 case Symbols = 'symbols';
59 case MaxId = 'max_id';
60 case SharedSymbolTable = '$ion_shared_symbol_table';
61 }
62
63 namespace ion\Symbol\System;
64 enum SID : int {
65 case Ion = 1;
66 case Ivm_1_0 = 2;
67 case IonSymbolTable = 3;
68 case Name = 4;
69 case Version = 5;
70 case Imports = 6;
71 case Symbols = 7;
72 case MaxId = 8;
73 case SharedSymbolTable = 9;
74 }
75
76 namespace ion;
77 class Symbol {
78 public function __construct(
79 public readonly string $value,
80 public readonly int $sid = -1,
81 public readonly ?Symbol\ImportLocation $importLocation = null,
82 ) {}
83
84 public function equals(Symbol $symbol): bool { }
85 }
86
87 namespace ion\Symbol;
88 class Table {
89
90 }
91
92 namespace ion;
93 class Catalog {
94 }
95
96 namespace ion;
97 class Collection {
98
99 }
100
101 namespace ion;
102 class Decimal {
103 public function __construct(
104 string|int $number,
105 public readonly ?Decimal\Context $context = null,
106 ) {}
107
108 public function equals(Decimal $decimal) : bool {}
109 public function zero() : void {}
110
111 public function __toString() : string {}
112 /** @alias ion\Decimal::__toString */
113 public function toString() : string {}
114 public function toInt() : int {}
115 }
116
117 namespace ion\Decimal;
118 class Context {
119
120 }
121
122
123 namespace ion;
124 class Timestamp extends \DateTime {
125 public function __construct(
126 public readonly int $precision,
127 public readonly string $format = "c",
128 string $datetime = "now",
129 ?\DateTimeZone $timezone = null,
130 ) {}
131
132 public function __toString() : string {}
133 }
134
135
136 namespace ion;
137 interface Reader extends \RecursiveIterator {
138 public function getType() : Type;
139 public function hasAnnotations() : bool;
140 public function hasAnnotation(string $annotation) : bool;
141 public function isNull() : bool;
142 public function isInStruct() : bool;
143 public function getFieldName() : string;
144 public function getFieldNameSymbol() : Symbol;
145 public function getAnnotations() : array;
146 public function getAnnotationSymbols() : array;
147 public function countAnnotations() : int;
148 public function getAnnotation(int $index) : string;
149 public function getAnnotationSymbol(int $index) : Symbol;
150
151 public function readNull() : Type;
152 public function readBool() : bool;
153 public function readInt() : int|string;
154 public function readFloat() : float;
155 public function readDecimal() : Decimal;
156 public function readTimestamp() : Timestamp;
157 public function readSymbol() : Symbol;
158 public function readString() : string;
159 /** @param ref $string */
160 public function readStringPart(&$string, int $length = 0x1000) : bool;
161 public function readLob() : string;
162 /** @param ref $string */
163 public function readLobPart(&$string, int $length = 0x1000) : bool;
164
165 public function getPosition() : int;
166 public function getDepth() : int;
167
168 public function seek(int $offset, int $length = -1) : void;
169 /*
170 public function getSymbolTable() : SymbolTable;
171 public function setSymbolTable(SymbolTable $table) : void;
172 */
173 public function getValueOffset() : int;
174 public function getValueLength() : int;
175 }
176 namespace ion\Reader;
177 class Options {
178 public function __construct(
179 public readonly ?\ion\Catalog $catalog = null,
180 public readonly ?\ion\Decimal\Context $decimalContext = null,
181 public readonly ?\Closure $onContextChange = null,
182 public readonly bool $returnSystemValues = false,
183 public readonly int $newLine = 0xa,
184 public readonly int $maxContainerDepth = 10,
185 public readonly int $maxAnnotations = 10,
186 public readonly int $maxAnnotationBuffered = 512,
187 public readonly int $symbolThreshold = 4096,
188 public readonly int $userValueThreshold = 4096,
189 public readonly int $chunkThreshold = 4096,
190 public readonly int $allocationPageSize = 4096,
191 public readonly bool $skipCharacterValidation = false,
192 ) {}
193 }
194
195 namespace ion\Reader;
196 abstract class Reader implements \ion\Reader {
197 public readonly ?Options $options;
198
199 public function hasChildren() : bool {}
200 public function getChildren() : \ion\Reader {}
201
202 public function rewind() : void {}
203 public function next() : void {}
204 public function valid() : bool {}
205 public function key() : mixed {}
206 public function current() : mixed {}
207
208 public function getType() : \ion\Type {}
209 public function hasAnnotations() : bool {}
210 public function hasAnnotation(string $annotation) : bool {}
211 public function isNull() : bool {}
212 public function isInStruct() : bool {}
213 public function getFieldName() : string {}
214 public function getFieldNameSymbol() : \ion\Symbol {}
215 public function getAnnotations() : array {}
216 public function getAnnotationSymbols() : array {}
217 public function countAnnotations() : int {}
218 public function getAnnotation(int $index) : string {}
219 public function getAnnotationSymbol(int $index) : \ion\Symbol {}
220
221 public function readNull() : \ion\Type {}
222 public function readBool() : bool {}
223 public function readInt() : int|string {}
224 public function readFloat() : float {}
225 public function readDecimal() : \ion\Decimal {}
226 public function readTimestamp() : \ion\Timestamp {}
227 public function readSymbol() : \ion\Symbol {}
228 public function readString() : string {}
229 /** @param ref $string */
230 public function readStringPart(&$string, int $length = 0x1000) : bool {}
231 public function readLob() : string {}
232 /** @param ref $string */
233 public function readLobPart(&$string, int $length = 0x1000) : bool {}
234
235 public function getPosition() : int {}
236 public function getDepth() : int{}
237
238 public function seek(int $offset, int $length = -1) : void {}
239 /*
240 public function getSymbolTable() : SymbolTable {}
241 public function setSymbolTable(SymbolTable $table) : void {}
242 */
243 public function getValueOffset() : int {}
244 public function getValueLength() : int {}
245 }
246 namespace ion\Reader;
247 interface Buffer extends \ion\Reader {
248 public function getBuffer() : string;
249 }
250
251 namespace ion\Reader\Buffer;
252 class Reader extends \ion\Reader\Reader implements \ion\Reader\Buffer {
253 public function __construct(
254 string $buffer,
255 ?\ion\Reader\Options $options = null,
256 ) {}
257
258 public function getBuffer() : string {}
259 }
260
261 namespace ion\Reader;
262 interface Stream extends \ion\Reader {
263 /** @return resource */
264 public function getStream();
265 /** @param resource $stream */
266 public function resetStream($stream) : void;
267 /** @param resource $stream */
268 public function resetStreamWithLength($stream, int $position, int $length = -1) : void;
269 }
270
271 namespace ion\Reader\Stream;
272 class Reader extends \ion\Reader\Reader implements \ion\Reader\Stream {
273 /** @param resource $stream */
274 public function __construct(
275 $stream,
276 ?\ion\Reader\Options $options = null,
277 ) {
278 }
279 /** @return resource */
280 public function getStream() {}
281 /** @param resource $stream */
282 public function resetStream($stream) : void {}
283 /** @param resource $stream */
284 public function resetStreamWithLength($stream, int $position, int $length = -1) : void {}
285 }
286
287 namespace ion\Writer;
288 class Options {
289 public function __construct(
290 public readonly ?\ion\Catalog $catalog = null,
291 public readonly ?\ion\Decimal\Context $decimalContext = null,
292 ?\ion\Collection $encodingSymbolTable = null,
293 public readonly bool $outputBinary = false,
294 public readonly bool $compactFloats = false,
295 public readonly bool $escapeNonAscii = false,
296 public readonly bool $prettyPrint = false,
297 public readonly bool $indentTabs = true,
298 public readonly int $indentSize = 2,
299 public readonly bool $smallContainersInline = true,
300 public readonly bool $suppressSystemValues = false,
301 public readonly bool $flushEveryValue = false,
302 public readonly int $maxContainerDepth = 10,
303 public readonly int $maxAnnotations = 10,
304 public readonly int $tempBufferSize = 0x400,
305 public readonly int $allocationPageSize = 0x1000,
306 ) {}
307
308 // public function addSharedImports(\ion\Collection|\ion\Symbol\Table ...$imports) : void;
309 }
310
311 namespace ion;
312 interface Writer {
313 public function writeNull() : void;
314 public function writeTypedNull(Type $type) : void;
315 public function writeBool(bool $value) : void;
316 public function writeInt(int|string $value) : void;
317 public function writeFloat(float $value) : void;
318 public function writeDecimal(Decimal|string $value) : void;
319 public function writeTimestamp(Timestamp|string $value) : void;
320 public function writeSymbol(Symbol|string $value) : void;
321 public function writeString(string $value) : void;
322 public function writeCLob(string $value) : void;
323 public function writeBLob(string $value) : void;
324
325 public function startLob(Type $type) : void;
326 public function appendLob(string $data) : void;
327 public function finishLob() : void;
328
329 public function startContainer(Type $type) : void;
330 public function finishContainer() : void;
331
332 public function writeFieldName(string $name) : void;
333
334 public function writeAnnotation(Symbol|string ...$annotation) : void;
335
336 public function getDepth() : int;
337 public function flush() : int;
338 public function finish() : int;
339
340 public function writeOne(Reader $reader) : void;
341 public function writeAll(Reader $reader) : void;
342
343 // public function getCatalog() : Catalog;
344 // public function setCatalog(Catalog $catalog) : void;
345
346 // public function getSymbolTable() : Symbol\Table;
347 // puvlic function setSymbolTable(Symbol\Table $table) : void;
348 }
349
350 namespace ion\Writer;
351 abstract class Writer implements \ion\Writer {
352 public function writeNull() : void {}
353 public function writeTypedNull(\ion\Type $type) : void {}
354 public function writeBool(bool $value) : void {}
355 public function writeInt(int|string $value) : void {}
356 public function writeFloat(float $value) : void {}
357 public function writeDecimal(\ion\Decimal|string $value) : void {}
358 public function writeTimestamp(\ion\Timestamp|string $value) : void {}
359 public function writeSymbol(\ion\Symbol|string $value) : void {}
360 public function writeString(string $value) : void {}
361 public function writeCLob(string $value) : void {}
362 public function writeBLob(string $value) : void {}
363
364 public function startLob(\ion\Type $type) : void {}
365 public function appendLob(string $data) : void {}
366 public function finishLob() : void {}
367
368 public function startContainer(\ion\Type $type) : void {}
369 public function finishContainer() : void {}
370
371 public function writeFieldName(string $name) : void {}
372
373 public function writeAnnotation(\ion\Symbol|string ...$annotation) : void {}
374
375 public function getDepth() : int {}
376 public function flush() : int {}
377 public function finish() : int {}
378
379 public function writeOne(\ion\Reader $reader) : void {}
380 public function writeAll(\ion\Reader $reader) : void {}
381 }
382
383 namespace ion\Writer;
384 interface Buffer extends \ion\Writer {
385 public function getBuffer() : string;
386 }
387
388 namespace ion\Writer\Buffer;
389 class Writer extends \ion\Writer\Writer implements \ion\Writer\Buffer {
390 /** @param ref $buffer */
391 public function __construct(
392 ?string &$buffer,
393 ?\ion\Writer\Options $options = null,
394 ) {}
395
396 /**
397 * @return string a _copy_ of $buffer passed to the constructor
398 */
399 public function getBuffer() : string {}
400 }
401
402 namespace ion\Writer;
403 interface Stream extends \ion\Writer {
404 /** @return resource */
405 public function getStream();
406 }
407
408 namespace ion\Writer\Stream;
409 class Writer extends \ion\Writer\Writer implements \ion\Writer\Stream {
410 /** @param resource $stream */
411 public function __construct(
412 $stream,
413 ?\ion\Writer\Options $options = null,
414 ) {}
415 /** @return resource */
416 public function getStream() {}
417 }
418
419 namespace ion\PHP;
420 class Serializer {
421 public function __construct(
422 public readonly \ion\Writer $writer,
423 public readonly bool $callMagicSerialize = true,
424 public readonly ?string $callCustomSerialize = null,
425 ) {}
426 public function __invoke(mixed $data) : void {}
427 protected function serialize(mixed $data) : void {}
428 }
429
430 namespace ion\PHP;
431 class Unserializer {
432 public function __construct(
433 public readonly \ion\Reader $reader,
434 public readonly bool $callMagicUnserialize = true,
435 public readonly ?string $callCustomUnserialize = null,
436 ){}
437 public function __invoke() : mixed {}
438 protected function unserialize() : mixed {}
439 }
440
441 namespace ion;
442 function serialize(mixed $data, Writer\Options $options = null) : string {}
443 function unserialize(mixed $serialized, Reader\Options $options = null) : mixed {}
444
445
446
447