fix userland string serialization
[awesomized/ext-ion] / ion.stub.php
index 5e389b41586229b306a69e28e8a5d05db3a3a896..ac7dda8093392a4c3ee5b70cab208017da90b689 100644 (file)
@@ -23,38 +23,39 @@ namespace ion;
  *  * int
  *  * float
  *  * string
- *  * references
- *  * arrays
- *  * objects (incl. \Serializable, and classes implementing magic and custom __serialize)
+ *  * reference
+ *  * array
+ *  * object (incl. \Serializable, and classes implementing magic and custom __serialize)
  *
  * @param mixed $data PHP value(s).
- * @param Serializer|null $serializer Custom serializer.
+ * @param Serializer|array|null $serializer Custom Serializer (options).
  * @return string serialized ION data
- * @throws ion\Exception
+ * @throws \ion\Exception
  */
-function serialize(mixed $data, ?Serializer $serializer = null) : string {}
+function serialize(mixed $data, Serializer|array|null $serializer = null) : string {}
 
 /**
  * Unserialize ION data (stream) as PHP value(s).
  *
- * @param string|resource $data Serialized ION data, either as string buffer or stream,.
+ * @param string|resource $data Serialized ION data, either as string buffer or stream.
+ * @param Unserializer|array|null $unserializer Custom Unserializer (options).
  * @return mixed unserialized PHP values
- * @throws ion\Exception
+ * @throws \ion\Exception
  */
-function unserialize($data, ?Unserializer $unserializer = null) : mixed {}
+function unserialize($data, Unserializer|array|null $unserializer = null) : mixed {}
 
 /**
  * Serializer interface, used to customize ion\serialize()'s behavior.
  */
 interface Serializer {
-    public function serialize(mixed $data) : string;
+    public function serialize(mixed $data, \ion\Writer|\ion\Writer\Options|array|null $writer = null) : mixed;
 }
 
 /**
  * Unserializer interface, used to customize ion\unserialize()'s behavior.
  */
 interface Unserializer {
-    /** @param string|resource $data */
+    /** @param \ion\Reader|string|resource $data */
     public function unserialize($data) : mixed;
 }
 
@@ -256,7 +257,7 @@ class Decimal {
 
 /**
  * An ION Timestamp.
- * @see https://amzn.github.io/ion-docs/docs/spec.html#timestamp the ION sepc's timestamp definintion
+ * @see https://amzn.github.io/ion-docs/docs/spec.html#timestamp the ION spec's timestamp definition
  * @see https://php.net/date PHP's date documentation
  */
 class Timestamp extends \DateTime {
@@ -275,13 +276,13 @@ class Timestamp extends \DateTime {
      * @param Timestamp\Precision|int $precision The timestamp's precision.
      * @param Timestamp\Format|string|null $format The timestamp's format.
      * @param string|null $datetime The timestamp's value.
-     * @param \DateTimeZone|null $timezone The timestamp's timezone.
+     * @param \DateTimeZone|string|null $timezone The timestamp's timezone.
      */
     public function __construct(
         Timestamp\Precision|int $precision,
         Timestamp\Format|string|null $format = null,
         ?string $datetime = null,
-        ?\DateTimeZone $timezone = null,
+        \DateTimeZone|string|null $timezone = null,
     ) {}
 
     public function __toString() : string {}
@@ -374,7 +375,7 @@ interface Writer {
 namespace ion\Symbol;
 
 /**
- * The import location (referring to a shared table= of a symbol.
+ * The import location (referring to a shared table) of a symbol.
  */
 class ImportLocation {
     /**
@@ -830,18 +831,18 @@ interface Stream extends \ion\Reader {
 namespace ion\Reader\Buffer;
 
 /**
- * ION string buffer reader.
+ * ION buffer reader.
  */
 class Reader extends \ion\Reader\Reader implements \ion\Reader\Buffer {
     /**
      * Create a new string buffer reader.
      *
      * @param string $buffer The buffer to read from.
-     * @param \ion\Reader\Options|null $options Reader options.
+     * @param \ion\Reader\Options|array|null $options Reader options.
      */
     public function __construct(
         string $buffer,
-        ?\ion\Reader\Options $options = null,
+        \ion\Reader\Options|array|null $options = null,
     ) {}
 
     public function getBuffer() : string {}
@@ -857,11 +858,11 @@ class Reader extends \ion\Reader\Reader implements \ion\Reader\Stream {
      * Create a new stream reader.
      *
      * @param resource $stream The stream to read from.
-     * @param \ion\Reader\Options|null $options Reader options.
+     * @param \ion\Reader\Options|array|null $options Reader options.
      */
     public function __construct(
         $stream,
-        ?\ion\Reader\Options $options = null,
+        \ion\Reader\Options|array|null $options = null,
     ) {}
 
     /**
@@ -1010,10 +1011,10 @@ class Writer extends \ion\Writer\Writer implements \ion\Writer\Buffer {
     /**
      * Create a new buffer writer.
      *
-     * @param \ion\Writer\Options|null $options Writer options.
+     * @param \ion\Writer\Options|array|null $options Writer options.
      */
     public function __construct(
-        ?\ion\Writer\Options $options = null,
+        \ion\Writer\Options|array|null $options = null,
     ) {}
 
     public function getBuffer() : string {}
@@ -1030,11 +1031,11 @@ class Writer extends \ion\Writer\Writer implements \ion\Writer\Stream {
      * Create a new stream writer.
      *
      * @param resource $stream The stream to write to.
-     * @param \ion\Writer\Options|null $options Writer options.
+     * @param \ion\Writer\Options|array|null $options Writer options.
      */
     public function __construct(
         $stream,
-        ?\ion\Writer\Options $options = null,
+        \ion\Writer\Options|array|null $options = null,
     ) {}
     /**
      * @return resource
@@ -1043,19 +1044,14 @@ class Writer extends \ion\Writer\Writer implements \ion\Writer\Stream {
 }
 
 namespace ion\Serializer;
-
 /**
- * Specialization of the serializer for PHP.
+ * Serializer implementation
  */
-class PHP implements \ion\Serializer {
+class Serializer implements \ion\Serializer {
     /**
-     * Create a new PHP ION serializer.
+     * Create a new ION serializer.
      */
     public function __construct(
-        /**
-         * Writer options.
-         */
-        public readonly ?\ion\Writer\Options $writerOptions = null,
         /**
          * Whether to write the top level array as multiple ION sequences.
          */
@@ -1070,23 +1066,19 @@ class PHP implements \ion\Serializer {
         public readonly ?string $callCustomSerialize = null,
     ) {}
 
-    public function serialize(mixed $data) : string {}
+    public function serialize(mixed $data, \ion\Writer|\ion\Writer\Options|array|null $writer = null) : mixed {}
 }
 
 namespace ion\Unserializer;
 
 /**
- * Specialization of the unserializer for PHP.
+ * Unserializer implementation
  */
-class PHP implements \ion\Unserializer {
+class Unserializer implements \ion\Unserializer {
     /**
-     * Create a new ION PHP unserializer.
+     * Create a new ION unserializer.
      */
     public function __construct(
-        /**
-         * Reader options.
-         */
-        public readonly ?\ion\Reader\Options $readerOptions = null,
         /**
          * Whether to continue reading multiple ION sequences after the first one.
          */
@@ -1101,6 +1093,6 @@ class PHP implements \ion\Unserializer {
         public readonly ?string $callCustomUnserialize = null,
     ){}
 
-    /** @param string|resource $data */
+    /** @param \ion\Reader|string|resource $data */
     public function unserialize($data) : mixed {}
 }