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