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