4 * Amazon ION serialization format.
6 * @link https://github.com/awesomized/ext-ion
8 * @see https://github.com/amzn/ion-c amzn/ion-c
9 * @see https://amzn.github.io/ion-docs/ Amazon ION spec
11 * @generate-class-entries static
12 * @generate-function-entries static
18 * Serialize a PHP value as ION data.
20 * Serializes supported PHP values with the optionally provided \ion\Serializer:
28 * * object (incl. \Serializable, and classes implementing magic and custom __serialize)
30 * @param mixed $data PHP value(s).
31 * @param Serializer|array|null $serializer Custom Serializer (options).
32 * @return string serialized ION data
33 * @throws \ion\Exception
35 function serialize(mixed $data, Serializer|
array|
null $serializer = null) : string {}
38 * Unserialize ION data (stream) as PHP value(s).
40 * @param string|resource $data Serialized ION data, either as string buffer or stream.
41 * @param Unserializer|array|null $unserializer Custom Unserializer (options).
42 * @return mixed unserialized PHP values
43 * @throws \ion\Exception
45 function unserialize($data, Unserializer|
array|
null $unserializer = null) : mixed {}
48 * Serializer interface, used to customize ion\serialize()'s behavior.
50 interface Serializer
{
51 public function serialize(mixed $data, \ion\Writer|\ion\Writer\Options|
array|
null $writer = null) : mixed;
55 * Unserializer interface, used to customize ion\unserialize()'s behavior.
57 interface Unserializer
{
58 /** @param \ion\Reader|string|resource $data */
59 public function unserialize($data) : mixed;
63 * Base exception for the ION extension.
65 class Exception
extends \Exception
{
71 * The following special PHP classes are provided for some data types:
83 case Timestamp
= 0x600;
91 case Datagram
= 0xf00;
98 * @see https://amzn.github.io/ion-docs/docs/spec.html#symbol ION spec's symbol definition
99 * @see https://amzn.github.io/ion-docs/guides/symbols-guide.html ION spec's symbol guide
103 * Create an ION symbol.
105 public function __construct(
107 * The symbol's text representation.
109 public readonly ?
string $value = null,
111 * The symbols ID, referencing its location within a shared symbol table.
113 public readonly
int $sid = -1,
115 * The import location referencing a shared symbol table.
117 public readonly ?Symbol\ImportLocation
$importLocation = null,
121 * Compare two symbols for equality.
123 * Two symbols are considered equal, if either:
124 * * both are the same object or NULL
125 * * both values are NULL (unknown text), and both $importLocations match
126 * * both values match, regardless of $sid and $importLocation
128 * @param Symbol $symbol
129 * @return bool whether the two Symbols equal
131 public function equals(Symbol
$symbol): bool {}
132 public function __toString() : string {}
133 /** @alias ion\Symbol::__toString */
134 public function toString() : string {}
138 * The Catalog holds a collection of ion\Symbol\Table instances queried from ion\Reader and ion\Writer instances.
140 * @see https://amzn.github.io/ion-docs/docs/symbols.html#the-catalog the ION spec's symbol guide chapter on catalog.
142 class Catalog
implements \Countable
{
143 /** Internal cache. */
144 private array $symbolTables = [];
146 /** Create a new Catalog. */
147 public function __construct() {}
149 /** Count how many symbol tables the catalog holds. */
150 public function count() : int {}
153 * Add a shared symbol table to the catalog.
155 * @param Symbol\Table $table The new table to add.
157 public function add(Symbol\Table
$table) : void
{}
160 * Remove a shared symbol table from the catalog.
162 * @param Symbol\Table|string $table The symbol table to renmove.
163 * @return bool Success.
165 public function remove(Symbol\Table|
string $table) : bool {}
168 * Find a shared symbol table within the catalog.
170 * @param string $name The name of the symbol table.
171 * @param int $version The version the symbol table should match.
172 * @return Symbol\Table|null The symbol table found, if any.
174 public function find(string $name, int $version = 0) : ?Symbol\Table
{}
177 * Find a "best match" for a shared symbol table within the catalog.
179 * @param string $name The name of the symbol table,
180 * @param int $version The minimum version of the symbol table.
181 * @return Symbol\Table|null The symbol table found, if any.
183 public function findBest(string $name, int $version = 0) : ?Symbol\Table
{}
190 * @see https://amzn.github.io/ion-docs/docs/spec.html#blob the ION spec's BLob definition
191 * @see https://amzn.github.io/ion-docs/docs/spec.html#clob the ION sepc's CLob definition
195 * Create an ION large object.
197 public function __construct(
199 * The value of the large object.
201 public readonly
string $value,
203 * The type (CLob/BLob).
205 public readonly Type
$type = Type
::CLob
,
210 * An arbitrary precision fixed point decimal.
212 * @see ion\Decimal\Context
213 * @see https://amzn.github.io/ion-docs/docs/decimal.html the ION spec's decimal docs
217 * Create a new fixed point decimal.
219 public function __construct(
221 * The decimal number.
223 public readonly
string|
int $number,
225 * The decimal context.
227 public readonly ?Decimal\Context
$context = null,
231 * Check two decimals for equality.
233 * @param Decimal $decimal The decimal to compare to.
234 * @return bool Whether both decimals equal.
236 public function equals(Decimal
$decimal) : bool {}
239 * Check whether the decimal is actually a big integer.
240 * @return bool Whether the decimal is actually an integer.
242 public function isInt() : bool {}
244 public function __toString() : string {}
246 * Get the string representation of the decimal.
247 * @alias ion\Decimal::__toString
249 public function toString() : string {}
252 * Get the integer represention of the decimal.
253 * @throws \ion\Exception If the decimal is actually not an integer.
255 public function toInt() : int {}
260 * @see https://amzn.github.io/ion-docs/docs/spec.html#timestamp the ION spec's timestamp definition
261 * @see https://php.net/date PHP's date documentation
263 class Timestamp
extends \DateTime
{
265 * The timestamp's precision. See ion\Timestamp\Precision.
267 public readonly
int $precision;
269 * The timestamp's format. See ion\Timestamp\Format.
271 public readonly
string $format;
274 * Create a new ION timestamp.
276 * @param Timestamp\Precision|int $precision The timestamp's precision.
277 * @param Timestamp\Format|string|null $format The timestamp's format.
278 * @param string|null $datetime The timestamp's value.
279 * @param \DateTimeZone|string|null $timezone The timestamp's timezone.
281 public function __construct(
282 Timestamp\Precision|
int $precision,
283 Timestamp\Format|
string|
null $format = null,
284 ?
string $datetime = null,
285 \DateTimeZone|
string|
null $timezone = null,
288 public function __toString() : string {}
294 interface Reader
extends \RecursiveIterator
{
295 public function getType() : Type
;
296 public function hasAnnotations() : bool;
297 public function hasAnnotation(string $annotation) : bool;
298 public function isNull() : bool;
299 public function isInStruct() : bool;
300 public function getFieldName() : string;
301 public function getFieldNameSymbol() : Symbol
;
302 public function getAnnotations() : array;
303 public function getAnnotationSymbols() : array;
304 public function countAnnotations() : int;
305 public function getAnnotation(int $index) : string;
306 public function getAnnotationSymbol(int $index) : Symbol
;
308 public function readNull() : Type
;
309 public function readBool() : bool;
310 public function readInt() : int|
string;
311 public function readFloat() : float;
312 public function readDecimal() : Decimal
;
313 public function readTimestamp() : Timestamp
;
314 public function readSymbol() : Symbol
;
315 public function readString() : string;
316 /** @param ref $string */
317 public function readStringPart(&$string, int $length = 0x1000) : bool;
318 public function readLob() : string;
319 /** @param ref $string */
320 public function readLobPart(&$string, int $length = 0x1000) : bool;
322 public function getPosition() : int;
323 public function getDepth() : int;
325 public function seek(int $offset, int $length = -1) : void
;
327 public function getSymbolTable() : SymbolTable;
328 public function setSymbolTable(SymbolTable $table) : void;
330 public function getValueOffset() : int;
331 public function getValueLength() : int;
338 public function writeNull() : void
;
339 public function writeTypedNull(Type
$type) : void
;
340 public function writeBool(bool $value) : void
;
341 public function writeInt(int|
string $value) : void
;
342 public function writeFloat(float $value) : void
;
343 public function writeDecimal(Decimal|
string $value) : void
;
344 public function writeTimestamp(Timestamp|
string $value) : void
;
345 public function writeSymbol(Symbol|
string $value) : void
;
346 public function writeString(string $value) : void
;
347 public function writeCLob(string $value) : void
;
348 public function writeBLob(string $value) : void
;
350 public function startLob(Type
$type) : void
;
351 public function appendLob(string $data) : void
;
352 public function finishLob() : void
;
354 public function startContainer(Type
$type) : void
;
355 public function finishContainer() : void
;
357 public function writeFieldName(string $name) : void
;
359 public function writeAnnotation(Symbol|
string ...$annotation) : void
;
361 public function getDepth() : int;
362 public function flush() : int;
363 public function finish() : int;
365 // public function writeOne(Reader $reader) : void;
366 // public function writeAll(Reader $reader) : void;
368 // public function getCatalog() : Catalog;
369 // public function setCatalog(Catalog $catalog) : void;
371 // public function getSymbolTable() : Symbol\Table;
372 // puvlic function setSymbolTable(Symbol\Table $table) : void;
375 namespace ion\Symbol
;
378 * The import location (referring to a shared table) of a symbol.
380 class ImportLocation
{
382 * Create a new import location.
384 public function __construct(
386 * The name of the shared symbol table.
388 public readonly
string $name,
390 * The location (sid) of the symbol within the table.
392 public readonly
int $location,
397 * Base interface of built-in shared symbol tables.
401 * @return \ion\Symbol Instance of the symbol.
403 public function toSymbol() : \ion\Symbol
;
406 * @return int The symbol id.
408 public function toSID() : int;
411 * @return string The symbol's textual representation.
413 public function toString() : string;
417 * Base interface of an ION symbol table.
421 * Get the maximum symbol ID within the symbol table.
422 * @return int The maximum symbol ID.
424 public function getMaxId() : int;
427 * Add a symbol to the table.
429 * @param \ion\Symbol|string $symbol The symbol (value) to add.
430 * @return int The symbol ID.
432 public function add(\ion\Symbol|
string $symbol) : int;
435 * Find a symbol within the symbol table, including imports.
437 * @param string|int $id The ID or text of the symbol to find.
438 * @return \ion\Symbol|null The symbol found, if any.
440 public function find(string|
int $id) : ?\ion\Symbol
;
443 * Find a symbol within **only this** symbol table, ignoring imports.
445 * @param string|int $id The ID or text of the symbol to find.
446 * @return \ion\Symbol|null The symbol found, if any.
448 public function findLocal(string|
int $id) : ?\ion\Symbol
;
452 * The built-in ION system symbols.
454 enum System
: string implements \ion\Symbol\Enum
{
456 case Ivm_1_0
= '$ion_1_0';
457 case IonSymbolTable
= '$ion_symbol_table';
459 case Version
= 'version';
460 case Imports
= 'imports';
461 case Symbols
= 'symbols';
462 case MaxId
= 'max_id';
463 case SharedSymbolTable
= '$ion_shared_symbol_table';
465 /** @alias ion\Symbol\Enum::toSymbol */
466 public function toSymbol() : \ion\Symbol
{}
467 /** @alias ion\Symbol\Enum::toSID */
468 public function toSID() : int {}
469 /** @alias ion\Symbol\Enum::toString */
470 public function toString() : string {}
473 * Get the built-in ION system shared symbol table.
475 * @return Table\Shared The system symbol table.
477 public static function asTable() : Table\Shared
{}
481 * The built-in PHP symbols.
483 enum PHP
: string implements \ion\Symbol\Enum
{
485 case Reference
= 'R';
489 case ClassObject
= 'c';
490 case MagicObject
= 'O';
491 case CustomObject
= 'C';
493 case Serializable
= 'S';
495 /** @alias ion\Symbol\Enum::toSymbol */
496 public function toSymbol() : \ion\Symbol
{}
497 /** @alias ion\Symbol\Enum::toSID */
498 public function toSID() : int {}
499 /** @alias ion\Symbol\Enum::toString */
500 public function toString() : string {}
503 * Get the built-in PHP shared symbol table.
505 * @return Table\Shared The builtin PHP shared symbol table.
507 public static function asTable() : Table\Shared
{}
510 namespace ion\Symbol\Table
;
513 * A local symbol table.
515 * @see https://amzn.github.io/ion-docs/guides/symbols-guide.html the ION spec's symbol guide
516 * @see https://amzn.github.io/ion-docs/guides/cookbook.html#using-a-local-symbol-table the ION doc's cookbook
518 class Local
implements \ion\Symbol\Table
{
519 /** Internal cache. */
520 private array $imports = [];
521 /** Internal cache. */
522 private array $symbols = [];
525 * Create a local symbol table.
527 public function __construct() {}
530 * Import a symbol table.
532 * @param \ion\Symbol\Table $table The symbol table to import.
535 public function import(\ion\Symbol\Table
$table) : void
{}
537 /** @alias ion\Symbol\Table::getMaxId */
538 public function getMaxId() : int {}
540 /** @alias ion\Symbol\Table::add */
541 public function add(\ion\Symbol|
string $symbol) : int {}
542 /** @alias ion\Symbol\Table::find */
543 public function find(string|
int $id) : ?\ion\Symbol
{}
544 /** @alias ion\Symbol\Table::findLocal */
545 public function findLocal(string|
int $id) : ?\ion\Symbol
{}
549 * A shared symbol table.
551 * @see https://amzn.github.io/ion-docs/guides/symbols-guide.html the ION spec's symbol guide
552 * @see https://amzn.github.io/ion-docs/guides/cookbook.html#using-a-shared-symbol-table the ION doc's cookbook
554 class Shared
implements \ion\Symbol\Table
{
556 * Create a shared symbol table.
558 public function __construct(
560 * The name of the shared symbol table.
562 public readonly
string $name,
564 * The version of the shared symbol table.
566 public readonly
int $version = 1,
568 * Predefined list of symbols as array of strings.
570 ?
array $symbols = null,
573 /** Internal cache. */
574 private array $symbols = [];
576 /** @alias ion\Symbol\Table::getMaxId */
577 public function getMaxId() : int {}
579 /** @alias ion\Symbol\Table::add */
580 public function add(\ion\Symbol|
string $symbol) : int {}
581 /** @alias ion\Symbol\Table::find */
582 public function find(string|
int $id) : ?\ion\Symbol
{}
583 /** @alias ion\Symbol\Table::findLocal */
584 public function findLocal(string|
int $id) : ?\ion\Symbol
{}
587 namespace ion\Decimal
;
590 * An ion\Decimal's context.
594 * Create a new decimal context.
596 public function __construct(
600 public readonly
int $digits,
604 public readonly
int $eMax,
608 public readonly
int $eMin,
612 public readonly Context\Rounding|
int $round,
616 public readonly
bool $clamp,
620 * Create a context suitable for 32bit decimals.
622 public static function Dec32() : Context
{}
625 * Create a context suitable for 64bit decimals.
627 public static function Dec64() : Context
{}
630 * Create a context suitable for 128bit decimals.
632 public static function Dec128() : Context
{}
635 * Create a context with maximum settings.
636 * @param Context\Rounding|int $round Rounding mode.
638 public static function DecMax(Context\Rounding|
int $round = Context\Rounding
::HalfEven
) : Context
{}
641 namespace ion\Decimal\Context
;
646 enum Rounding
: int {
657 namespace ion\Timestamp
;
660 * Timestamp precision.
662 enum Precision
: int {
664 case Month
= 0x1|
0x2;
665 case Day
= 0x1|
0x2|
0x4;
666 case Min
= 0x1|
0x2|
0x4|
0x10;
667 case Sec
= 0x1|
0x2|
0x4|
0x10|
0x20;
668 case Frac
= 0x1|
0x2|
0x4|
0x10|
0x20|
0x40;
669 case MinTZ
= 0x1|
0x2|
0x4|
0x10|
0x80;
670 case SecTZ
= 0x1|
0x2|
0x4|
0x10|
0x20|
0x80;
671 case FracTZ
= 0x1|
0x2|
0x4|
0x10|
0x20|
0x40|
0x80;
677 enum Format
: string {
679 case Month
= "Y-m\T";
680 case Day
= "Y-m-d\T";
681 case Min
= "Y-m-d\TH:i";
682 case Sec
= "Y-m-d\TH:i:s";
683 case Frac
= "Y-m-d\TH:i:s.v";
684 case MinTZ
= "Y-m-d\TH:iP";
685 case SecTZ
= "Y-m-d\TH:i:sP";
686 case FracTZ
= "Y-m-d\TH:i:s.vP";
689 namespace ion\Reader
;
695 public function __construct(
697 * ION catalog to use for symbol lookup.
699 public readonly ?\ion\Catalog
$catalog = null,
701 * Decimal context to use.
703 public readonly ?\ion\Decimal\Context
$decimalContext = null,
705 * Callback as function(\ion\Reader):void called upon local symbol table context change.
707 public readonly ?\Closure
$onContextChange = null,
709 * Whether to return otherwise hidden system values.
711 public readonly
bool $returnSystemValues = false,
713 * The maximum depth of nested containers.
715 public readonly
int $maxContainerDepth = 10,
717 * The maximum number of annotations allowed on a single value.
719 public readonly
int $maxAnnotations = 10,
721 * The maximum number of bytes of all annotations on a single value.
723 public readonly
int $annotationBufferSize = 0x4000,
725 * The maximum number of bytes of a symbol/value/chunk.
727 public readonly
int $tempBufferSize = 0x4000,
729 * Whether to skip UTF-8 validation.
731 public readonly
bool $skipCharacterValidation = false,
736 * Base implementation of ION readers.
738 abstract class Reader
implements \ion\Reader
{
742 public readonly ?Options
$options;
744 public function hasChildren() : bool {}
745 public function getChildren() : \ion\Reader
{}
747 public function rewind() : void
{}
748 public function next() : void
{}
749 public function valid() : bool {}
750 public function key() : mixed {}
751 public function current() : mixed {}
753 public function getType() : \ion\Type
{}
754 public function hasAnnotations() : bool {}
755 public function hasAnnotation(string $annotation) : bool {}
756 public function isNull() : bool {}
757 public function isInStruct() : bool {}
758 public function getFieldName() : string {}
759 public function getFieldNameSymbol() : \ion\Symbol
{}
760 public function getAnnotations() : array {}
761 public function getAnnotationSymbols() : array {}
762 public function countAnnotations() : int {}
763 public function getAnnotation(int $index) : string {}
764 public function getAnnotationSymbol(int $index) : \ion\Symbol
{}
766 public function readNull() : \ion\Type
{}
767 public function readBool() : bool {}
768 public function readInt() : int|
string {}
769 public function readFloat() : float {}
770 public function readDecimal() : \ion\Decimal
{}
771 public function readTimestamp() : \ion\Timestamp
{}
772 public function readSymbol() : \ion\Symbol
{}
773 public function readString() : string {}
774 /** @param ref $string */
775 public function readStringPart(&$string, int $length = 0x1000) : bool {}
776 public function readLob() : string {}
777 /** @param ref $string */
778 public function readLobPart(&$string, int $length = 0x1000) : bool {}
780 public function getPosition() : int {}
781 public function getDepth() : int{}
783 public function seek(int $offset, int $length = -1) : void
{}
785 public function getSymbolTable() : SymbolTable {}
786 public function setSymbolTable(SymbolTable $table) : void {}
788 public function getValueOffset() : int {}
789 public function getValueLength() : int {}
793 * ION string buffer reader API.
795 interface Buffer
extends \ion\Reader
{
797 * Get the buffer read from.
799 * @return string The buffer read from.
801 public function getBuffer() : string;
805 * ION stream reader API.
807 interface Stream
extends \ion\Reader
{
809 * Get the stream read from.
811 * @return resource The stream read from.
813 public function getStream();
816 * Reset the stream read from.
818 * @param resource $stream The new stream to from.
820 public function resetStream($stream) : void
;
823 * Reset the stream read from, limiting length to read.
825 * @param resource $stream The stream to read from.
826 * @param int $length The maximum length to read from $stream.
828 public function resetStreamWithLength($stream, int $length) : void
;
831 namespace ion\Reader\Buffer
;
836 class Reader
extends \ion\Reader\Reader
implements \ion\Reader\Buffer
{
838 * Create a new string buffer reader.
840 * @param string $buffer The buffer to read from.
841 * @param \ion\Reader\Options|array|null $options Reader options.
843 public function __construct(
845 \ion\Reader\Options|
array|
null $options = null,
848 public function getBuffer() : string {}
851 namespace ion\Reader\Stream
;
856 class Reader
extends \ion\Reader\Reader
implements \ion\Reader\Stream
{
858 * Create a new stream reader.
860 * @param resource $stream The stream to read from.
861 * @param \ion\Reader\Options|array|null $options Reader options.
863 public function __construct(
865 \ion\Reader\Options|
array|
null $options = null,
869 * Get the stream read from.
871 * @return resource The stream read from.
873 public function getStream() {}
875 /** @param resource $stream */
876 public function resetStream($stream) : void
{}
877 /** @param resource $stream */
878 public function resetStreamWithLength($stream, int $length) : void
{}
881 namespace ion\Writer
;
884 * ION writer options.
888 * Create custom ION writer options.
890 public function __construct(
892 * ION catalog to use for symbol lookup.
894 public readonly ?\ion\Catalog
$catalog = null,
896 * Decimal context to use.
898 public readonly ?\ion\Decimal\Context
$decimalContext = null,
900 * Whether to output binary ION.
902 public readonly
bool $outputBinary = false,
904 * Whether to write doubles which fit in 32 bits as floats.
906 public readonly
bool $compactFloats = false,
908 * Whether to slash-escape all non ASCII bytes.
910 public readonly
bool $escapeNonAscii = false,
912 * Whether to produce pretty-printed output.
914 public readonly
bool $prettyPrint = false,
916 * Whether to indent with tabs, when pretty-printing.
918 public readonly
bool $indentTabs = true,
920 * The number of spaces to use for indentation instead of tabs, when pretty-printing.
922 public readonly
int $indentSize = 2,
924 * Whether to immediately flush every value written.
926 public readonly
bool $flushEveryValue = false,
928 * Maximum depth of nested containers.
930 public readonly
int $maxContainerDepth = 10,
932 * The maximum number of annotations allowed on a single value.
934 public readonly
int $maxAnnotations = 10,
936 * Temporary buffer size.
938 public readonly
int $tempBufferSize = 0x4000,
943 * Base implementation of common functionality of ION writers.
945 abstract class Writer
implements \ion\Writer
{
946 public function writeNull() : void
{}
947 public function writeTypedNull(\ion\Type
$type) : void
{}
948 public function writeBool(bool $value) : void
{}
949 public function writeInt(int|
string $value) : void
{}
950 public function writeFloat(float $value) : void
{}
951 public function writeDecimal(\ion\Decimal|
string $value) : void
{}
952 public function writeTimestamp(\ion\Timestamp|
string $value) : void
{}
953 public function writeSymbol(\ion\Symbol|
string $value) : void
{}
954 public function writeString(string $value) : void
{}
955 public function writeCLob(string $value) : void
{}
956 public function writeBLob(string $value) : void
{}
958 public function startLob(\ion\Type
$type) : void
{}
959 public function appendLob(string $data) : void
{}
960 public function finishLob() : void
{}
962 public function startContainer(\ion\Type
$type) : void
{}
963 public function finishContainer() : void
{}
965 public function writeFieldName(string $name) : void
{}
967 public function writeAnnotation(\ion\Symbol|
string ...$annotation) : void
{}
969 public function getDepth() : int {}
970 public function flush() : int {}
971 public function finish() : int {}
973 // public function writeOne(\ion\Reader $reader) : void {}
974 // public function writeAll(\ion\Reader $reader) : void {}
978 * ION buffer writer API.
980 interface Buffer
extends \ion\Writer
{
982 * Get the buffer written to.
984 * @reeturn string The buffer written so far.
986 public function getBuffer() : string;
989 * Reset the buffer written to.
991 public function resetBuffer() : void
;
995 * ION stream writer API.
997 interface Stream
extends \ion\Writer
{
999 * Get the stream being written to.
1002 public function getStream();
1005 namespace ion\Writer\Buffer
;
1010 class Writer
extends \ion\Writer\Writer
implements \ion\Writer\Buffer
{
1012 * Create a new buffer writer.
1014 * @param \ion\Writer\Options|array|null $options Writer options.
1016 public function __construct(
1017 \ion\Writer\Options|
array|
null $options = null,
1020 public function getBuffer() : string {}
1021 public function resetBuffer() : void
{}
1024 namespace ion\Writer\Stream
;
1027 * ION stream writer.
1029 class Writer
extends \ion\Writer\Writer
implements \ion\Writer\Stream
{
1031 * Create a new stream writer.
1033 * @param resource $stream The stream to write to.
1034 * @param \ion\Writer\Options|array|null $options Writer options.
1036 public function __construct(
1038 \ion\Writer\Options|
array|
null $options = null,
1043 public function getStream() {}
1046 namespace ion\Serializer
;
1048 * Serializer implementation
1050 class Serializer
implements \ion\Serializer
{
1052 * Create a new ION serializer.
1054 public function __construct(
1056 * Whether to write the top level array as multiple ION sequences.
1058 public readonly
bool $multiSequence = false,
1060 * Whether to call magic __serialize() methods on objects to serialize.
1062 public readonly
bool $callMagicSerialize = true,
1064 * Whether and which custom serialize method to call on objects to serialize.
1066 public readonly ?
string $callCustomSerialize = null,
1069 public function serialize(mixed $data, \ion\Writer|\ion\Writer\Options|
array|
null $writer = null) : mixed {}
1072 namespace ion\Unserializer
;
1075 * Unserializer implementation
1077 class Unserializer
implements \ion\Unserializer
{
1079 * Create a new ION unserializer.
1081 public function __construct(
1083 * Whether to continue reading multiple ION sequences after the first one.
1085 public readonly
bool $multiSequence = false,
1087 * Whether to call magic __unserialize() methods on objects to unserialize.
1089 public readonly
bool $callMagicUnserialize = true,
1091 * Whether and which custom unserialize method to call on objects to unserialize.
1093 public readonly ?
string $callCustomUnserialize = null,
1096 /** @param \ion\Reader|string|resource $data */
1097 public function unserialize($data) : mixed {}