support multi sequence un/serialization
[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 PROPERTY = "p";
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 = null,
80 public readonly int $sid = -1,
81 public readonly ?Symbol\ImportLocation $importLocation = null,
82 ) {}
83
84 public function equals(Symbol $symbol): bool {}
85 public function __toString() : string {}
86 /** @alias ion\Symbol::__toString */
87 public function toString() : string {}
88 }
89
90 namespace ion\Symbol;
91 class Table {
92
93 }
94
95 namespace ion;
96 class Catalog {
97 }
98
99 namespace ion;
100 class Collection {
101
102 }
103
104 namespace ion;
105 class LOB {
106 public function __construct(
107 public readonly string $value,
108 public readonly Type $type = Type::CLob,
109 ) {
110 }
111 }
112
113 namespace ion\Decimal;
114 class Context {
115 public function __construct(
116 public readonly int $bits = 128
117 ) {}
118 }
119
120 namespace ion;
121 class Decimal {
122 public function __construct(
123 public readonly string|int $number,
124 public readonly ?Decimal\Context $context = null,
125 ) {}
126
127 public function equals(Decimal $decimal) : bool {}
128 public function isInt() : bool {}
129
130 public function __toString() : string {}
131 /** @alias ion\Decimal::__toString */
132 public function toString() : string {}
133 public function toInt() : int {}
134 }
135
136 namespace ion\Timestamp;
137 enum Precision : int {
138 case Year = 0x1;
139 case Month = 0x1|0x2;
140 case Day = 0x1|0x2|0x4;
141 case Min = 0x1|0x2|0x4|0x10;
142 case Sec = 0x1|0x2|0x4|0x10|0x20;
143 case Frac = 0x1|0x2|0x4|0x10|0x20|0x40;
144 }
145 namespace ion;
146 class Timestamp extends \DateTime {
147 public readonly int $precision;
148 public readonly string $format;
149
150 public function __construct(
151 Timestamp\Precision|int $precision,
152 ?string $format = null,
153 ?string $datetime = null,
154 ?\DateTimeZone $timezone = null,
155 ) {}
156
157 public function __toString() : string {}
158 }
159
160
161 namespace ion;
162 interface Reader extends \RecursiveIterator {
163 public function getType() : Type;
164 public function hasAnnotations() : bool;
165 public function hasAnnotation(string $annotation) : bool;
166 public function isNull() : bool;
167 public function isInStruct() : bool;
168 public function getFieldName() : string;
169 public function getFieldNameSymbol() : Symbol;
170 public function getAnnotations() : array;
171 public function getAnnotationSymbols() : array;
172 public function countAnnotations() : int;
173 public function getAnnotation(int $index) : string;
174 public function getAnnotationSymbol(int $index) : Symbol;
175
176 public function readNull() : Type;
177 public function readBool() : bool;
178 public function readInt() : int|string;
179 public function readFloat() : float;
180 public function readDecimal() : Decimal;
181 public function readTimestamp() : Timestamp;
182 public function readSymbol() : Symbol;
183 public function readString() : string;
184 /** @param ref $string */
185 public function readStringPart(&$string, int $length = 0x1000) : bool;
186 public function readLob() : string;
187 /** @param ref $string */
188 public function readLobPart(&$string, int $length = 0x1000) : bool;
189
190 public function getPosition() : int;
191 public function getDepth() : int;
192
193 public function seek(int $offset, int $length = -1) : void;
194 /*
195 public function getSymbolTable() : SymbolTable;
196 public function setSymbolTable(SymbolTable $table) : void;
197 */
198 public function getValueOffset() : int;
199 public function getValueLength() : int;
200 }
201 namespace ion\Reader;
202 class Options {
203 public function __construct(
204 public readonly ?\ion\Catalog $catalog = null,
205 public readonly ?\ion\Decimal\Context $decimalContext = null,
206 public readonly ?\Closure $onContextChange = null,
207 public readonly bool $returnSystemValues = false,
208 public readonly int $newLine = 0xa,
209 public readonly int $maxContainerDepth = 10,
210 public readonly int $maxAnnotations = 10,
211 public readonly int $maxAnnotationBuffered = 512,
212 public readonly int $symbolThreshold = 4096,
213 public readonly int $userValueThreshold = 4096,
214 public readonly int $chunkThreshold = 4096,
215 public readonly int $allocationPageSize = 4096,
216 public readonly bool $skipCharacterValidation = false,
217 ) {}
218 }
219
220 namespace ion\Reader;
221 abstract class Reader implements \ion\Reader {
222 public readonly ?Options $options;
223
224 public function hasChildren() : bool {}
225 public function getChildren() : \ion\Reader {}
226
227 public function rewind() : void {}
228 public function next() : void {}
229 public function valid() : bool {}
230 public function key() : mixed {}
231 public function current() : mixed {}
232
233 public function getType() : \ion\Type {}
234 public function hasAnnotations() : bool {}
235 public function hasAnnotation(string $annotation) : bool {}
236 public function isNull() : bool {}
237 public function isInStruct() : bool {}
238 public function getFieldName() : string {}
239 public function getFieldNameSymbol() : \ion\Symbol {}
240 public function getAnnotations() : array {}
241 public function getAnnotationSymbols() : array {}
242 public function countAnnotations() : int {}
243 public function getAnnotation(int $index) : string {}
244 public function getAnnotationSymbol(int $index) : \ion\Symbol {}
245
246 public function readNull() : \ion\Type {}
247 public function readBool() : bool {}
248 public function readInt() : int|string {}
249 public function readFloat() : float {}
250 public function readDecimal() : \ion\Decimal {}
251 public function readTimestamp() : \ion\Timestamp {}
252 public function readSymbol() : \ion\Symbol {}
253 public function readString() : string {}
254 /** @param ref $string */
255 public function readStringPart(&$string, int $length = 0x1000) : bool {}
256 public function readLob() : string {}
257 /** @param ref $string */
258 public function readLobPart(&$string, int $length = 0x1000) : bool {}
259
260 public function getPosition() : int {}
261 public function getDepth() : int{}
262
263 public function seek(int $offset, int $length = -1) : void {}
264 /*
265 public function getSymbolTable() : SymbolTable {}
266 public function setSymbolTable(SymbolTable $table) : void {}
267 */
268 public function getValueOffset() : int {}
269 public function getValueLength() : int {}
270 }
271 namespace ion\Reader;
272 interface Buffer extends \ion\Reader {
273 public function getBuffer() : string;
274 }
275
276 namespace ion\Reader\Buffer;
277 class Reader extends \ion\Reader\Reader implements \ion\Reader\Buffer {
278 public function __construct(
279 string $buffer,
280 ?\ion\Reader\Options $options = null,
281 ) {}
282
283 public function getBuffer() : string {}
284 }
285
286 namespace ion\Reader;
287 interface Stream extends \ion\Reader {
288 /** @return resource */
289 public function getStream();
290 /** @param resource $stream */
291 public function resetStream($stream) : void;
292 /** @param resource $stream */
293 public function resetStreamWithLength($stream, int $position, int $length = -1) : void;
294 }
295
296 namespace ion\Reader\Stream;
297 class Reader extends \ion\Reader\Reader implements \ion\Reader\Stream {
298 /** @param resource $stream */
299 public function __construct(
300 $stream,
301 ?\ion\Reader\Options $options = null,
302 ) {
303 }
304 /** @return resource */
305 public function getStream() {}
306 /** @param resource $stream */
307 public function resetStream($stream) : void {}
308 /** @param resource $stream */
309 public function resetStreamWithLength($stream, int $position, int $length = -1) : void {}
310 }
311
312 namespace ion\Writer;
313 class Options {
314 public function __construct(
315 public readonly ?\ion\Catalog $catalog = null,
316 public readonly ?\ion\Decimal\Context $decimalContext = null,
317 ?\ion\Collection $encodingSymbolTable = null,
318 public readonly bool $outputBinary = false,
319 public readonly bool $compactFloats = false,
320 public readonly bool $escapeNonAscii = false,
321 public readonly bool $prettyPrint = false,
322 public readonly bool $indentTabs = true,
323 public readonly int $indentSize = 2,
324 public readonly bool $smallContainersInline = true,
325 public readonly bool $suppressSystemValues = false,
326 public readonly bool $flushEveryValue = false,
327 public readonly int $maxContainerDepth = 10,
328 public readonly int $maxAnnotations = 10,
329 public readonly int $tempBufferSize = 0x400,
330 public readonly int $allocationPageSize = 0x1000,
331 ) {}
332
333 // public function addSharedImports(\ion\Collection|\ion\Symbol\Table ...$imports) : void;
334 }
335
336 namespace ion;
337 interface Writer {
338 public function writeNull() : void;
339 public function writeTypedNull(Type $type) : void;
340 public function writeBool(bool $value) : void;
341 public function writeInt(int|string $value) : void;
342 public function writeFloat(float $value) : void;
343 public function writeDecimal(Decimal|string $value) : void;
344 public function writeTimestamp(Timestamp|string $value) : void;
345 public function writeSymbol(Symbol|string $value) : void;
346 public function writeString(string $value) : void;
347 public function writeCLob(string $value) : void;
348 public function writeBLob(string $value) : void;
349
350 public function startLob(Type $type) : void;
351 public function appendLob(string $data) : void;
352 public function finishLob() : void;
353
354 public function startContainer(Type $type) : void;
355 public function finishContainer() : void;
356
357 public function writeFieldName(string $name) : void;
358
359 public function writeAnnotation(Symbol|string ...$annotation) : void;
360
361 public function getDepth() : int;
362 public function flush() : int;
363 public function finish() : int;
364
365 public function writeOne(Reader $reader) : void;
366 public function writeAll(Reader $reader) : void;
367
368 // public function getCatalog() : Catalog;
369 // public function setCatalog(Catalog $catalog) : void;
370
371 // public function getSymbolTable() : Symbol\Table;
372 // puvlic function setSymbolTable(Symbol\Table $table) : void;
373 }
374
375 namespace ion\Writer;
376 abstract class Writer implements \ion\Writer {
377 public function writeNull() : void {}
378 public function writeTypedNull(\ion\Type $type) : void {}
379 public function writeBool(bool $value) : void {}
380 public function writeInt(int|string $value) : void {}
381 public function writeFloat(float $value) : void {}
382 public function writeDecimal(\ion\Decimal|string $value) : void {}
383 public function writeTimestamp(\ion\Timestamp|string $value) : void {}
384 public function writeSymbol(\ion\Symbol|string $value) : void {}
385 public function writeString(string $value) : void {}
386 public function writeCLob(string $value) : void {}
387 public function writeBLob(string $value) : void {}
388
389 public function startLob(\ion\Type $type) : void {}
390 public function appendLob(string $data) : void {}
391 public function finishLob() : void {}
392
393 public function startContainer(\ion\Type $type) : void {}
394 public function finishContainer() : void {}
395
396 public function writeFieldName(string $name) : void {}
397
398 public function writeAnnotation(\ion\Symbol|string ...$annotation) : void {}
399
400 public function getDepth() : int {}
401 public function flush() : int {}
402 public function finish() : int {}
403
404 public function writeOne(\ion\Reader $reader) : void {}
405 public function writeAll(\ion\Reader $reader) : void {}
406 }
407
408 namespace ion\Writer;
409 interface Buffer extends \ion\Writer {
410 public function getBuffer() : string;
411 }
412
413 namespace ion\Writer\Buffer;
414 class Writer extends \ion\Writer\Writer implements \ion\Writer\Buffer {
415 /** @param ref $buffer */
416 public function __construct(
417 ?string &$buffer,
418 ?\ion\Writer\Options $options = null,
419 ) {}
420
421 /**
422 * @return string a _copy_ of $buffer passed to the constructor
423 */
424 public function getBuffer() : string {}
425 }
426
427 namespace ion\Writer;
428 interface Stream extends \ion\Writer {
429 /** @return resource */
430 public function getStream();
431 }
432
433 namespace ion\Writer\Stream;
434 class Writer extends \ion\Writer\Writer implements \ion\Writer\Stream {
435 /** @param resource $stream */
436 public function __construct(
437 $stream,
438 ?\ion\Writer\Options $options = null,
439 ) {}
440 /** @return resource */
441 public function getStream() {}
442 }
443
444 namespace ion;
445 interface Serializer {
446 public function __invoke(mixed $data) : string;
447 // protected function serialize(mixed $data) : string;
448 }
449 namespace ion;
450 interface Unserializer {
451 /** @param string|resource $data */
452 public function __invoke($data) : mixed;
453 // /** @param string|resource $data */
454 // protected function unserialize($data) : mixed;
455 }
456
457 namespace ion\Serializer;
458 class PHP implements \ion\Serializer {
459 public function __construct(
460 public readonly ?\ion\Writer\Options $writerOptions = null,
461 public readonly bool $multiSequence = false,
462 public readonly bool $callMagicSerialize = true,
463 public readonly ?string $callCustomSerialize = null,
464 ) {}
465 public function __invoke(mixed $data) : string {}
466 protected function serialize(mixed $data) : string {}
467 }
468
469 namespace ion\Unserializer;
470 class PHP implements \ion\Unserializer {
471 public function __construct(
472 public readonly ?\ion\Reader\Options $readerOptions = null,
473 public readonly bool $multiSequence = true,
474 public readonly bool $callMagicUnserialize = true,
475 public readonly ?string $callCustomUnserialize = null,
476 ){}
477 /** @param string|resource $data */
478 public function __invoke($data) : mixed {}
479 /** @param string|resource $data */
480 protected function unserialize($data) : mixed {}
481 }
482
483 namespace ion;
484 function serialize(mixed $data, ?Serializer $serializer = null) : string {}
485 /** @param string|resource $data */
486 function unserialize($data, ?Unserializer $unserializer = null) : mixed {}