Skip to content

Commit 717c399

Browse files
committed
remove Options classes
1 parent a34b502 commit 717c399

11 files changed

+457
-761
lines changed

ion.c

+148-195
Large diffs are not rendered by default.

ion.stub.php

+63-56
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ function unserialize($data, Unserializer|array|null $unserializer = null) : mixe
4848
* Serializer interface, used to customize ion\serialize()'s behavior.
4949
*/
5050
interface Serializer {
51-
public function serialize(mixed $data, \ion\Writer|\ion\Writer\Options|array|null $writer = null) : mixed;
51+
public function serialize(mixed $data, Writer|array|null $writer = null) : mixed;
5252
}
5353

5454
/**
5555
* Unserializer interface, used to customize ion\unserialize()'s behavior.
5656
*/
5757
interface Unserializer {
58-
/** @param \ion\Reader|string|resource $data */
58+
/** @param Reader|string|resource $data */
5959
public function unserialize($data) : mixed;
6060
}
6161

@@ -689,10 +689,14 @@ enum Format : string {
689689
namespace ion\Reader;
690690

691691
/**
692-
* Reader options.
692+
* Base implementation of ION readers.
693693
*/
694-
class Options {
694+
abstract class Reader implements \ion\Reader {
695+
/**
696+
* @param string|resource $data The string or resource to read from.
697+
*/
695698
public function __construct(
699+
$data,
696700
/**
697701
* ION catalog to use for symbol lookup.
698702
*/
@@ -730,16 +734,6 @@ public function __construct(
730734
*/
731735
public readonly bool $skipCharacterValidation = false,
732736
) {}
733-
}
734-
735-
/**
736-
* Base implementation of ION readers.
737-
*/
738-
abstract class Reader implements \ion\Reader {
739-
/**
740-
* Reader options.
741-
*/
742-
public readonly ?Options $options;
743737

744738
public function hasChildren() : bool {}
745739
public function getChildren() : \ion\Reader {}
@@ -794,7 +788,7 @@ public function getValueLength() : int {}
794788
*/
795789
interface Buffer extends \ion\Reader {
796790
/**
797-
* Get the buffer read from.
791+
* Get the buffer being read from.
798792
*
799793
* @return string The buffer read from.
800794
*/
@@ -806,7 +800,7 @@ public function getBuffer() : string;
806800
*/
807801
interface Stream extends \ion\Reader {
808802
/**
809-
* Get the stream read from.
803+
* Get the stream being read from.
810804
*
811805
* @return resource The stream read from.
812806
*/
@@ -834,16 +828,6 @@ public function resetStreamWithLength($stream, int $length) : void;
834828
* ION buffer reader.
835829
*/
836830
class Reader extends \ion\Reader\Reader implements \ion\Reader\Buffer {
837-
/**
838-
* Create a new string buffer reader.
839-
*
840-
* @param string $buffer The buffer to read from.
841-
* @param \ion\Reader\Options|array|null $options Reader options.
842-
*/
843-
public function __construct(
844-
string $buffer,
845-
\ion\Reader\Options|array|null $options = null,
846-
) {}
847831

848832
public function getBuffer() : string {}
849833
}
@@ -854,16 +838,6 @@ public function getBuffer() : string {}
854838
* ION stream reader.
855839
*/
856840
class Reader extends \ion\Reader\Reader implements \ion\Reader\Stream {
857-
/**
858-
* Create a new stream reader.
859-
*
860-
* @param resource $stream The stream to read from.
861-
* @param \ion\Reader\Options|array|null $options Reader options.
862-
*/
863-
public function __construct(
864-
$stream,
865-
\ion\Reader\Options|array|null $options = null,
866-
) {}
867841

868842
/**
869843
* Get the stream read from.
@@ -881,11 +855,11 @@ public function resetStreamWithLength($stream, int $length) : void {}
881855
namespace ion\Writer;
882856

883857
/**
884-
* ION writer options.
858+
* Base implementation of common functionality of ION writers.
885859
*/
886-
class Options {
860+
abstract class Writer implements \ion\Writer {
887861
/**
888-
* Create custom ION writer options.
862+
* Create custom ION writer.
889863
*/
890864
public function __construct(
891865
/**
@@ -937,12 +911,7 @@ public function __construct(
937911
*/
938912
public readonly int $tempBufferSize = 0x4000,
939913
) {}
940-
}
941914

942-
/**
943-
* Base implementation of common functionality of ION writers.
944-
*/
945-
abstract class Writer implements \ion\Writer {
946915
public function writeNull() : void {}
947916
public function writeTypedNull(\ion\Type $type) : void {}
948917
public function writeBool(bool $value) : void {}
@@ -1005,17 +974,9 @@ public function getStream();
1005974
namespace ion\Writer\Buffer;
1006975

1007976
/**
1008-
* IO buffer writer.
977+
* ION buffer writer.
1009978
*/
1010979
class Writer extends \ion\Writer\Writer implements \ion\Writer\Buffer {
1011-
/**
1012-
* Create a new buffer writer.
1013-
*
1014-
* @param \ion\Writer\Options|array|null $options Writer options.
1015-
*/
1016-
public function __construct(
1017-
\ion\Writer\Options|array|null $options = null,
1018-
) {}
1019980

1020981
public function getBuffer() : string {}
1021982
public function resetBuffer() : void {}
@@ -1031,11 +992,57 @@ class Writer extends \ion\Writer\Writer implements \ion\Writer\Stream {
1031992
* Create a new stream writer.
1032993
*
1033994
* @param resource $stream The stream to write to.
1034-
* @param \ion\Writer\Options|array|null $options Writer options.
1035995
*/
1036996
public function __construct(
1037997
$stream,
1038-
\ion\Writer\Options|array|null $options = null,
998+
/**
999+
* ION catalog to use for symbol lookup.
1000+
*/
1001+
public readonly ?\ion\Catalog $catalog = null,
1002+
/**
1003+
* Decimal context to use.
1004+
*/
1005+
public readonly ?\ion\Decimal\Context $decimalContext = null,
1006+
/**
1007+
* Whether to output binary ION.
1008+
*/
1009+
public readonly bool $outputBinary = false,
1010+
/**
1011+
* Whether to write doubles which fit in 32 bits as floats.
1012+
*/
1013+
public readonly bool $compactFloats = false,
1014+
/**
1015+
* Whether to slash-escape all non ASCII bytes.
1016+
*/
1017+
public readonly bool $escapeNonAscii = false,
1018+
/**
1019+
* Whether to produce pretty-printed output.
1020+
*/
1021+
public readonly bool $prettyPrint = false,
1022+
/**
1023+
* Whether to indent with tabs, when pretty-printing.
1024+
*/
1025+
public readonly bool $indentTabs = true,
1026+
/**
1027+
* The number of spaces to use for indentation instead of tabs, when pretty-printing.
1028+
*/
1029+
public readonly int $indentSize = 2,
1030+
/**
1031+
* Whether to immediately flush every value written.
1032+
*/
1033+
public readonly bool $flushEveryValue = false,
1034+
/**
1035+
* Maximum depth of nested containers.
1036+
*/
1037+
public readonly int $maxContainerDepth = 10,
1038+
/**
1039+
* The maximum number of annotations allowed on a single value.
1040+
*/
1041+
public readonly int $maxAnnotations = 10,
1042+
/**
1043+
* Temporary buffer size.
1044+
*/
1045+
public readonly int $tempBufferSize = 0x4000,
10391046
) {}
10401047
/**
10411048
* @return resource
@@ -1066,7 +1073,7 @@ public function __construct(
10661073
public readonly ?string $callCustomSerialize = null,
10671074
) {}
10681075

1069-
public function serialize(mixed $data, \ion\Writer|\ion\Writer\Options|array|null $writer = null) : mixed {}
1076+
public function serialize(mixed $data, \ion\Writer|array|null $writer = null) : mixed {}
10701077
}
10711078

10721079
namespace ion\Unserializer;

0 commit comments

Comments
 (0)