@@ -106,11 +106,13 @@ var_dump($res) //int(5)
106106
107107``` php
108108<?php
109+
109110/**
110111 * Similar to json_decode()
111112 *
112113 * @return array|stdClass|string|float|int|bool|null
113- * @throws RuntimeException for invalid JSON (or document over 4GB, or out of range integer/float)
114+ * @throws SimdJsonException for invalid JSON
115+ * (or document over 4GB, or out of range integer/float)
114116 */
115117function simdjson_decode(string $json, bool $assoc = false, int $depth = 512) {}
116118
@@ -125,23 +127,39 @@ function simdjson_is_valid(string $json, int $depth = 512) : ?bool {}
125127 * Parses $json and returns the number of keys in $json matching the JSON pointer $key
126128 *
127129 * @return ?int (null if depth is invalid)
130+ * @throws SimdJsonException for invalid JSON
131+ * (or document over 4GB, or out of range integer/float)
128132 */
129133function simdjson_key_count(string $json, string $key, int $depth = 512) : ?int {}
130134
131135/**
132136 * Returns true if the JSON pointer $key could be found.
133137 *
134138 * @return ?bool (null if depth is invalid, false if json is invalid or key is not found)
139+ * @throws SimdJsonException for invalid JSON
140+ * (or document over 4GB, or out of range integer/float)
135141 */
136142function simdjson_key_exists(string $json, string $key, int $depth = 512) : ?bool {}
137143
138144/**
139145 * Returns the value at $key
140146 *
141147 * @return array|stdClass|string|float|int|bool|null the value at $key
142- * @throws RuntimeException for invalid JSON (or document over 4GB, or out of range integer/float)
148+ * @throws SimdJsonException for invalid JSON
149+ * (or document over 4GB, or out of range integer/float)
143150 */
144151function simdjson_key_value(string $json, string $key, bool $assoc = unknown, int $depth = unknown) {}
152+
153+ /**
154+ * An error thrown by simdjson when processing json.
155+ *
156+ * The error code is available as $e->getCode().
157+ * This can be compared against the `SIMDJSON_ERR_*` constants.
158+ *
159+ * Before simdjson 2.1.0, a regular RuntimeException with an error code of 0 was thrown.
160+ */
161+ class SimdJsonException extends RuntimeException {
162+ }
145163```
146164
147165## Edge cases
0 commit comments