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 * * objects (incl. \Serializable, and classes implementing magic and custom __serialize)
30 * @param mixed $data PHP value(s).
31 * @param Serializer|null $serializer Custom serializer.
32 * @return string serialized ION data
33 * @throws ion\Exception
35 function serialize(mixed $data, ?Serializer
$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 * @return mixed unserialized PHP values
42 * @throws ion\Exception
44 function unserialize($data, ?Unserializer
$unserializer = null) : mixed {}
47 * Serializer interface, used to customize ion\serialize()'s behavior.
49 interface Serializer
{
50 public function serialize(mixed $data) : string;
54 * Unserializer interface, used to customize ion\unserialize()'s behavior.
56 interface Unserializer
{
57 /** @param string|resource $data */
58 public function unserialize($data) : mixed;
62 * Base exception for the ION extension.
64 class Exception
extends \Exception
{
70 * The following special PHP classes are provided for some data types:
82 case Timestamp
= 0x600;
90 case Datagram
= 0xf00;
97 * @see https://amzn.github.io/ion-docs/docs/spec.html#symbol ION spec's symbol definition
98 * @see https://amzn.github.io/ion-docs/guides/symbols-guide.html ION spec's symbol guide
102 * Create an ION symbol.
104 public function __construct(
106 * The symbol's text representation.
108 public readonly ?
string $value = null,
110 * The symbols ID, referencing its location within a shared symbol table.
112 public readonly
int $sid = -1,
114 * The import location referencing a shared symbol table.
116 public readonly ?Symbol\ImportLocation
$importLocation = null,
120 * Compare two symbols for equality.
122 * Two symbols are considered equal, if either:
123 * * both are the same object or NULL
124 * * both values are NULL (unknown text), and both $importLocations match
125 * * both values match, regardless of $sid and $importLocation
127 * @param Symbol $symbol
128 * @return bool whether the two Symbols equal
130 public function equals(Symbol
$symbol): bool {}
131 public function __toString() : string {}
132 /** @alias ion\Symbol::__toString */
133 public function toString() : string {}
137 * The Catalog holds a collection of ion\Symbol\Table instances queried from ion\Reader and ion\Writer instances.
139 * @see https://amzn.github.io/ion-docs/docs/symbols.html#the-catalog the ION spec's symbol guide chapter on catalog.
141 class Catalog
implements \Countable
{
142 /** Internal cache. */
143 private array $symbolTables = [];
145 /** Create a new Catalog. */
146 public function __construct() {}
148 /** Count how many symbol tables the catalog holds. */
149 public function count() : int {}
152 * Add a shared symbol table to the catalog.
154 * @param Symbol\Table $table The new table to add.
156 public function add(Symbol\Table
$table) : void
{}
159 * Remove a shared symbol table from the catalog.
161 * @param Symbol\Table|string $table The symbol table to renmove.
162 * @return bool Success.
164 public function remove(Symbol\Table|
string $table) : bool {}
167 * Find a shared symbol table within the catalog.
169 * @param string $name The name of the symbol table.
170 * @param int $version The version the symbol table should match.
171 * @return Symbol\Table|null The symbol table found, if any.
173 public function find(string $name, int $version = 0) : ?Symbol\Table
{}
176 * Find a "best match" for a shared symbol table within the catalog.
178 * @param string $name The name of the symbol table,
179 * @param int $version The minimum version of the symbol table.
180 * @return Symbol\Table|null The symbol table found, if any.
182 public function findBest(string $name, int $version = 0) : ?Symbol\Table
{}
189 * @see https://amzn.github.io/ion-docs/docs/spec.html#blob the ION spec's BLob definition
190 * @see https://amzn.github.io/ion-docs/docs/spec.html#clob the ION sepc's CLob definition
194 * Create an ION large object.
196 public function __construct(
198 * The value of the large object.
200 public readonly
string $value,
202 * The type (CLob/BLob).
204 public readonly Type
$type = Type
::CLob
,
209 * An arbitrary precision fixed point decimal.
211 * @see ion\Decimal\Context
212 * @see https://amzn.github.io/ion-docs/docs/decimal.html the ION spec's decimal docs
216 * Create a new fixed point decimal.
218 public function __construct(
220 * The decimal number.
222 public readonly
string|
int $number,
224 * The decimal context.
226 public readonly ?Decimal\Context
$context = null,
230 * Check two decimals for equality.
232 * @param Decimal $decimal The decimal to compare to.
233 * @return bool Whether both decimals equal.
235 public function equals(Decimal
$decimal) : bool {}
238 * Check whether the decimal is actually a big integer.
239 * @return bool Whether the decimal is actually an integer.
241 public function isInt() : bool {}
243 public function __toString() : string {}
245 * Get the string representation of the decimal.
246 * @alias ion\Decimal::__toString
248 public function toString() : string {}
251 * Get the integer represention of the decimal.
252 * @throws \ion\Exception If the decimal is actually not an integer.
254 public function toInt() : int {}
259 * @see https://amzn.github.io/ion-docs/docs/spec.html#timestamp the ION sepc's timestamp definintion
260 * @see https://php.net/date PHP's date documentation
262 class Timestamp
extends \DateTime
{
264 * The timestamp's precision. See ion\Timestamp\Precision.
266 public readonly
int $precision;
268 * The timestamp's format. See ion\Timestamp\Format.
270 public readonly
string $format;
273 * Create a new ION timestamp.
275 * @param Timestamp\Precision|int $precision The timestamp's precision.
276 * @param Timestamp\Format|string|null $format The timestamp's format.
277 * @param string|null $datetime The timestamp's value.
278 * @param \DateTimeZone|null $timezone The timestamp's timezone.
280 public function __construct(
281 Timestamp\Precision|
int $precision,
282 Timestamp\Format|
string|
null $format = null,
283 ?
string $datetime = null,
284 ?\DateTimeZone
$timezone = null,
287 public function __toString() : string {}
293 interface Reader
extends \RecursiveIterator
{
294 public function getType() : Type
;
295 public function hasAnnotations() : bool;
296 public function hasAnnotation(string $annotation) : bool;
297 public function isNull() : bool;
298 public function isInStruct() : bool;
299 public function getFieldName() : string;
300 public function getFieldNameSymbol() : Symbol
;
301 public function getAnnotations() : array;
302 public function getAnnotationSymbols() : array;
303 public function countAnnotations() : int;
304 public function getAnnotation(int $index) : string;
305 public function getAnnotationSymbol(int $index) : Symbol
;
307 public function readNull() : Type
;
308 public function readBool() : bool;
309 public function readInt() : int|
string;
310 public function readFloat() : float;
311 public function readDecimal() : Decimal
;
312 public function readTimestamp() : Timestamp
;
313 public function readSymbol() : Symbol
;
314 public function readString() : string;
315 /** @param ref $string */
316 public function readStringPart(&$string, int $length = 0x1000) : bool;
317 public function readLob() : string;
318 /** @param ref $string */
319 public function readLobPart(&$string, int $length = 0x1000) : bool;
321 public function getPosition() : int;
322 public function getDepth() : int;
324 public function seek(int $offset, int $length = -1) : void
;
326 public function getSymbolTable() : SymbolTable;
327 public function setSymbolTable(SymbolTable $table) : void;
329 public function getValueOffset() : int;
330 public function getValueLength() : int;
337 public function writeNull() : void
;
338 public function writeTypedNull(Type
$type) : void
;
339 public function writeBool(bool $value) : void
;
340 public function writeInt(int|
string $value) : void
;
341 public function writeFloat(float $value) : void
;
342 public function writeDecimal(Decimal|
string $value) : void
;
343 public function writeTimestamp(Timestamp|
string $value) : void
;
344 public function writeSymbol(Symbol|
string $value) : void
;
345 public function writeString(string $value) : void
;
346 public function writeCLob(string $value) : void
;
347 public function writeBLob(string $value) : void
;
349 public function startLob(Type
$type) : void
;
350 public function appendLob(string $data) : void
;
351 public function finishLob() : void
;
353 public function startContainer(Type
$type) : void
;
354 public function finishContainer() : void
;
356 public function writeFieldName(string $name) : void
;
358 public function writeAnnotation(Symbol|
string ...$annotation) : void
;
360 public function getDepth() : int;
361 public function flush() : int;
362 public function finish() : int;
364 // public function writeOne(Reader $reader) : void;
365 // public function writeAll(Reader $reader) : void;
367 // public function getCatalog() : Catalog;
368 // public function setCatalog(Catalog $catalog) : void;
370 // public function getSymbolTable() : Symbol\Table;
371 // puvlic function setSymbolTable(Symbol\Table $table) : void;
374 namespace ion\Symbol
;
377 * The import location (referring to a shared table= of a symbol.
379 class ImportLocation
{
381 * Create a new import location.
383 public function __construct(
385 * The name of the shared symbol table.
387 public readonly
string $name,
389 * The location (sid) of the symbol within the table.
391 public readonly
int $location,
396 * Base interface of built-in shared symbol tables.
400 * @return \ion\Symbol Instance of the symbol.
402 public function toSymbol() : \ion\Symbol
;
405 * @return int The symbol id.
407 public function toSID() : int;
410 * @return string The symbol's textual representation.
412 public function toString() : string;
416 * Base interface of an ION symbol table.
420 * Get the maximum symbol ID within the symbol table.
421 * @return int The maximum symbol ID.
423 public function getMaxId() : int;
426 * Add a symbol to the table.
428 * @param \ion\Symbol|string $symbol The symbol (value) to add.
429 * @return int The symbol ID.
431 public function add(\ion\Symbol|
string $symbol) : int;
434 * Find a symbol within the symbol table, including imports.
436 * @param string|int $id The ID or text of the symbol to find.
437 * @return \ion\Symbol|null The symbol found, if any.
439 public function find(string|
int $id) : ?\ion\Symbol
;
442 * Find a symbol within **only this** symbol table, ignoring imports.
444 * @param string|int $id The ID or text of the symbol to find.
445 * @return \ion\Symbol|null The symbol found, if any.
447 public function findLocal(string|
int $id) : ?\ion\Symbol
;
450 namespace ion\Symbol\Table
;
453 * Get the built-in PHP shared symbol table.
455 * @see \ion\Symbol\Table\PHP
456 * @return \ion\Symbol\Table The builtin PHP shared symbol table.
458 function PHP() : \ion\Symbol\Table
{}
461 * Get the built-in ION system shared symbol table.
463 * @see \ion\Symbol\Table\System
464 * @return \ion\Symbol\Table The builtin ION system shared symbol table.
466 function System() : \ion\Symbol\Table
{}
469 * The built-in ION system symbols.
471 enum System
: string implements \ion\Symbol\Enum
{
473 case Ivm_1_0
= '$ion_1_0';
474 case IonSymbolTable
= '$ion_symbol_table';
476 case Version
= 'version';
477 case Imports
= 'imports';
478 case Symbols
= 'symbols';
479 case MaxId
= 'max_id';
480 case SharedSymbolTable
= '$ion_shared_symbol_table';
482 /** @alias ion\Symbol\Enum::toSymbol */
483 public function toSymbol() : \ion\Symbol
{}
484 /** @alias ion\Symbol\Enum::toSID */
485 public function toSID() : int {}
486 /** @alias ion\Symbol\Enum::toString */
487 public function toString() : string {}
491 * The built-in PHP symbols.
493 enum PHP
: string implements \ion\Symbol\Enum
{
495 case Reference
= 'R';
499 case ClassObject
= 'c';
500 case MagicObject
= 'O';
501 case CustomObject
= 'C';
503 case Serializable
= 'S';
505 /** @alias ion\Symbol\Enum::toSymbol */
506 public function toSymbol() : \ion\Symbol
{}
507 /** @alias ion\Symbol\Enum::toSID */
508 public function toSID() : int {}
509 /** @alias ion\Symbol\Enum::toString */
510 public function toString() : string {}
514 * A local symbol table.
516 * @see https://amzn.github.io/ion-docs/guides/symbols-guide.html the ION spec's symbol guide
517 * @see https://amzn.github.io/ion-docs/guides/cookbook.html#using-a-local-symbol-table the ION doc's cookbook
519 class Local
implements \ion\Symbol\Table
{
520 /** Internal cache. */
521 private array $imports = [];
522 /** Internal cache. */
523 private array $symbols = [];
526 * Create a local symbol table.
528 public function __construct() {}
531 * Import a symbol table.
533 * @param \ion\Symbol\Table $table The symbol table to import.
536 public function import(\ion\Symbol\Table
$table) : void
{}
538 /** @alias ion\Symbol\Table::getMaxId */
539 public function getMaxId() : int {}
541 /** @alias ion\Symbol\Table::add */
542 public function add(\ion\Symbol|
string $symbol) : int {}
543 /** @alias ion\Symbol\Table::find */
544 public function find(string|
int $id) : ?\ion\Symbol
{}
545 /** @alias ion\Symbol\Table::findLocal */
546 public function findLocal(string|
int $id) : ?\ion\Symbol
{}
550 * A shared symbol table.
552 * @see https://amzn.github.io/ion-docs/guides/symbols-guide.html the ION spec's symbol guide
553 * @see https://amzn.github.io/ion-docs/guides/cookbook.html#using-a-shared-symbol-table the ION doc's cookbook
555 class Shared
implements \ion\Symbol\Table
{
557 * Create a shared symbol table.
559 public function __construct(
561 * The name of the shared symbol table.
563 public readonly
string $name,
565 * The version of the shared symbol table.
567 public readonly
int $version = 1,
569 * Predefined list of symbols as array of strings.
571 ?
array $symbols = null,
574 /** Internal cache. */
575 private array $symbols = [];
577 /** @alias ion\Symbol\Table::getMaxId */
578 public function getMaxId() : int {}
580 /** @alias ion\Symbol\Table::add */
581 public function add(\ion\Symbol|
string $symbol) : int {}
582 /** @alias ion\Symbol\Table::find */
583 public function find(string|
int $id) : ?\ion\Symbol
{}
584 /** @alias ion\Symbol\Table::findLocal */
585 public function findLocal(string|
int $id) : ?\ion\Symbol
{}
588 namespace ion\Decimal
;
591 * An ion\Decimal's context.
595 * Create a new decimal context.
597 public function __construct(
601 public readonly
int $digits,
605 public readonly
int $eMax,
609 public readonly
int $eMin,
613 public readonly Context\Rounding|
int $round,
617 public readonly
bool $clamp,
621 * Create a context suitable for 32bit decimals.
623 public static function Dec32() : Context
{}
626 * Create a context suitable for 64bit decimals.
628 public static function Dec64() : Context
{}
631 * Create a context suitable for 128bit decimals.
633 public static function Dec128() : Context
{}
636 * Create a context with maximum settings.
637 * @param Context\Rounding|int $round Rounding mode.
639 public static function DecMax(Context\Rounding|
int $round = Context\Rounding
::HalfEven
) : Context
{}
642 namespace ion\Decimal\Context
;
647 enum Rounding
: int {
658 namespace ion\Timestamp
;
661 * Timestamp precision.
663 enum Precision
: int {
665 case Month
= 0x1|
0x2;
666 case Day
= 0x1|
0x2|
0x4;
667 case Min
= 0x1|
0x2|
0x4|
0x10;
668 case Sec
= 0x1|
0x2|
0x4|
0x10|
0x20;
669 case Frac
= 0x1|
0x2|
0x4|
0x10|
0x20|
0x40;
670 case MinTZ
= 0x1|
0x2|
0x4|
0x10|
0x80;
671 case SecTZ
= 0x1|
0x2|
0x4|
0x10|
0x20|
0x80;
672 case FracTZ
= 0x1|
0x2|
0x4|
0x10|
0x20|
0x40|
0x80;
678 enum Format
: string {
680 case Month
= "Y-m\T";
681 case Day
= "Y-m-d\T";
682 case Min
= "Y-m-d\TH:i";
683 case Sec
= "Y-m-d\TH:i:s";
684 case Frac
= "Y-m-d\TH:i:s.v";
685 case MinTZ
= "Y-m-d\TH:iP";
686 case SecTZ
= "Y-m-d\TH:i:sP";
687 case FracTZ
= "Y-m-d\TH:i:s.vP";
690 namespace ion\Reader
;
696 public function __construct(
698 * ION catalog to use for symbol lookup.
700 public readonly ?\ion\Catalog
$catalog = null,
702 * Decimal context to use.
704 public readonly ?\ion\Decimal\Context
$decimalContext = null,
706 * Callback as function(\ion\Reader):void called upon local symbol table context change.
708 public readonly ?\Closure
$onContextChange = null,
710 * Whether to return otherwise hidden system values.
712 public readonly
bool $returnSystemValues = false,
714 * The maximum depth of nested containers.
716 public readonly
int $maxContainerDepth = 10,
718 * The maximum number of annotations allowed on a single value.
720 public readonly
int $maxAnnotations = 10,
722 * The maximum number of bytes of all annotations on a single value.
724 public readonly
int $annotationBufferSize = 0x4000,
726 * The maximum number of bytes of a symbol/value/chunk.
728 public readonly
int $tempBufferSize = 0x4000,
730 * Whether to skip UTF-8 validation.
732 public readonly
bool $skipCharacterValidation = false,
737 * Base implementation of ION readers.
739 abstract class Reader
implements \ion\Reader
{
743 public readonly ?Options
$options;
745 public function hasChildren() : bool {}
746 public function getChildren() : \ion\Reader
{}
748 public function rewind() : void
{}
749 public function next() : void
{}
750 public function valid() : bool {}
751 public function key() : mixed {}
752 public function current() : mixed {}
754 public function getType() : \ion\Type
{}
755 public function hasAnnotations() : bool {}
756 public function hasAnnotation(string $annotation) : bool {}
757 public function isNull() : bool {}
758 public function isInStruct() : bool {}
759 public function getFieldName() : string {}
760 public function getFieldNameSymbol() : \ion\Symbol
{}
761 public function getAnnotations() : array {}
762 public function getAnnotationSymbols() : array {}
763 public function countAnnotations() : int {}
764 public function getAnnotation(int $index) : string {}
765 public function getAnnotationSymbol(int $index) : \ion\Symbol
{}
767 public function readNull() : \ion\Type
{}
768 public function readBool() : bool {}
769 public function readInt() : int|
string {}
770 public function readFloat() : float {}
771 public function readDecimal() : \ion\Decimal
{}
772 public function readTimestamp() : \ion\Timestamp
{}
773 public function readSymbol() : \ion\Symbol
{}
774 public function readString() : string {}
775 /** @param ref $string */
776 public function readStringPart(&$string, int $length = 0x1000) : bool {}
777 public function readLob() : string {}
778 /** @param ref $string */
779 public function readLobPart(&$string, int $length = 0x1000) : bool {}
781 public function getPosition() : int {}
782 public function getDepth() : int{}
784 public function seek(int $offset, int $length = -1) : void
{}
786 public function getSymbolTable() : SymbolTable {}
787 public function setSymbolTable(SymbolTable $table) : void {}
789 public function getValueOffset() : int {}
790 public function getValueLength() : int {}
794 * ION string buffer reader API.
796 interface Buffer
extends \ion\Reader
{
798 * Get the buffer read from.
800 * @return string The buffer read from.
802 public function getBuffer() : string;
806 * ION stream reader API.
808 interface Stream
extends \ion\Reader
{
810 * Get the stream read from.
812 * @return resource The stream read from.
814 public function getStream();
817 * Reset the stream read from.
819 * @param resource $stream The new stream to from.
821 public function resetStream($stream) : void
;
824 * Reset the stream read from, limiting length to read.
826 * @param resource $stream The stream to read from.
827 * @param int $length The maximum length to read from $stream.
829 public function resetStreamWithLength($stream, int $length) : void
;
832 namespace ion\Reader\Buffer
;
835 * ION string buffer reader.
837 class Reader
extends \ion\Reader\Reader
implements \ion\Reader\Buffer
{
839 * Create a new string buffer reader.
841 * @param string $buffer The buffer to read from.
842 * @param \ion\Reader\Options|null $options Reader options.
844 public function __construct(
846 ?\ion\Reader\Options
$options = null,
849 public function getBuffer() : string {}
852 namespace ion\Reader\Stream
;
857 class Reader
extends \ion\Reader\Reader
implements \ion\Reader\Stream
{
859 * Create a new stream reader.
861 * @param resource $stream The stream to read from.
862 * @param \ion\Reader\Options|null $options Reader options.
864 public function __construct(
866 ?\ion\Reader\Options
$options = null,
870 * Get the stream read from.
872 * @return resource The stream read from.
874 public function getStream() {}
876 /** @param resource $stream */
877 public function resetStream($stream) : void
{}
878 /** @param resource $stream */
879 public function resetStreamWithLength($stream, int $length) : void
{}
882 namespace ion\Writer
;
885 * ION writer options.
889 * Create custom ION writer options.
891 public function __construct(
893 * ION catalog to use for symbol lookup.
895 public readonly ?\ion\Catalog
$catalog = null,
897 * Decimal context to use.
899 public readonly ?\ion\Decimal\Context
$decimalContext = null,
901 * Whether to output binary ION.
903 public readonly
bool $outputBinary = false,
905 * Whether to write doubles which fit in 32 bits as floats.
907 public readonly
bool $compactFloats = false,
909 * Whether to slash-escape all non ASCII bytes.
911 public readonly
bool $escapeNonAscii = false,
913 * Whether to produce pretty-printed output.
915 public readonly
bool $prettyPrint = false,
917 * Whether to indent with tabs, when pretty-printing.
919 public readonly
bool $indentTabs = true,
921 * The number of spaces to use for indentation instead of tabs, when pretty-printing.
923 public readonly
int $indentSize = 2,
925 * Whether to immediately flush every value written.
927 public readonly
bool $flushEveryValue = false,
929 * Maximum depth of nested containers.
931 public readonly
int $maxContainerDepth = 10,
933 * The maximum number of annotations allowed on a single value.
935 public readonly
int $maxAnnotations = 10,
937 * Temporary buffer size.
939 public readonly
int $tempBufferSize = 0x4000,
944 * Base implementation of common functionality of ION writers.
946 abstract class Writer
implements \ion\Writer
{
947 public function writeNull() : void
{}
948 public function writeTypedNull(\ion\Type
$type) : void
{}
949 public function writeBool(bool $value) : void
{}
950 public function writeInt(int|
string $value) : void
{}
951 public function writeFloat(float $value) : void
{}
952 public function writeDecimal(\ion\Decimal|
string $value) : void
{}
953 public function writeTimestamp(\ion\Timestamp|
string $value) : void
{}
954 public function writeSymbol(\ion\Symbol|
string $value) : void
{}
955 public function writeString(string $value) : void
{}
956 public function writeCLob(string $value) : void
{}
957 public function writeBLob(string $value) : void
{}
959 public function startLob(\ion\Type
$type) : void
{}
960 public function appendLob(string $data) : void
{}
961 public function finishLob() : void
{}
963 public function startContainer(\ion\Type
$type) : void
{}
964 public function finishContainer() : void
{}
966 public function writeFieldName(string $name) : void
{}
968 public function writeAnnotation(\ion\Symbol|
string ...$annotation) : void
{}
970 public function getDepth() : int {}
971 public function flush() : int {}
972 public function finish() : int {}
974 // public function writeOne(\ion\Reader $reader) : void {}
975 // public function writeAll(\ion\Reader $reader) : void {}
979 * ION buffer writer API.
981 interface Buffer
extends \ion\Writer
{
983 * Get the buffer written to.
985 * @reeturn string The buffer written so far.
987 public function getBuffer() : string;
990 * Reset the buffer written to.
992 public function resetBuffer() : void
;
996 * ION stream writer API.
998 interface Stream
extends \ion\Writer
{
1000 * Get the stream being written to.
1003 public function getStream();
1006 namespace ion\Writer\Buffer
;
1011 class Writer
extends \ion\Writer\Writer
implements \ion\Writer\Buffer
{
1013 * Create a new buffer writer.
1015 * @param \ion\Writer\Options|null $options Writer options.
1017 public function __construct(
1018 ?\ion\Writer\Options
$options = null,
1021 public function getBuffer() : string {}
1022 public function resetBuffer() : void
{}
1025 namespace ion\Writer\Stream
;
1028 * ION stream writer.
1030 class Writer
extends \ion\Writer\Writer
implements \ion\Writer\Stream
{
1032 * Create a new stream writer.
1034 * @param resource $stream The stream to write to.
1035 * @param \ion\Writer\Options|null $options Writer options.
1037 public function __construct(
1039 ?\ion\Writer\Options
$options = null,
1044 public function getStream() {}
1047 namespace ion\Serializer
;
1050 * Specialization of the serializer for PHP.
1052 class PHP
implements \ion\Serializer
{
1054 * Create a new PHP ION serializer.
1056 public function __construct(
1060 public readonly ?\ion\Writer\Options
$writerOptions = null,
1062 * Whether to write the top level array as multiple ION sequences.
1064 public readonly
bool $multiSequence = false,
1066 * Whether to call magic __serialize() methods on objects to serialize.
1068 public readonly
bool $callMagicSerialize = true,
1070 * Whether and which custom serialize method to call on objects to serialize.
1072 public readonly ?
string $callCustomSerialize = null,
1075 public function serialize(mixed $data) : string {}
1078 namespace ion\Unserializer
;
1081 * Specialization of the unserializer for PHP.
1083 class PHP
implements \ion\Unserializer
{
1085 * Create a new ION PHP unserializer.
1087 public function __construct(
1091 public readonly ?\ion\Reader\Options
$readerOptions = null,
1093 * Whether to continue reading multiple ION sequences after the first one.
1095 public readonly
bool $multiSequence = false,
1097 * Whether to call magic __unserialize() methods on objects to unserialize.
1099 public readonly
bool $callMagicUnserialize = true,
1101 * Whether and which custom unserialize method to call on objects to unserialize.
1103 public readonly ?
string $callCustomUnserialize = null,
1106 /** @param string|resource $data */
1107 public function unserialize($data) : mixed {}