accept arrays as named parameters for {Uns,S}erializer and
[awesomized/ext-ion] / ion.stub.php
index 15b60d306cb820dafa3119412dfc421245e3376a..9431b17265fcb9cd44b15e833038353034e592c5 100644 (file)
@@ -23,25 +23,25 @@ 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.
  * @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.
  * @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.
@@ -256,7 +256,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 +275,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 +374,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 {
     /**
@@ -447,24 +447,6 @@ interface Table {
     public function findLocal(string|int $id) : ?\ion\Symbol;
 }
 
-namespace ion\Symbol\Table;
-
-/**
- * Get the built-in PHP shared symbol table.
- *
- * @see \ion\Symbol\Table\PHP
- * @return \ion\Symbol\Table The builtin PHP shared symbol table.
- */
-function PHP() : \ion\Symbol\Table {}
-
-/**
- * Get the built-in ION system shared symbol table.
- *
- * @see \ion\Symbol\Table\System
- * @return \ion\Symbol\Table The builtin ION system shared symbol table.
- */
-function System() : \ion\Symbol\Table {}
-
 /**
  * The built-in ION system symbols.
  */
@@ -485,6 +467,13 @@ enum System : string implements \ion\Symbol\Enum {
     public function toSID() : int {}
     /** @alias ion\Symbol\Enum::toString */
     public function toString() : string {}
+
+    /**
+     * Get the built-in ION system shared symbol table.
+     *
+     * @return Table\Shared The system symbol table.
+     */
+    public static function asTable() : Table\Shared {}
 }
 
 /**
@@ -508,8 +497,17 @@ enum PHP : string implements \ion\Symbol\Enum {
     public function toSID() : int {}
     /** @alias ion\Symbol\Enum::toString */
     public function toString() : string {}
+
+    /**
+     * Get the built-in PHP shared symbol table.
+     *
+     * @return Table\Shared The builtin PHP shared symbol table.
+     */
+    public static function asTable() : Table\Shared {}
 }
 
+namespace ion\Symbol\Table;
+
 /**
  * A local symbol table.
  *
@@ -832,7 +830,7 @@ 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 {
     /**
@@ -1057,7 +1055,7 @@ class PHP implements \ion\Serializer {
         /**
          * Writer options.
          */
-        public readonly ?\ion\Writer\Options $writerOptions = null,
+        public readonly \ion\Writer\Options|array|null $writerOptions = null,
         /**
          * Whether to write the top level array as multiple ION sequences.
          */
@@ -1088,7 +1086,7 @@ class PHP implements \ion\Unserializer {
         /**
          * Reader options.
          */
-        public readonly ?\ion\Reader\Options $readerOptions = null,
+        public readonly \ion\Reader\Options|array|null $readerOptions = null,
         /**
          * Whether to continue reading multiple ION sequences after the first one.
          */