seriously simplify the buffer writer by not accepting a ref to a buffer
[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 List = 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 /** Internal cache */
116 private array $imports = [];
117 /** Internal cache */
118 private array $symbols = [];
119
120 public function __construct() {}
121 public function import(\ion\Symbol\Table $table) : void {}
122
123 /** @alias ion\Symbol\Table::getMaxId */
124 public function getMaxId() : int {}
125
126 /** @alias ion\Symbol\Table::add */
127 public function add(\ion\Symbol|string $symbol) : int {}
128 /** @alias ion\Symbol\Table::find */
129 public function find(string|int $id) : ?\ion\Symbol {}
130 /** @alias ion\Symbol\Table::findLocal */
131 public function findLocal(string|int $id) : ?\ion\Symbol {}
132 }
133
134 namespace ion\Symbol\Table;
135 class Shared implements \ion\Symbol\Table {
136 public function __construct(
137 public readonly string $name,
138 public readonly int $version = 1,
139 ?array $symbols = null,
140 ) {}
141
142 /** Internal cache */
143 private array $symbols = [];
144
145 /** @alias ion\Symbol\Table::getMaxId */
146 public function getMaxId() : int {}
147
148 /** @alias ion\Symbol\Table::add */
149 public function add(\ion\Symbol|string $symbol) : int {}
150 /** @alias ion\Symbol\Table::find */
151 public function find(string|int $id) : ?\ion\Symbol {}
152 /** @alias ion\Symbol\Table::findLocal */
153 public function findLocal(string|int $id) : ?\ion\Symbol {}
154 }
155
156 namespace ion;
157 class Catalog implements Countable {
158 /** Internal cache */
159 private array $symbolTables = [];
160
161 public function __construct() {}
162
163 public function count() : int {}
164
165 public function add(Symbol\Table $table) : void {}
166 public function remove(Symbol\Table|string $table) : bool {}
167
168 public function find(string $name, int $version = 0) : ?Symbol\Table {}
169 public function findBest(string $name, int $version = 0) : ?Symbol\Table {}
170 }
171
172 namespace ion;
173 class LOB {
174 public function __construct(
175 public readonly string $value,
176 public readonly Type $type = Type::CLob,
177 ) {
178 }
179 }
180
181 namespace ion\Decimal\Context;
182 enum Rounding : int {
183 case Ceiling = 0;
184 case Up = 1;
185 case HalfUp = 2;
186 case HalfEven = 3;
187 case HalfDown = 4;
188 case Down = 5;
189 case Floor = 6;
190 case Down05Up = 7;
191 }
192
193 namespace ion\Decimal;
194 class Context {
195 public function __construct(
196 public readonly int $digits,
197 public readonly int $eMax,
198 public readonly int $eMin,
199 public readonly Context\Rounding|int $round,
200 public readonly bool $clamp,
201 ) {}
202
203 public static function Dec32() : Context {}
204 public static function Dec64() : Context {}
205 public static function Dec128() : Context {}
206 public static function DecMax(Context\Rounding|int $round = Context\Rounding::HalfEven) : Context {}
207 }
208
209 namespace ion;
210 class Decimal {
211 public function __construct(
212 public readonly string|int $number,
213 public readonly ?Decimal\Context $context = null,
214 ) {}
215
216 public function equals(Decimal $decimal) : bool {}
217 public function isInt() : bool {}
218
219 public function __toString() : string {}
220 /** @alias ion\Decimal::__toString */
221 public function toString() : string {}
222 public function toInt() : int {}
223 }
224
225 namespace ion\Timestamp;
226 enum Precision : int {
227 case Year = 0x1;
228 case Month = 0x1|0x2;
229 case Day = 0x1|0x2|0x4;
230 case Min = 0x1|0x2|0x4|0x10;
231 case Sec = 0x1|0x2|0x4|0x10|0x20;
232 case Frac = 0x1|0x2|0x4|0x10|0x20|0x40;
233 case MinTZ = 0x1|0x2|0x4|0x10|0x80;
234 case SecTZ = 0x1|0x2|0x4|0x10|0x20|0x80;
235 case FracTZ = 0x1|0x2|0x4|0x10|0x20|0x40|0x80;
236 }
237
238 namespace ion\Timestamp;
239 enum Format : string {
240 case Year = "Y\T";
241 case Month = "Y-m\T";
242 case Day = "Y-m-d\T";
243 case Min = "Y-m-d\TH:i";
244 case Sec = "Y-m-d\TH:i:s";
245 case Frac = "Y-m-d\TH:i:s.v";
246 case MinTZ = "Y-m-d\TH:iP";
247 case SecTZ = "Y-m-d\TH:i:sP";
248 case FracTZ = "Y-m-d\TH:i:s.vP";
249 }
250 namespace ion;
251 class Timestamp extends \DateTime {
252 public readonly int $precision;
253 public readonly string $format;
254
255 public function __construct(
256 Timestamp\Precision|int $precision,
257 Timestamp\Format|string|null $format = null,
258 ?string $datetime = null,
259 ?\DateTimeZone $timezone = null,
260 ) {}
261
262 public function __toString() : string {}
263 }
264
265
266 namespace ion;
267 interface Reader extends \RecursiveIterator {
268 public function getType() : Type;
269 public function hasAnnotations() : bool;
270 public function hasAnnotation(string $annotation) : bool;
271 public function isNull() : bool;
272 public function isInStruct() : bool;
273 public function getFieldName() : string;
274 public function getFieldNameSymbol() : Symbol;
275 public function getAnnotations() : array;
276 public function getAnnotationSymbols() : array;
277 public function countAnnotations() : int;
278 public function getAnnotation(int $index) : string;
279 public function getAnnotationSymbol(int $index) : Symbol;
280
281 public function readNull() : Type;
282 public function readBool() : bool;
283 public function readInt() : int|string;
284 public function readFloat() : float;
285 public function readDecimal() : Decimal;
286 public function readTimestamp() : Timestamp;
287 public function readSymbol() : Symbol;
288 public function readString() : string;
289 /** @param ref $string */
290 public function readStringPart(&$string, int $length = 0x1000) : bool;
291 public function readLob() : string;
292 /** @param ref $string */
293 public function readLobPart(&$string, int $length = 0x1000) : bool;
294
295 public function getPosition() : int;
296 public function getDepth() : int;
297
298 public function seek(int $offset, int $length = -1) : void;
299 /*
300 public function getSymbolTable() : SymbolTable;
301 public function setSymbolTable(SymbolTable $table) : void;
302 */
303 public function getValueOffset() : int;
304 public function getValueLength() : int;
305 }
306
307 namespace ion\Reader;
308 class Options {
309 public function __construct(
310 public readonly ?\ion\Catalog $catalog = null,
311 public readonly ?\ion\Decimal\Context $decimalContext = null,
312 public readonly ?\Closure $onContextChange = null,
313 public readonly bool $returnSystemValues = false,
314 public readonly int $newLine = 0xa,
315 public readonly int $maxContainerDepth = 10,
316 public readonly int $maxAnnotations = 10,
317 public readonly int $maxAnnotationBuffered = 512,
318 public readonly int $symbolThreshold = 0x4000,
319 public readonly int $userValueThreshold = 0x4000,
320 public readonly int $chunkThreshold = 0x4000,
321 public readonly int $allocationPageSize = 0x10000,
322 public readonly bool $skipCharacterValidation = false,
323 ) {}
324 }
325
326 namespace ion\Reader;
327 abstract class Reader implements \ion\Reader {
328 public readonly ?Options $options;
329
330 public function hasChildren() : bool {}
331 public function getChildren() : \ion\Reader {}
332
333 public function rewind() : void {}
334 public function next() : void {}
335 public function valid() : bool {}
336 public function key() : mixed {}
337 public function current() : mixed {}
338
339 public function getType() : \ion\Type {}
340 public function hasAnnotations() : bool {}
341 public function hasAnnotation(string $annotation) : bool {}
342 public function isNull() : bool {}
343 public function isInStruct() : bool {}
344 public function getFieldName() : string {}
345 public function getFieldNameSymbol() : \ion\Symbol {}
346 public function getAnnotations() : array {}
347 public function getAnnotationSymbols() : array {}
348 public function countAnnotations() : int {}
349 public function getAnnotation(int $index) : string {}
350 public function getAnnotationSymbol(int $index) : \ion\Symbol {}
351
352 public function readNull() : \ion\Type {}
353 public function readBool() : bool {}
354 public function readInt() : int|string {}
355 public function readFloat() : float {}
356 public function readDecimal() : \ion\Decimal {}
357 public function readTimestamp() : \ion\Timestamp {}
358 public function readSymbol() : \ion\Symbol {}
359 public function readString() : string {}
360 /** @param ref $string */
361 public function readStringPart(&$string, int $length = 0x1000) : bool {}
362 public function readLob() : string {}
363 /** @param ref $string */
364 public function readLobPart(&$string, int $length = 0x1000) : bool {}
365
366 public function getPosition() : int {}
367 public function getDepth() : int{}
368
369 public function seek(int $offset, int $length = -1) : void {}
370 /*
371 public function getSymbolTable() : SymbolTable {}
372 public function setSymbolTable(SymbolTable $table) : void {}
373 */
374 public function getValueOffset() : int {}
375 public function getValueLength() : int {}
376 }
377 namespace ion\Reader;
378 interface Buffer extends \ion\Reader {
379 public function getBuffer() : string;
380 }
381
382 namespace ion\Reader\Buffer;
383 class Reader extends \ion\Reader\Reader implements \ion\Reader\Buffer {
384 public function __construct(
385 string $buffer,
386 ?\ion\Reader\Options $options = null,
387 ) {}
388
389 public function getBuffer() : string {}
390 }
391
392 namespace ion\Reader;
393 interface Stream extends \ion\Reader {
394 /** @return resource */
395 public function getStream();
396 /** @param resource $stream */
397 public function resetStream($stream) : void;
398 /** @param resource $stream */
399 public function resetStreamWithLength($stream, int $length) : void;
400 }
401
402 namespace ion\Reader\Stream;
403 class Reader extends \ion\Reader\Reader implements \ion\Reader\Stream {
404 /** @param resource $stream */
405 public function __construct(
406 $stream,
407 ?\ion\Reader\Options $options = null,
408 ) {
409 }
410 /** @return resource */
411 public function getStream() {}
412 /** @param resource $stream */
413 public function resetStream($stream) : void {}
414 /** @param resource $stream */
415 public function resetStreamWithLength($stream, int $length) : void {}
416 }
417
418 namespace ion\Writer;
419 class Options {
420 public function __construct(
421 public readonly ?\ion\Catalog $catalog = null,
422 public readonly ?\ion\Decimal\Context $decimalContext = null,
423 public readonly bool $outputBinary = false,
424 public readonly bool $compactFloats = false,
425 public readonly bool $escapeNonAscii = false,
426 public readonly bool $prettyPrint = false,
427 public readonly bool $indentTabs = true,
428 public readonly int $indentSize = 2,
429 public readonly bool $smallContainersInline = true,
430 public readonly bool $suppressSystemValues = false,
431 public readonly bool $flushEveryValue = false,
432 public readonly int $maxContainerDepth = 10,
433 public readonly int $maxAnnotations = 10,
434 public readonly int $tempBufferSize = 0x4000,
435 public readonly int $allocationPageSize = 0x10000,
436 ) {}
437 }
438
439 namespace ion;
440 interface Writer {
441 public function writeNull() : void;
442 public function writeTypedNull(Type $type) : void;
443 public function writeBool(bool $value) : void;
444 public function writeInt(int|string $value) : void;
445 public function writeFloat(float $value) : void;
446 public function writeDecimal(Decimal|string $value) : void;
447 public function writeTimestamp(Timestamp|string $value) : void;
448 public function writeSymbol(Symbol|string $value) : void;
449 public function writeString(string $value) : void;
450 public function writeCLob(string $value) : void;
451 public function writeBLob(string $value) : void;
452
453 public function startLob(Type $type) : void;
454 public function appendLob(string $data) : void;
455 public function finishLob() : void;
456
457 public function startContainer(Type $type) : void;
458 public function finishContainer() : void;
459
460 public function writeFieldName(string $name) : void;
461
462 public function writeAnnotation(Symbol|string ...$annotation) : void;
463
464 public function getDepth() : int;
465 public function flush() : int;
466 public function finish() : int;
467
468 public function writeOne(Reader $reader) : void;
469 public function writeAll(Reader $reader) : void;
470
471 // public function getCatalog() : Catalog;
472 // public function setCatalog(Catalog $catalog) : void;
473
474 // public function getSymbolTable() : Symbol\Table;
475 // puvlic function setSymbolTable(Symbol\Table $table) : void;
476 }
477
478 namespace ion\Writer;
479 abstract class Writer implements \ion\Writer {
480 public function writeNull() : void {}
481 public function writeTypedNull(\ion\Type $type) : void {}
482 public function writeBool(bool $value) : void {}
483 public function writeInt(int|string $value) : void {}
484 public function writeFloat(float $value) : void {}
485 public function writeDecimal(\ion\Decimal|string $value) : void {}
486 public function writeTimestamp(\ion\Timestamp|string $value) : void {}
487 public function writeSymbol(\ion\Symbol|string $value) : void {}
488 public function writeString(string $value) : void {}
489 public function writeCLob(string $value) : void {}
490 public function writeBLob(string $value) : void {}
491
492 public function startLob(\ion\Type $type) : void {}
493 public function appendLob(string $data) : void {}
494 public function finishLob() : void {}
495
496 public function startContainer(\ion\Type $type) : void {}
497 public function finishContainer() : void {}
498
499 public function writeFieldName(string $name) : void {}
500
501 public function writeAnnotation(\ion\Symbol|string ...$annotation) : void {}
502
503 public function getDepth() : int {}
504 public function flush() : int {}
505 public function finish() : int {}
506
507 public function writeOne(\ion\Reader $reader) : void {}
508 public function writeAll(\ion\Reader $reader) : void {}
509 }
510
511 namespace ion\Writer;
512 interface Buffer extends \ion\Writer {
513 public function getBuffer() : string;
514 public function resetBuffer() : void;
515 }
516
517 namespace ion\Writer\Buffer;
518 class Writer extends \ion\Writer\Writer implements \ion\Writer\Buffer {
519 public function __construct(
520 ?\ion\Writer\Options $options = null,
521 ) {}
522
523 public function getBuffer() : string {}
524 public function resetBuffer() : void {}
525 }
526
527 namespace ion\Writer;
528 interface Stream extends \ion\Writer {
529 /** @return resource */
530 public function getStream();
531 }
532
533 namespace ion\Writer\Stream;
534 class Writer extends \ion\Writer\Writer implements \ion\Writer\Stream {
535 /** @param resource $stream */
536 public function __construct(
537 $stream,
538 ?\ion\Writer\Options $options = null,
539 ) {}
540 /** @return resource */
541 public function getStream() {}
542 }
543
544 namespace ion;
545 interface Serializer {
546 public function serialize(mixed $data) : string;
547 }
548 namespace ion;
549 interface Unserializer {
550 /** @param string|resource $data */
551 public function unserialize($data) : mixed;
552 }
553
554 namespace ion\Serializer;
555 class PHP implements \ion\Serializer {
556 public function __construct(
557 public readonly ?\ion\Writer\Options $writerOptions = null,
558 public readonly bool $multiSequence = false,
559 public readonly bool $callMagicSerialize = true,
560 public readonly ?string $callCustomSerialize = null,
561 ) {}
562 public function serialize(mixed $data) : string {}
563 }
564
565 namespace ion\Unserializer;
566 class PHP implements \ion\Unserializer {
567 public function __construct(
568 public readonly ?\ion\Reader\Options $readerOptions = null,
569 public readonly bool $multiSequence = false,
570 public readonly bool $callMagicUnserialize = true,
571 public readonly ?string $callCustomUnserialize = null,
572 ){}
573 /** @param string|resource $data */
574 public function unserialize($data) : mixed {}
575 }
576
577 namespace ion;
578 function serialize(mixed $data, ?Serializer $serializer = null) : string {}
579 /** @param string|resource $data */
580 function unserialize($data, ?Unserializer $unserializer = null) : mixed {}