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