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