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.
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 sepc's timestamp definintion
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|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
$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
;
451 namespace ion\Symbol\Table
;
454 * Get the built-in PHP shared symbol table.
456 * @see \ion\Symbol\Table\PHP
457 * @return \ion\Symbol\Table The builtin PHP shared symbol table.
459 function PHP() : \ion\Symbol\Table
{}
462 * Get the built-in ION system shared symbol table.
464 * @see \ion\Symbol\Table\System
465 * @return \ion\Symbol\Table The builtin ION system shared symbol table.
467 function System() : \ion\Symbol\Table
{}
470 * The built-in ION system symbols.
472 enum System
: string implements \ion\Symbol\Enum
{
474 case Ivm_1_0
= '$ion_1_0';
475 case IonSymbolTable
= '$ion_symbol_table';
477 case Version
= 'version';
478 case Imports
= 'imports';
479 case Symbols
= 'symbols';
480 case MaxId
= 'max_id';
481 case SharedSymbolTable
= '$ion_shared_symbol_table';
483 /** @alias ion\Symbol\Enum::toSymbol */
484 public function toSymbol() : \ion\Symbol
{}
485 /** @alias ion\Symbol\Enum::toSID */
486 public function toSID() : int {}
487 /** @alias ion\Symbol\Enum::toString */
488 public function toString() : string {}
492 * The built-in PHP symbols.
494 enum PHP
: string implements \ion\Symbol\Enum
{
496 case Reference
= 'R';
500 case ClassObject
= 'c';
501 case MagicObject
= 'O';
502 case CustomObject
= 'C';
504 case Serializable
= 'S';
506 /** @alias ion\Symbol\Enum::toSymbol */
507 public function toSymbol() : \ion\Symbol
{}
508 /** @alias ion\Symbol\Enum::toSID */
509 public function toSID() : int {}
510 /** @alias ion\Symbol\Enum::toString */
511 public function toString() : string {}
515 * A local symbol table.
517 * @see https://amzn.github.io/ion-docs/guides/symbols-guide.html the ION spec's symbol guide
518 * @see https://amzn.github.io/ion-docs/guides/cookbook.html#using-a-local-symbol-table the ION doc's cookbook
520 class Local
implements \ion\Symbol\Table
{
521 /** Internal cache. */
522 private array $imports = [];
523 /** Internal cache. */
524 private array $symbols = [];
527 * Create a local symbol table.
529 public function __construct() {}
532 * Import a symbol table.
534 * @param \ion\Symbol\Table $table The symbol table to import.
537 public function import(\ion\Symbol\Table
$table) : void
{}
539 /** @alias ion\Symbol\Table::getMaxId */
540 public function getMaxId() : int {}
542 /** @alias ion\Symbol\Table::add */
543 public function add(\ion\Symbol|
string $symbol) : int {}
544 /** @alias ion\Symbol\Table::find */
545 public function find(string|
int $id) : ?\ion\Symbol
{}
546 /** @alias ion\Symbol\Table::findLocal */
547 public function findLocal(string|
int $id) : ?\ion\Symbol
{}
551 * A shared symbol table.
553 * @see https://amzn.github.io/ion-docs/guides/symbols-guide.html the ION spec's symbol guide
554 * @see https://amzn.github.io/ion-docs/guides/cookbook.html#using-a-shared-symbol-table the ION doc's cookbook
556 class Shared
implements \ion\Symbol\Table
{
558 * Create a shared symbol table.
560 public function __construct(
562 * The name of the shared symbol table.
564 public readonly
string $name,
566 * The version of the shared symbol table.
568 public readonly
int $version = 1,
570 * Predefined list of symbols as array of strings.
572 ?
array $symbols = null,
575 /** Internal cache. */
576 private array $symbols = [];
578 /** @alias ion\Symbol\Table::getMaxId */
579 public function getMaxId() : int {}
581 /** @alias ion\Symbol\Table::add */
582 public function add(\ion\Symbol|
string $symbol) : int {}
583 /** @alias ion\Symbol\Table::find */
584 public function find(string|
int $id) : ?\ion\Symbol
{}
585 /** @alias ion\Symbol\Table::findLocal */
586 public function findLocal(string|
int $id) : ?\ion\Symbol
{}
589 namespace ion\Decimal
;
592 * An ion\Decimal's context.
596 * Create a new decimal context.
598 public function __construct(
602 public readonly
int $digits,
606 public readonly
int $eMax,
610 public readonly
int $eMin,
614 public readonly Context\Rounding|
int $round,
618 public readonly
bool $clamp,
622 * Create a context suitable for 32bit decimals.
624 public static function Dec32() : Context
{}
627 * Create a context suitable for 64bit decimals.
629 public static function Dec64() : Context
{}
632 * Create a context suitable for 128bit decimals.
634 public static function Dec128() : Context
{}
637 * Create a context with maximum settings.
638 * @param Context\Rounding|int $round Rounding mode.
640 public static function DecMax(Context\Rounding|
int $round = Context\Rounding
::HalfEven
) : Context
{}
643 namespace ion\Decimal\Context
;
648 enum Rounding
: int {
659 namespace ion\Timestamp
;
662 * Timestamp precision.
664 enum Precision
: int {
666 case Month
= 0x1|
0x2;
667 case Day
= 0x1|
0x2|
0x4;
668 case Min
= 0x1|
0x2|
0x4|
0x10;
669 case Sec
= 0x1|
0x2|
0x4|
0x10|
0x20;
670 case Frac
= 0x1|
0x2|
0x4|
0x10|
0x20|
0x40;
671 case MinTZ
= 0x1|
0x2|
0x4|
0x10|
0x80;
672 case SecTZ
= 0x1|
0x2|
0x4|
0x10|
0x20|
0x80;
673 case FracTZ
= 0x1|
0x2|
0x4|
0x10|
0x20|
0x40|
0x80;
679 enum Format
: string {
681 case Month
= "Y-m\T";
682 case Day
= "Y-m-d\T";
683 case Min
= "Y-m-d\TH:i";
684 case Sec
= "Y-m-d\TH:i:s";
685 case Frac
= "Y-m-d\TH:i:s.v";
686 case MinTZ
= "Y-m-d\TH:iP";
687 case SecTZ
= "Y-m-d\TH:i:sP";
688 case FracTZ
= "Y-m-d\TH:i:s.vP";
691 namespace ion\Reader
;
697 public function __construct(
699 * ION catalog to use for symbol lookup.
701 public readonly ?\ion\Catalog
$catalog = null,
703 * Decimal context to use.
705 public readonly ?\ion\Decimal\Context
$decimalContext = null,
707 * Callback as function(\ion\Reader):void called upon local symbol table context change.
709 public readonly ?\Closure
$onContextChange = null,
711 * Whether to return otherwise hidden system values.
713 public readonly
bool $returnSystemValues = false,
715 * The maximum depth of nested containers.
717 public readonly
int $maxContainerDepth = 10,
719 * The maximum number of annotations allowed on a single value.
721 public readonly
int $maxAnnotations = 10,
723 * The maximum number of bytes of all annotations on a single value.
725 public readonly
int $annotationBufferSize = 0x4000,
727 * The maximum number of bytes of a symbol/value/chunk.
729 public readonly
int $tempBufferSize = 0x4000,
731 * Whether to skip UTF-8 validation.
733 public readonly
bool $skipCharacterValidation = false,
738 * Base implementation of ION readers.
740 abstract class Reader
implements \ion\Reader
{
744 public readonly ?Options
$options;
746 public function hasChildren() : bool {}
747 public function getChildren() : \ion\Reader
{}
749 public function rewind() : void
{}
750 public function next() : void
{}
751 public function valid() : bool {}
752 public function key() : mixed {}
753 public function current() : mixed {}
755 public function getType() : \ion\Type
{}
756 public function hasAnnotations() : bool {}
757 public function hasAnnotation(string $annotation) : bool {}
758 public function isNull() : bool {}
759 public function isInStruct() : bool {}
760 public function getFieldName() : string {}
761 public function getFieldNameSymbol() : \ion\Symbol
{}
762 public function getAnnotations() : array {}
763 public function getAnnotationSymbols() : array {}
764 public function countAnnotations() : int {}
765 public function getAnnotation(int $index) : string {}
766 public function getAnnotationSymbol(int $index) : \ion\Symbol
{}
768 public function readNull() : \ion\Type
{}
769 public function readBool() : bool {}
770 public function readInt() : int|
string {}
771 public function readFloat() : float {}
772 public function readDecimal() : \ion\Decimal
{}
773 public function readTimestamp() : \ion\Timestamp
{}
774 public function readSymbol() : \ion\Symbol
{}
775 public function readString() : string {}
776 /** @param ref $string */
777 public function readStringPart(&$string, int $length = 0x1000) : bool {}
778 public function readLob() : string {}
779 /** @param ref $string */
780 public function readLobPart(&$string, int $length = 0x1000) : bool {}
782 public function getPosition() : int {}
783 public function getDepth() : int{}
785 public function seek(int $offset, int $length = -1) : void
{}
787 public function getSymbolTable() : SymbolTable {}
788 public function setSymbolTable(SymbolTable $table) : void {}
790 public function getValueOffset() : int {}
791 public function getValueLength() : int {}
795 * ION string buffer reader API.
797 interface Buffer
extends \ion\Reader
{
799 * Get the buffer read from.
801 * @return string The buffer read from.
803 public function getBuffer() : string;
807 * ION stream reader API.
809 interface Stream
extends \ion\Reader
{
811 * Get the stream read from.
813 * @return resource The stream read from.
815 public function getStream();
818 * Reset the stream read from.
820 * @param resource $stream The new stream to from.
822 public function resetStream($stream) : void
;
825 * Reset the stream read from, limiting length to read.
827 * @param resource $stream The stream to read from.
828 * @param int $length The maximum length to read from $stream.
830 public function resetStreamWithLength($stream, int $length) : void
;
833 namespace ion\Reader\Buffer
;
836 * ION string buffer reader.
838 class Reader
extends \ion\Reader\Reader
implements \ion\Reader\Buffer
{
840 * Create a new string buffer reader.
842 * @param string $buffer The buffer to read from.
843 * @param \ion\Reader\Options|null $options Reader options.
845 public function __construct(
847 ?\ion\Reader\Options
$options = null,
850 public function getBuffer() : string {}
853 namespace ion\Reader\Stream
;
858 class Reader
extends \ion\Reader\Reader
implements \ion\Reader\Stream
{
860 * Create a new stream reader.
862 * @param resource $stream The stream to read from.
863 * @param \ion\Reader\Options|null $options Reader options.
865 public function __construct(
867 ?\ion\Reader\Options
$options = null,
871 * Get the stream read from.
873 * @return resource The stream read from.
875 public function getStream() {}
877 /** @param resource $stream */
878 public function resetStream($stream) : void
{}
879 /** @param resource $stream */
880 public function resetStreamWithLength($stream, int $length) : void
{}
883 namespace ion\Writer
;
886 * ION writer options.
890 * Create custom ION writer options.
892 public function __construct(
894 * ION catalog to use for symbol lookup.
896 public readonly ?\ion\Catalog
$catalog = null,
898 * Decimal context to use.
900 public readonly ?\ion\Decimal\Context
$decimalContext = null,
902 * Whether to output binary ION.
904 public readonly
bool $outputBinary = false,
906 * Whether to write doubles which fit in 32 bits as floats.
908 public readonly
bool $compactFloats = false,
910 * Whether to slash-escape all non ASCII bytes.
912 public readonly
bool $escapeNonAscii = false,
914 * Whether to produce pretty-printed output.
916 public readonly
bool $prettyPrint = false,
918 * Whether to indent with tabs, when pretty-printing.
920 public readonly
bool $indentTabs = true,
922 * The number of spaces to use for indentation instead of tabs, when pretty-printing.
924 public readonly
int $indentSize = 2,
926 * Whether to immediately flush every value written.
928 public readonly
bool $flushEveryValue = false,
930 * Maximum depth of nested containers.
932 public readonly
int $maxContainerDepth = 10,
934 * The maximum number of annotations allowed on a single value.
936 public readonly
int $maxAnnotations = 10,
938 * Temporary buffer size.
940 public readonly
int $tempBufferSize = 0x4000,
945 * Base implementation of common functionality of ION writers.
947 abstract class Writer
implements \ion\Writer
{
948 public function writeNull() : void
{}
949 public function writeTypedNull(\ion\Type
$type) : void
{}
950 public function writeBool(bool $value) : void
{}
951 public function writeInt(int|
string $value) : void
{}
952 public function writeFloat(float $value) : void
{}
953 public function writeDecimal(\ion\Decimal|
string $value) : void
{}
954 public function writeTimestamp(\ion\Timestamp|
string $value) : void
{}
955 public function writeSymbol(\ion\Symbol|
string $value) : void
{}
956 public function writeString(string $value) : void
{}
957 public function writeCLob(string $value) : void
{}
958 public function writeBLob(string $value) : void
{}
960 public function startLob(\ion\Type
$type) : void
{}
961 public function appendLob(string $data) : void
{}
962 public function finishLob() : void
{}
964 public function startContainer(\ion\Type
$type) : void
{}
965 public function finishContainer() : void
{}
967 public function writeFieldName(string $name) : void
{}
969 public function writeAnnotation(\ion\Symbol|
string ...$annotation) : void
{}
971 public function getDepth() : int {}
972 public function flush() : int {}
973 public function finish() : int {}
975 // public function writeOne(\ion\Reader $reader) : void {}
976 // public function writeAll(\ion\Reader $reader) : void {}
980 * ION buffer writer API.
982 interface Buffer
extends \ion\Writer
{
984 * Get the buffer written to.
986 * @reeturn string The buffer written so far.
988 public function getBuffer() : string;
991 * Reset the buffer written to.
993 public function resetBuffer() : void
;
997 * ION stream writer API.
999 interface Stream
extends \ion\Writer
{
1001 * Get the stream being written to.
1004 public function getStream();
1007 namespace ion\Writer\Buffer
;
1012 class Writer
extends \ion\Writer\Writer
implements \ion\Writer\Buffer
{
1014 * Create a new buffer writer.
1016 * @param \ion\Writer\Options|null $options Writer options.
1018 public function __construct(
1019 ?\ion\Writer\Options
$options = null,
1022 public function getBuffer() : string {}
1023 public function resetBuffer() : void
{}
1026 namespace ion\Writer\Stream
;
1029 * ION stream writer.
1031 class Writer
extends \ion\Writer\Writer
implements \ion\Writer\Stream
{
1033 * Create a new stream writer.
1035 * @param resource $stream The stream to write to.
1036 * @param \ion\Writer\Options|null $options Writer options.
1038 public function __construct(
1040 ?\ion\Writer\Options
$options = null,
1045 public function getStream() {}
1048 namespace ion\Serializer
;
1051 * Specialization of the serializer for PHP.
1053 class PHP
implements \ion\Serializer
{
1055 * Create a new PHP ION serializer.
1057 public function __construct(
1061 public readonly ?\ion\Writer\Options
$writerOptions = null,
1063 * Whether to write the top level array as multiple ION sequences.
1065 public readonly
bool $multiSequence = false,
1067 * Whether to call magic __serialize() methods on objects to serialize.
1069 public readonly
bool $callMagicSerialize = true,
1071 * Whether and which custom serialize method to call on objects to serialize.
1073 public readonly ?
string $callCustomSerialize = null,
1076 public function serialize(mixed $data) : string {}
1079 namespace ion\Unserializer
;
1082 * Specialization of the unserializer for PHP.
1084 class PHP
implements \ion\Unserializer
{
1086 * Create a new ION PHP unserializer.
1088 public function __construct(
1092 public readonly ?\ion\Reader\Options
$readerOptions = null,
1094 * Whether to continue reading multiple ION sequences after the first one.
1096 public readonly
bool $multiSequence = false,
1098 * Whether to call magic __unserialize() methods on objects to unserialize.
1100 public readonly
bool $callMagicUnserialize = true,
1102 * Whether and which custom unserialize method to call on objects to unserialize.
1104 public readonly ?
string $callCustomUnserialize = null,
1107 /** @param string|resource $data */
1108 public function unserialize($data) : mixed {}