Skip to content

Commit 3d0dbf0

Browse files
committed
stub: Proper annotations
1 parent 6ae2039 commit 3d0dbf0

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

simdjson.stub.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ function simdjson_is_valid(string $json, int $depth = 512): bool {}
244244
* When false, JSON objects will be returned as objects.
245245
* @param int $depth the maximum nesting depth of the structure being decoded.
246246
* @return array|stdClass|string|float|int|bool|null
247-
* @throws SimdJsonException for invalid JSON
247+
* @throws SimdJsonDecoderException for invalid JSON
248248
* (or $json over 4GB long, or out of range integer/float)
249249
* @throws ValueError for invalid $depth
250250
*/
@@ -259,7 +259,7 @@ function simdjson_decode(string $json, bool $associative = false, int $depth = 5
259259
* When false, JSON objects will be returned as objects.
260260
* @param int $depth the maximum nesting depth of the structure being decoded.
261261
* @return array|stdClass|string|float|int|bool|null
262-
* @throws SimdJsonException for invalid JSON
262+
* @throws SimdJsonDecoderException for invalid JSON
263263
* (or $json over 4GB long, or out of range integer/float)
264264
* @throws ValueError for invalid $depth
265265
*/
@@ -274,7 +274,7 @@ function simdjson_decode_from_stream($res, bool $associative = false, int $depth
274274
* @param bool $associative When true, JSON objects will be returned as associative arrays.
275275
* When false, JSON objects will be returned as objects.
276276
* @return array|stdClass|string|float|int|bool|null the value at $key
277-
* @throws SimdJsonException for invalid JSON or invalid JSON pointer
277+
* @throws SimdJsonDecoderException for invalid JSON or invalid JSON pointer
278278
* (or document over 4GB, or out of range integer/float)
279279
* @throws ValueError for invalid $depth
280280
* @see https://www.rfc-editor.org/rfc/rfc6901.html
@@ -291,7 +291,7 @@ function simdjson_key_value(string $json, string $key, bool $associative = false
291291
* returning 0 for JSON pointers
292292
* to values that are neither objects nor arrays.
293293
* @return int
294-
* @throws SimdJsonException for invalid JSON or invalid JSON pointer
294+
* @throws SimdJsonDecoderException for invalid JSON or invalid JSON pointer
295295
* (or document over 4GB, or out of range integer/float)
296296
* @throws ValueError for invalid $depth
297297
* @see https://www.rfc-editor.org/rfc/rfc6901.html
@@ -305,7 +305,7 @@ function simdjson_key_count(string $json, string $key, int $depth = 512, bool $t
305305
* @param string $key The JSON pointer being requested
306306
* @param int $depth the maximum nesting depth of the structure being decoded.
307307
* @return bool (false if key is not found)
308-
* @throws SimdJsonException for invalid JSON or invalid JSON pointer
308+
* @throws SimdJsonDecoderException for invalid JSON or invalid JSON pointer
309309
* (or document over 4GB, or out of range integer/float)
310310
* @throws ValueError for invalid $depth
311311
* @see https://www.rfc-editor.org/rfc/rfc6901.html
@@ -332,21 +332,25 @@ function simdjson_is_valid_utf8(string $string): bool {}
332332
* @param int $flags Bitmask consisting of SIMDJSON_PRETTY_PRINT or SIMDJSON_APPEND_NEWLINE.
333333
* @param int $depth Set the maximum depth. Must be greater than zero.
334334
* @return string
335+
* @throws SimdJsonEncoderException
336+
* @throws ValueError for invalid $depth
335337
*/
336338
function simdjson_encode(mixed $value, int $flags = 0, int $depth = 512): string {}
337339

338340
/**
339341
* Writes the JSON representation of a value to given stream
340342
*
341-
* @param mixed $value The value being encoded. Can be any type except a resource.
342-
* @param resource $res A file system pointer resource that is typically created using fopen().
343-
* @param int $flags Bitmask consisting of SIMDJSON_PRETTY_PRINT, SIMDJSON_APPEND_NEWLINE or SIMDJSON_INVALID_UTF8_SUBSTITUTE.
344-
* @param int $depth Set the maximum depth. Must be greater than zero.
345-
* @return bool
343+
* @param mixed $value The value being encoded. Can be any type except a resource.
344+
* @param resource $res A file system pointer resource that is typically created using fopen().
345+
* @param int $flags Bitmask consisting of SIMDJSON_PRETTY_PRINT, SIMDJSON_APPEND_NEWLINE or SIMDJSON_INVALID_UTF8_SUBSTITUTE.
346+
* @param int $depth Set the maximum depth. Must be greater than zero.
347+
* @return bool
348+
* @throws SimdJsonEncoderException
349+
* @throws ValueError for invalid $depth
346350
*/
347351
function simdjson_encode_to_stream(mixed $value, $res, int $flags = 0, int $depth = 512) : true {}
348352

349-
class SimdJsonException extends RuntimeException {}
353+
abstract class SimdJsonException extends RuntimeException {}
350354

351355
class SimdJsonDecoderException extends SimdJsonException {}
352356

simdjson_arginfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: ebea873e016b9c136bfbd095a585a05c7e66738e */
2+
* Stub hash: 5b2147fe5e6865e7ab51e22a21cb235aeba0a12e */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_simdjson_validate, 0, 1, _IS_BOOL, 0)
55
ZEND_ARG_TYPE_INFO(0, json, IS_STRING, 0)
@@ -176,6 +176,7 @@ static zend_class_entry *register_class_SimdJsonException(zend_class_entry *clas
176176

177177
INIT_CLASS_ENTRY(ce, "SimdJsonException", class_SimdJsonException_methods);
178178
class_entry = zend_register_internal_class_ex(&ce, class_entry_RuntimeException);
179+
class_entry->ce_flags |= ZEND_ACC_ABSTRACT;
179180

180181
return class_entry;
181182
}

0 commit comments

Comments
 (0)