add ci workflow
[awesomized/ext-ion] / ion.stub.php
1 <?php
2
3 /**
4 * @generate-class-entries static
5 * @generate-function-entries static
6 */
7
8 namespace ion;
9
10 function serialize(mixed $data, ?Serializer $serializer = null) : string {}
11 /** @param string|resource $data */
12 function unserialize($data, ?Unserializer $unserializer = null) : mixed {}
13
14 interface Serializer {
15 public function serialize(mixed $data) : string;
16 }
17 interface Unserializer {
18 /** @param string|resource $data */
19 public function unserialize($data) : mixed;
20 }
21
22 enum Type : int {
23 case Null = 0x000;
24 case Bool = 0x100;
25 case Int = 0x200;
26 case Float = 0x400;
27 case Decimal = 0x500;
28 case Timestamp = 0x600;
29 case Symbol = 0x700;
30 case String = 0x800;
31 case CLob = 0x900;
32 case BLob = 0xa00;
33 case List = 0xb00;
34 case SExp = 0xc00;
35 case Struct = 0xd00;
36 case Datagram = 0xf00;
37
38 case EOF =-0x100;
39 case NONE =-0x200;
40 }
41
42 class Symbol {
43 public function __construct(
44 public readonly ?string $value = null,
45 public readonly int $sid = -1,
46 public readonly ?Symbol\ImportLocation $importLocation = null,
47 ) {}
48
49 public function equals(Symbol $symbol): bool {}
50 public function __toString() : string {}
51 /** @alias ion\Symbol::__toString */
52 public function toString() : string {}
53 }
54
55 class Catalog implements Countable {
56 /** Internal cache */
57 private array $symbolTables = [];
58
59 public function __construct() {}
60
61 public function count() : int {}
62
63 public function add(Symbol\Table $table) : void {}
64 public function remove(Symbol\Table|string $table) : bool {}
65
66 public function find(string $name, int $version = 0) : ?Symbol\Table {}
67 public function findBest(string $name, int $version = 0) : ?Symbol\Table {}
68 }
69
70 class LOB {
71 public function __construct(
72 public readonly string $value,
73 public readonly Type $type = Type::CLob,
74 ) {
75 }
76 }
77
78 class Decimal {
79 public function __construct(
80 public readonly string|int $number,
81 public readonly ?Decimal\Context $context = null,
82 ) {}
83
84 public function equals(Decimal $decimal) : bool {}
85 public function isInt() : bool {}
86
87 public function __toString() : string {}
88 /** @alias ion\Decimal::__toString */
89 public function toString() : string {}
90 public function toInt() : int {}
91 }
92
93 class Timestamp extends \DateTime {
94 public readonly int $precision;
95 public readonly string $format;
96
97 public function __construct(
98 Timestamp\Precision|int $precision,
99 Timestamp\Format|string|null $format = null,
100 ?string $datetime = null,
101 ?\DateTimeZone $timezone = null,
102 ) {}
103
104 public function __toString() : string {}
105 }
106
107 interface Reader extends \RecursiveIterator {
108 public function getType() : Type;
109 public function hasAnnotations() : bool;
110 public function hasAnnotation(string $annotation) : bool;
111 public function isNull() : bool;
112 public function isInStruct() : bool;
113 public function getFieldName() : string;
114 public function getFieldNameSymbol() : Symbol;
115 public function getAnnotations() : array;
116 public function getAnnotationSymbols() : array;
117 public function countAnnotations() : int;
118 public function getAnnotation(int $index) : string;
119 public function getAnnotationSymbol(int $index) : Symbol;
120
121 public function readNull() : Type;
122 public function readBool() : bool;
123 public function readInt() : int|string;
124 public function readFloat() : float;
125 public function readDecimal() : Decimal;
126 public function readTimestamp() : Timestamp;
127 public function readSymbol() : Symbol;
128 public function readString() : string;
129 /** @param ref $string */
130 public function readStringPart(&$string, int $length = 0x1000) : bool;
131 public function readLob() : string;
132 /** @param ref $string */
133 public function readLobPart(&$string, int $length = 0x1000) : bool;
134
135 public function getPosition() : int;
136 public function getDepth() : int;
137
138 public function seek(int $offset, int $length = -1) : void;
139 /*
140 public function getSymbolTable() : SymbolTable;
141 public function setSymbolTable(SymbolTable $table) : void;
142 */
143 public function getValueOffset() : int;
144 public function getValueLength() : int;
145 }
146
147 interface Writer {
148 public function writeNull() : void;
149 public function writeTypedNull(Type $type) : void;
150 public function writeBool(bool $value) : void;
151 public function writeInt(int|string $value) : void;
152 public function writeFloat(float $value) : void;
153 public function writeDecimal(Decimal|string $value) : void;
154 public function writeTimestamp(Timestamp|string $value) : void;
155 public function writeSymbol(Symbol|string $value) : void;
156 public function writeString(string $value) : void;
157 public function writeCLob(string $value) : void;
158 public function writeBLob(string $value) : void;
159
160 public function startLob(Type $type) : void;
161 public function appendLob(string $data) : void;
162 public function finishLob() : void;
163
164 public function startContainer(Type $type) : void;
165 public function finishContainer() : void;
166
167 public function writeFieldName(string $name) : void;
168
169 public function writeAnnotation(Symbol|string ...$annotation) : void;
170
171 public function getDepth() : int;
172 public function flush() : int;
173 public function finish() : int;
174
175 // public function writeOne(Reader $reader) : void;
176 // public function writeAll(Reader $reader) : void;
177
178 // public function getCatalog() : Catalog;
179 // public function setCatalog(Catalog $catalog) : void;
180
181 // public function getSymbolTable() : Symbol\Table;
182 // puvlic function setSymbolTable(Symbol\Table $table) : void;
183 }
184
185 namespace ion\Symbol;
186
187 class ImportLocation {
188 public function __construct(
189 public readonly string $name,
190 public readonly int $location,
191 ) {}
192 }
193
194 interface Enum {
195 public function toSymbol() : \ion\Symbol;
196 public function toSID() : int;
197 public function toString() : string;
198 }
199
200 interface Table {
201 public function getMaxId() : int;
202
203 public function add(\ion\Symbol|string $symbol) : int;
204 public function find(string|int $id) : ?\ion\Symbol;
205 public function findLocal(string|int $id) : ?\ion\Symbol;
206 }
207
208 namespace ion\Symbol\Table;
209
210 function PHP() : \ion\Symbol\Table {}
211 function System() : \ion\Symbol\Table {}
212
213 enum System : string implements \ion\Symbol\Enum {
214 case Ion = '$ion';
215 case Ivm_1_0 = '$ion_1_0';
216 case IonSymbolTable = '$ion_symbol_table';
217 case Name = 'name';
218 case Version = 'version';
219 case Imports = 'imports';
220 case Symbols = 'symbols';
221 case MaxId = 'max_id';
222 case SharedSymbolTable = '$ion_shared_symbol_table';
223
224 /** @alias ion\Symbol\Enum::toSymbol */
225 public function toSymbol() : \ion\Symbol {}
226 /** @alias ion\Symbol\Enum::toSID */
227 public function toSID() : int {}
228 /** @alias ion\Symbol\Enum::toString */
229 public function toString() : string {}
230 }
231
232 enum PHP : string implements \ion\Symbol\Enum {
233 case PHP = 'PHP';
234 case Reference = 'R';
235 case Backref = 'r';
236 case Property = 'p';
237 case Object = 'o';
238 case ClassObject = 'c';
239 case MagicObject = 'O';
240 case CustomObject = 'C';
241 case Enum = 'E';
242 case Serializable = 'S';
243
244 /** @alias ion\Symbol\Enum::toSymbol */
245 public function toSymbol() : \ion\Symbol {}
246 /** @alias ion\Symbol\Enum::toSID */
247 public function toSID() : int {}
248 /** @alias ion\Symbol\Enum::toString */
249 public function toString() : string {}
250 }
251
252 class Local implements \ion\Symbol\Table {
253 /** Internal cache */
254 private array $imports = [];
255 /** Internal cache */
256 private array $symbols = [];
257
258 public function __construct() {}
259 public function import(\ion\Symbol\Table $table) : void {}
260
261 /** @alias ion\Symbol\Table::getMaxId */
262 public function getMaxId() : int {}
263
264 /** @alias ion\Symbol\Table::add */
265 public function add(\ion\Symbol|string $symbol) : int {}
266 /** @alias ion\Symbol\Table::find */
267 public function find(string|int $id) : ?\ion\Symbol {}
268 /** @alias ion\Symbol\Table::findLocal */
269 public function findLocal(string|int $id) : ?\ion\Symbol {}
270 }
271
272 class Shared implements \ion\Symbol\Table {
273 public function __construct(
274 public readonly string $name,
275 public readonly int $version = 1,
276 ?array $symbols = null,
277 ) {}
278
279 /** Internal cache */
280 private array $symbols = [];
281
282 /** @alias ion\Symbol\Table::getMaxId */
283 public function getMaxId() : int {}
284
285 /** @alias ion\Symbol\Table::add */
286 public function add(\ion\Symbol|string $symbol) : int {}
287 /** @alias ion\Symbol\Table::find */
288 public function find(string|int $id) : ?\ion\Symbol {}
289 /** @alias ion\Symbol\Table::findLocal */
290 public function findLocal(string|int $id) : ?\ion\Symbol {}
291 }
292
293 namespace ion\Decimal;
294
295 class Context {
296 public function __construct(
297 public readonly int $digits,
298 public readonly int $eMax,
299 public readonly int $eMin,
300 public readonly Context\Rounding|int $round,
301 public readonly bool $clamp,
302 ) {}
303
304 public static function Dec32() : Context {}
305 public static function Dec64() : Context {}
306 public static function Dec128() : Context {}
307 public static function DecMax(Context\Rounding|int $round = Context\Rounding::HalfEven) : Context {}
308 }
309
310 namespace ion\Decimal\Context;
311
312 enum Rounding : int {
313 case Ceiling = 0;
314 case Up = 1;
315 case HalfUp = 2;
316 case HalfEven = 3;
317 case HalfDown = 4;
318 case Down = 5;
319 case Floor = 6;
320 case Down05Up = 7;
321 }
322
323 namespace ion\Timestamp;
324
325 enum Precision : int {
326 case Year = 0x1;
327 case Month = 0x1|0x2;
328 case Day = 0x1|0x2|0x4;
329 case Min = 0x1|0x2|0x4|0x10;
330 case Sec = 0x1|0x2|0x4|0x10|0x20;
331 case Frac = 0x1|0x2|0x4|0x10|0x20|0x40;
332 case MinTZ = 0x1|0x2|0x4|0x10|0x80;
333 case SecTZ = 0x1|0x2|0x4|0x10|0x20|0x80;
334 case FracTZ = 0x1|0x2|0x4|0x10|0x20|0x40|0x80;
335 }
336
337 enum Format : string {
338 case Year = "Y\T";
339 case Month = "Y-m\T";
340 case Day = "Y-m-d\T";
341 case Min = "Y-m-d\TH:i";
342 case Sec = "Y-m-d\TH:i:s";
343 case Frac = "Y-m-d\TH:i:s.v";
344 case MinTZ = "Y-m-d\TH:iP";
345 case SecTZ = "Y-m-d\TH:i:sP";
346 case FracTZ = "Y-m-d\TH:i:s.vP";
347 }
348
349 namespace ion\Reader;
350
351 class Options {
352 public function __construct(
353 public readonly ?\ion\Catalog $catalog = null,
354 public readonly ?\ion\Decimal\Context $decimalContext = null,
355 public readonly ?\Closure $onContextChange = null,
356 public readonly bool $returnSystemValues = false,
357 public readonly int $newLine = 0xa,
358 public readonly int $maxContainerDepth = 10,
359 public readonly int $maxAnnotations = 10,
360 public readonly int $maxAnnotationBuffered = 512,
361 public readonly int $symbolThreshold = 0x4000,
362 public readonly int $userValueThreshold = 0x4000,
363 public readonly int $chunkThreshold = 0x4000,
364 public readonly int $allocationPageSize = 0x10000,
365 public readonly bool $skipCharacterValidation = false,
366 ) {}
367 }
368
369 abstract class Reader implements \ion\Reader {
370 public readonly ?Options $options;
371
372 public function hasChildren() : bool {}
373 public function getChildren() : \ion\Reader {}
374
375 public function rewind() : void {}
376 public function next() : void {}
377 public function valid() : bool {}
378 public function key() : mixed {}
379 public function current() : mixed {}
380
381 public function getType() : \ion\Type {}
382 public function hasAnnotations() : bool {}
383 public function hasAnnotation(string $annotation) : bool {}
384 public function isNull() : bool {}
385 public function isInStruct() : bool {}
386 public function getFieldName() : string {}
387 public function getFieldNameSymbol() : \ion\Symbol {}
388 public function getAnnotations() : array {}
389 public function getAnnotationSymbols() : array {}
390 public function countAnnotations() : int {}
391 public function getAnnotation(int $index) : string {}
392 public function getAnnotationSymbol(int $index) : \ion\Symbol {}
393
394 public function readNull() : \ion\Type {}
395 public function readBool() : bool {}
396 public function readInt() : int|string {}
397 public function readFloat() : float {}
398 public function readDecimal() : \ion\Decimal {}
399 public function readTimestamp() : \ion\Timestamp {}
400 public function readSymbol() : \ion\Symbol {}
401 public function readString() : string {}
402 /** @param ref $string */
403 public function readStringPart(&$string, int $length = 0x1000) : bool {}
404 public function readLob() : string {}
405 /** @param ref $string */
406 public function readLobPart(&$string, int $length = 0x1000) : bool {}
407
408 public function getPosition() : int {}
409 public function getDepth() : int{}
410
411 public function seek(int $offset, int $length = -1) : void {}
412 /*
413 public function getSymbolTable() : SymbolTable {}
414 public function setSymbolTable(SymbolTable $table) : void {}
415 */
416 public function getValueOffset() : int {}
417 public function getValueLength() : int {}
418 }
419
420 interface Buffer extends \ion\Reader {
421 public function getBuffer() : string;
422 }
423
424 interface Stream extends \ion\Reader {
425 /** @return resource */
426 public function getStream();
427 /** @param resource $stream */
428 public function resetStream($stream) : void;
429 /** @param resource $stream */
430 public function resetStreamWithLength($stream, int $length) : void;
431 }
432
433 namespace ion\Reader\Buffer;
434
435 class Reader extends \ion\Reader\Reader implements \ion\Reader\Buffer {
436 public function __construct(
437 string $buffer,
438 ?\ion\Reader\Options $options = null,
439 ) {}
440
441 public function getBuffer() : string {}
442 }
443
444 namespace ion\Reader\Stream;
445
446 class Reader extends \ion\Reader\Reader implements \ion\Reader\Stream {
447 /** @param resource $stream */
448 public function __construct(
449 $stream,
450 ?\ion\Reader\Options $options = null,
451 ) {
452 }
453 /** @return resource */
454 public function getStream() {}
455 /** @param resource $stream */
456 public function resetStream($stream) : void {}
457 /** @param resource $stream */
458 public function resetStreamWithLength($stream, int $length) : void {}
459 }
460
461 namespace ion\Writer;
462
463 class Options {
464 public function __construct(
465 public readonly ?\ion\Catalog $catalog = null,
466 public readonly ?\ion\Decimal\Context $decimalContext = null,
467 public readonly bool $outputBinary = false,
468 public readonly bool $compactFloats = false,
469 public readonly bool $escapeNonAscii = false,
470 public readonly bool $prettyPrint = false,
471 public readonly bool $indentTabs = true,
472 public readonly int $indentSize = 2,
473 public readonly bool $smallContainersInline = true,
474 public readonly bool $suppressSystemValues = false,
475 public readonly bool $flushEveryValue = false,
476 public readonly int $maxContainerDepth = 10,
477 public readonly int $maxAnnotations = 10,
478 public readonly int $tempBufferSize = 0x4000,
479 public readonly int $allocationPageSize = 0x10000,
480 ) {}
481 }
482
483 abstract class Writer implements \ion\Writer {
484 public function writeNull() : void {}
485 public function writeTypedNull(\ion\Type $type) : void {}
486 public function writeBool(bool $value) : void {}
487 public function writeInt(int|string $value) : void {}
488 public function writeFloat(float $value) : void {}
489 public function writeDecimal(\ion\Decimal|string $value) : void {}
490 public function writeTimestamp(\ion\Timestamp|string $value) : void {}
491 public function writeSymbol(\ion\Symbol|string $value) : void {}
492 public function writeString(string $value) : void {}
493 public function writeCLob(string $value) : void {}
494 public function writeBLob(string $value) : void {}
495
496 public function startLob(\ion\Type $type) : void {}
497 public function appendLob(string $data) : void {}
498 public function finishLob() : void {}
499
500 public function startContainer(\ion\Type $type) : void {}
501 public function finishContainer() : void {}
502
503 public function writeFieldName(string $name) : void {}
504
505 public function writeAnnotation(\ion\Symbol|string ...$annotation) : void {}
506
507 public function getDepth() : int {}
508 public function flush() : int {}
509 public function finish() : int {}
510
511 // public function writeOne(\ion\Reader $reader) : void {}
512 // public function writeAll(\ion\Reader $reader) : void {}
513 }
514
515 interface Buffer extends \ion\Writer {
516 public function getBuffer() : string;
517 public function resetBuffer() : void;
518 }
519
520 interface Stream extends \ion\Writer {
521 /** @return resource */
522 public function getStream();
523 }
524
525 namespace ion\Writer\Buffer;
526
527 class Writer extends \ion\Writer\Writer implements \ion\Writer\Buffer {
528 public function __construct(
529 ?\ion\Writer\Options $options = null,
530 ) {}
531
532 public function getBuffer() : string {}
533 public function resetBuffer() : void {}
534 }
535
536 namespace ion\Writer\Stream;
537
538 class Writer extends \ion\Writer\Writer implements \ion\Writer\Stream {
539 /** @param resource $stream */
540 public function __construct(
541 $stream,
542 ?\ion\Writer\Options $options = null,
543 ) {}
544 /** @return resource */
545 public function getStream() {}
546 }
547
548 namespace ion\Serializer;
549
550 class PHP implements \ion\Serializer {
551 public function __construct(
552 public readonly ?\ion\Writer\Options $writerOptions = null,
553 public readonly bool $multiSequence = false,
554 public readonly bool $callMagicSerialize = true,
555 public readonly ?string $callCustomSerialize = null,
556 ) {}
557 public function serialize(mixed $data) : string {}
558 }
559
560 namespace ion\Unserializer;
561
562 class PHP implements \ion\Unserializer {
563 public function __construct(
564 public readonly ?\ion\Reader\Options $readerOptions = null,
565 public readonly bool $multiSequence = false,
566 public readonly bool $callMagicUnserialize = true,
567 public readonly ?string $callCustomUnserialize = null,
568 ){}
569 /** @param string|resource $data */
570 public function unserialize($data) : mixed {}
571 }