Skip to content

Commit 14ef530

Browse files
committed
2.1.0-dev: Add SimdJsonException, update C simdjson
This uses the `simdjson_php` branch of https://github.com/TysonAndre/simdjson - This makes the result of numeric edge cases match phps for values that would overflow to infinity (with the simdjson dom parser) (e.g. 1e999) discovered in the compatibility tests - Merges in bug fixes from simdjson 3.0.0 e.g. for https://en.wikipedia.org/wiki/Signed_zero Import various tests from php-src ext/json to test compatibility Mark other dependencies on json to run tests Mark a test as php 7.1+ only Add more tests of parsing large floating point numbers Switch from RuntimeException to SimdJsonException 1. Change to SimdJsonException extends RuntimeException. The name was chosen to be similar to https://www.php.net/jsonexception JsonException. 2. Set the value of $e->getCode() 3. Add global constants `SIMDJSON_ERR_*` 4. Throw SimdJsonException instead for invalid properties Disable development checks in debug builds and disable exception support to force manual error handling of all possible error conditions (this library is called from php, which is written in C) Fix Windows build error, make bindings consistently ZEND_API
1 parent c0034f2 commit 14ef530

40 files changed

Lines changed: 4234 additions & 216 deletions

.github/workflows/integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ jobs:
104104
- "7.3"
105105
- "7.4"
106106
- "8.0"
107+
- "8.1"
107108
os: [ubuntu-latest]
108109
experimental: [false]
109110
runs-on: ${{ matrix.os }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ modules/
3232
*.dep
3333
php_test_results_*.txt
3434
tests/*
35-
!tests/*.phpt
35+
!tests/**/*.phpt
3636
!tests/_files/
3737
*~
3838
configure.ac

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,36 +109,36 @@ var_dump($res) //int(5)
109109
/**
110110
* Similar to json_decode()
111111
*
112-
* @returns array|stdClass|string|float|int|bool|null
112+
* @return array|stdClass|string|float|int|bool|null
113113
* @throws RuntimeException for invalid JSON (or document over 4GB, or out of range integer/float)
114114
*/
115115
function simdjson_decode(string $json, bool $assoc = false, int $depth = 512) {}
116116

117117
/**
118118
* Returns true if json is valid.
119119
*
120-
* @returns ?bool (null if depth is invalid)
120+
* @return ?bool (null if depth is invalid)
121121
*/
122122
function simdjson_is_valid(string $json, int $depth = 512) : ?bool {}
123123

124124
/**
125125
* Parses $json and returns the number of keys in $json matching the JSON pointer $key
126126
*
127-
* @returns ?bool (null if depth is invalid)
127+
* @return ?int (null if depth is invalid)
128128
*/
129129
function simdjson_key_count(string $json, string $key, int $depth = 512) : ?int {}
130130

131131
/**
132132
* Returns true if the JSON pointer $key could be found.
133133
*
134-
* @returns ?bool (null if depth is invalid, false if json is invalid or key is not found)
134+
* @return ?bool (null if depth is invalid, false if json is invalid or key is not found)
135135
*/
136136
function simdjson_key_exists(string $json, string $key, int $depth = 512) : ?bool {}
137137

138138
/**
139139
* Returns the value at $key
140140
*
141-
* @returns array|stdClass|string|float|int|bool|null the value at $key
141+
* @return array|stdClass|string|float|int|bool|null the value at $key
142142
* @throws RuntimeException for invalid JSON (or document over 4GB, or out of range integer/float)
143143
*/
144144
function simdjson_key_value(string $json, string $key, bool $assoc = unknown, int $depth = unknown) {}
@@ -148,7 +148,7 @@ function simdjson_key_value(string $json, string $key, bool $assoc = unknown, in
148148

149149
There are some differences from `json_decode()` due to the implementation of the underlying simdjson library. This will throw a RuntimeException if simdjson rejects the JSON.
150150

151-
1) `simdjson_decode()` how out of range 64-bit integers and floats are handled.
151+
1) **Until simdjson 2.1.0,** `simdjson_decode()` differed in how out of range 64-bit integers and floats are handled.
152152

153153
See https://github.com/simdjson/simdjson/blob/master/doc/basics.md#standard-compliance
154154

config.m4

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ if test "$PHP_SIMDJSON" != "no"; then
2929
[CXXFLAGS="$CXXFLAGS -fvisibility=hidden"])
3030

3131
AC_DEFINE(HAVE_SIMDJSON, 1, [whether simdjson is enabled])
32+
dnl Disable exceptions because PHP is written in C and loads this C++ module, handle errors manually.
33+
dnl Disable development checks of C simdjson library in php debug builds (can manually override)
3234
PHP_NEW_EXTENSION(simdjson, [
3335
php_simdjson.cpp \
3436
src/bindings.cpp \
3537
src/simdjson.cpp],
36-
$ext_shared,, "-std=c++17 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1", cxx)
38+
$ext_shared,, "-std=c++17 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DSIMDJSON_EXCEPTIONS=0 -DSIMDJSON_DEVELOPMENT_CHECKS=0", cxx)
3739

38-
PHP_INSTALL_HEADERS([ext/simdjson], [php_simdjson.h])
40+
PHP_INSTALL_HEADERS([ext/simdjson], [php_simdjson.h, src/bindings.h src/bindings_impl.h])
3941
PHP_ADD_MAKEFILE_FRAGMENT
4042
PHP_ADD_BUILD_DIR(src, 1)
4143
fi

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ if (PHP_SIMDJSON == "yes") {
1111
'/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /std:c++latest');
1212
ADD_SOURCES(configure_module_dirname + '/src', 'simdjson.cpp bindings.cpp', 'simdjson');
1313
ADD_FLAG('CFLAGS_SIMDJSON', '/I' + configure_module_dirname);
14-
PHP_INSTALL_HEADERS('ext/simdjson', 'php_simdjson.h');
14+
PHP_INSTALL_HEADERS('ext/simdjson', 'php_simdjson.h src/bindings.h src/bindings_impl.h');
1515
}
1616
// vim:ft=javascript

package.xml

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,23 @@
2020
-->
2121
<date>2022-10-12</date>
2222
<version>
23-
<release>2.0.5</release>
24-
<api>2.0.5</api>
23+
<release>2.1.0dev</release>
24+
<api>2.1.0dev</api>
2525
</version>
2626
<stability>
2727
<release>stable</release>
2828
<api>stable</api>
2929
</stability>
3030
<license uri="https://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0</license>
3131
<notes>
32-
* Reuse PHP's 1-byte and 0-byte interned strings in simdjson_decode, reducing memory usage for those strings. (e.g. for the key/value in '{"x":""}')
33-
* Return correct count in simdjson_key_count. Properly return counts larger than 0xFFFFFF instead of returning 0xFFFFFF.
32+
* Allow out of range 64-bit values in JSON integer syntax and allow floating point values outside of the max/min finite floating point values (i.e. parsing to +/- infinity).
33+
34+
This allows simdjson_decode() to be used as a replacement for json_decode() in more use cases.
35+
* Return the correct value in simdjson_key_count() for JSON pointers to arrays/objects exceeding size 0xFFFFFF.
36+
Previously, this would be limited to returning at most 0xFFFFFF(16777215).
37+
* Throw 'SimdJsonException extends RuntimeException' instead of RuntimeException.
38+
* Set the error code from simdjson as SimdJsonException->getCode()
39+
* Expose error_code constants from simdjson as `SIMDJSON_ERR_$ERRCODENAME`
3440
</notes>
3541
<contents>
3642
<dir name="/">
@@ -42,9 +48,12 @@
4248
<file name="php_simdjson.h" role="src"/>
4349
<file name="php_simdjson.cpp" role="src"/>
4450
<file name="README.md" role="doc"/>
51+
<file name="simdjson.stub.php" role="src"/>
52+
<file name="simdjson_arginfo.h" role="src"/>
4553
<dir name="src">
4654
<file name="bindings.cpp" role="src"/>
4755
<file name="bindings.h" role="src"/>
56+
<file name="bindings_impl.h" role="src"/>
4857
<file name="simdjson.cpp" role="src"/>
4958
<file name="simdjson.h" role="src"/>
5059
</dir>
@@ -67,7 +76,6 @@
6776
<file name="key_count.phpt" role="test"/>
6877
<file name="key_count_args.phpt" role="test"/>
6978
<file name="key_count_exception.phpt" role="test"/>
70-
<file name="key_count_large.phpt" role="test"/>
7179
<file name="key_exists.phpt" role="test"/>
7280
<file name="key_exists_args.phpt" role="test"/>
7381
<file name="key_value_args.phpt" role="test"/>
@@ -77,6 +85,31 @@
7785
<file name="key_value_result.phpt" role="test"/>
7886
<file name="uint64_overflow.phpt" role="test"/>
7987
<file name="_files/result.json" role="test"/>
88+
<dir name="compat">
89+
<file name="001.phpt" role="test"/>
90+
<file name="bug41067.phpt" role="test"/>
91+
<file name="bug41403.phpt" role="test"/>
92+
<file name="bug41504.phpt" role="test"/>
93+
<file name="bug45791.phpt" role="test"/>
94+
<file name="bug47644.phpt" role="test"/>
95+
<file name="bug50224.phpt" role="test"/>
96+
<file name="bug62010.phpt" role="test"/>
97+
<file name="bug64874_part1.phpt" role="test"/>
98+
<file name="bug64874_part2.phpt" role="test"/>
99+
<file name="bug68546.phpt" role="test"/>
100+
<file name="bug68817.phpt" role="test"/>
101+
<file name="bug68938.phpt" role="test"/>
102+
<file name="bug69187.phpt" role="test"/>
103+
<file name="fail001.phpt" role="test"/>
104+
<file name="json_decode_basic.phpt" role="test"/>
105+
<file name="json_decode_error.phpt" role="test"/>
106+
<file name="json_decode_invalid_utf8.phpt" role="test"/>
107+
<file name="pass001.1_64bit.phpt" role="test"/>
108+
<file name="pass001.1.phpt" role="test"/>
109+
<file name="pass001.phpt" role="test"/>
110+
<file name="pass002.phpt" role="test"/>
111+
<file name="pass003.phpt" role="test"/>
112+
</dir>
80113
</dir>
81114
</dir>
82115
</contents>
@@ -93,6 +126,21 @@
93126
<providesextension>simdjson</providesextension>
94127
<extsrcrelease/>
95128
<changelog>
129+
<release>
130+
<date>2022-10-01</date>
131+
<version>
132+
<release>2.0.5</release>
133+
<api>2.0.5</api>
134+
</version>
135+
<stability>
136+
<release>stable</release>
137+
<api>stable</api>
138+
</stability>
139+
<license uri="https://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0</license>
140+
<notes>
141+
* Reuse PHP's 1-byte and 0-byte interned strings in simdjson_decode, reducing memory usage for those strings. (e.g. for the key/value in '{"x":""}')
142+
</notes>
143+
</release>
96144
<release>
97145
<date>2022-10-01</date>
98146
<version>

php_simdjson.cpp

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ extern "C" {
2020
#include "zend_exceptions.h"
2121
#include "main/SAPI.h"
2222
#include "ext/standard/info.h"
23+
#include "ext/spl/spl_exceptions.h"
2324

2425
#include "php_simdjson.h"
26+
#include "simdjson_arginfo.h"
2527
}
2628

2729
#include "src/bindings.h"
30+
#include "src/simdjson.h"
2831

2932
ZEND_DECLARE_MODULE_GLOBALS(simdjson);
3033

34+
ZEND_API zend_class_entry *simdjson_exception_ce;
35+
3136
#if PHP_VERSION_ID >= 70200
3237
#define SIMDJSON_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
3338
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null)
@@ -66,29 +71,15 @@ SIMDJSON_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(simdjson_key_count_arginfo, 0,
6671
ZEND_ARG_TYPE_INFO(0, depth, IS_LONG, 0)
6772
ZEND_END_ARG_INFO()
6873

69-
extern simdjson::dom::parser* cplus_simdjson_create_parser(void);
70-
71-
extern void cplus_simdjson_free_parser(simdjson::dom::parser* parser);
72-
73-
extern bool cplus_simdjson_is_valid(simdjson::dom::parser& parser, const char *json, size_t len, size_t depth);
74-
75-
extern void cplus_simdjson_parse(simdjson::dom::parser& parser, const char *json, size_t len, zval *return_value, unsigned char assoc, size_t depth);
76-
77-
extern void cplus_simdjson_key_value(simdjson::dom::parser& parser, const char *json, size_t len, const char *key, zval *return_value, unsigned char assoc, size_t depth);
78-
79-
extern u_short cplus_simdjson_key_exists(simdjson::dom::parser& parser, const char *json, size_t len, const char *key, size_t depth);
80-
81-
extern void cplus_simdjson_key_count(simdjson::dom::parser& parser, const char *json, size_t len, const char *key, zval *return_value, size_t depth);
82-
8374
#define SIMDJSON_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(simdjson, v)
84-
static simdjson::dom::parser &simdjson_get_parser() {
85-
simdjson::dom::parser *parser = (simdjson::dom::parser *)SIMDJSON_G(parser);
75+
static simdjson_php_parser *simdjson_get_parser() {
76+
simdjson_php_parser *parser = SIMDJSON_G(parser);
8677
if (parser == NULL) {
8778
parser = cplus_simdjson_create_parser();
8879
SIMDJSON_G(parser) = parser;
8980
ZEND_ASSERT(parser != NULL);
9081
}
91-
return *parser;
82+
return parser;
9283
}
9384

9485
// The simdjson parser accepts strings with at most 32-bit lengths, for now.
@@ -128,7 +119,10 @@ PHP_FUNCTION (simdjson_decode) {
128119
if (!simdjson_validate_depth(depth)) {
129120
RETURN_NULL();
130121
}
131-
cplus_simdjson_parse(simdjson_get_parser(), ZSTR_VAL(json), ZSTR_LEN(json), return_value, assoc, depth);
122+
simdjson_php_error_code error = cplus_simdjson_parse(simdjson_get_parser(), ZSTR_VAL(json), ZSTR_LEN(json), return_value, assoc, depth);
123+
if (error) {
124+
cplus_simdjson_throw_jsonexception(error);
125+
}
132126
}
133127

134128
PHP_FUNCTION (simdjson_key_value) {
@@ -143,7 +137,10 @@ PHP_FUNCTION (simdjson_key_value) {
143137
if (!simdjson_validate_depth(depth)) {
144138
RETURN_NULL();
145139
}
146-
cplus_simdjson_key_value(simdjson_get_parser(), ZSTR_VAL(json), ZSTR_LEN(json), ZSTR_VAL(key), return_value, assoc, depth);
140+
simdjson_php_error_code error = cplus_simdjson_key_value(simdjson_get_parser(), ZSTR_VAL(json), ZSTR_LEN(json), ZSTR_VAL(key), return_value, assoc, depth);
141+
if (error) {
142+
cplus_simdjson_throw_jsonexception(error);
143+
}
147144
}
148145

149146
PHP_FUNCTION (simdjson_key_count) {
@@ -156,7 +153,10 @@ PHP_FUNCTION (simdjson_key_count) {
156153
if (!simdjson_validate_depth(depth)) {
157154
RETURN_NULL();
158155
}
159-
cplus_simdjson_key_count(simdjson_get_parser(), ZSTR_VAL(json), ZSTR_LEN(json), ZSTR_VAL(key), return_value, depth);
156+
simdjson_php_error_code error = cplus_simdjson_key_count(simdjson_get_parser(), ZSTR_VAL(json), ZSTR_LEN(json), ZSTR_VAL(key), return_value, depth);
157+
if (error) {
158+
cplus_simdjson_throw_jsonexception(error);
159+
}
160160
}
161161

162162
PHP_FUNCTION (simdjson_key_exists) {
@@ -202,7 +202,42 @@ ZEND_TSRMLS_CACHE_UPDATE();
202202

203203
/** {{{ PHP_MINIT_FUNCTION
204204
*/
205+
#define SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(errcode) REGISTER_LONG_CONSTANT("SIMDJSON_ERR_" #errcode, simdjson::errcode, CONST_PERSISTENT)
206+
#define SIMDJSON_REGISTER_CUSTOM_ERROR_CODE_CONSTANT(errcode, val) REGISTER_LONG_CONSTANT("SIMDJSON_ERR_" #errcode, (val), CONST_PERSISTENT)
205207
PHP_MINIT_FUNCTION (simdjson) {
208+
simdjson_exception_ce = register_class_SimdJsonException(spl_ce_RuntimeException);
209+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(CAPACITY); ///< This parser can't support a document that big
210+
// SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(MEMALLOC); ///< Error allocating memory, most likely out of memory
211+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(TAPE_ERROR); ///< Something went wrong, this is a generic error
212+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(DEPTH_ERROR); ///< Your document exceeds the user-specified depth limitation
213+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(STRING_ERROR); ///< Problem while parsing a string
214+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(T_ATOM_ERROR); ///< Problem while parsing an atom starting with the letter 't'
215+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(F_ATOM_ERROR); ///< Problem while parsing an atom starting with the letter 'f'
216+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(N_ATOM_ERROR); ///< Problem while parsing an atom starting with the letter 'n'
217+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(NUMBER_ERROR); ///< Problem while parsing a number
218+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(UTF8_ERROR); ///< the input is not valid UTF-8
219+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(UNINITIALIZED); ///< unknown error, or uninitialized document
220+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(EMPTY); ///< no structural element found
221+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(UNESCAPED_CHARS); ///< found unescaped characters in a string.
222+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(UNCLOSED_STRING); ///< missing quote at the end
223+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(UNSUPPORTED_ARCHITECTURE); ///< unsupported architecture
224+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(INCORRECT_TYPE); ///< JSON element has a different type than user expected
225+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(NUMBER_OUT_OF_RANGE); ///< JSON number does not fit in 64 bits
226+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(INDEX_OUT_OF_BOUNDS); ///< JSON array index too large
227+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(NO_SUCH_FIELD); ///< JSON field not found in object
228+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(IO_ERROR); ///< Error reading a file
229+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(INVALID_JSON_POINTER); ///< Invalid JSON pointer reference
230+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(INVALID_URI_FRAGMENT); ///< Invalid URI fragment
231+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(UNEXPECTED_ERROR); ///< indicative of a bug in simdjson
232+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(PARSER_IN_USE); ///< parser is already in use.
233+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(OUT_OF_ORDER_ITERATION); ///< tried to iterate an array or object out of order
234+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(INSUFFICIENT_PADDING); ///< The JSON doesn't have enough padding for simdjson to safely parse it.
235+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(INCOMPLETE_ARRAY_OR_OBJECT); ///< The document ends early.
236+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(SCALAR_DOCUMENT_AS_VALUE); ///< A scalar document is treated as a value.
237+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(OUT_OF_BOUNDS); ///< Attempted to access location outside of document.
238+
SIMDJSON_REGISTER_ERROR_CODE_CONSTANT(TRAILING_CONTENT); ///< Unexpected trailing content in the JSON input
239+
SIMDJSON_REGISTER_CUSTOM_ERROR_CODE_CONSTANT(INVALID_PROPERTY, 255); ///< Invalid property
240+
206241
return SUCCESS;
207242
}
208243
/* }}} */
@@ -225,9 +260,9 @@ PHP_RINIT_FUNCTION (simdjson) {
225260
/** {{{ PHP_RSHUTDOWN_FUNCTION
226261
*/
227262
PHP_RSHUTDOWN_FUNCTION (simdjson) {
228-
void *parser = SIMDJSON_G(parser);
263+
simdjson_php_parser *parser = SIMDJSON_G(parser);
229264
if (parser != NULL) {
230-
cplus_simdjson_free_parser((simdjson::dom::parser *) parser);
265+
cplus_simdjson_free_parser(parser);
231266
SIMDJSON_G(parser) = NULL;
232267
}
233268
return SUCCESS;

php_simdjson.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
extern zend_module_entry simdjson_module_entry;
1818
#define phpext_simdjson_ptr &simdjson_module_entry
1919

20-
#define PHP_SIMDJSON_VERSION "2.0.5"
20+
#define PHP_SIMDJSON_VERSION "2.1.0dev"
2121
#define SIMDJSON_SUPPORT_URL "https://github.com/crazyxman/simdjson_php"
2222
#define SIMDJSON_PARSE_FAIL 0
2323
#define SIMDJSON_PARSE_SUCCESS 1
@@ -26,17 +26,20 @@ extern zend_module_entry simdjson_module_entry;
2626

2727
#define SIMDJSON_PARSE_DEFAULT_DEPTH 512
2828

29-
30-
extern PHPAPI void php_var_dump(zval **struc, int level);
31-
extern PHPAPI void php_debug_zval_dump(zval **struc, int level);
29+
/*
30+
* NOTE: Namespaces and references(&) are C++ only functionality.
31+
* To expose this functionality to other C PECLs,
32+
* switch to a forward class declaration of a class that only wraps simdjson::dom::parser
33+
*/
34+
class simdjson_php_parser;
3235

3336
ZEND_BEGIN_MODULE_GLOBALS(simdjson)
3437
/*
3538
* php::simdjson::parser pointer, constructed on first use with request-scope lifetime.
3639
* Note that in ZTS builds, the thread for each request will deliberately have different instances for each concurrently running request.
3740
* (The simdjson library is not thread safe)
3841
*/
39-
void *parser;
42+
simdjson_php_parser *parser;
4043
ZEND_END_MODULE_GLOBALS(simdjson)
4144

4245
PHP_MINIT_FUNCTION(simdjson);

simdjson.stub.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* This is used with php-src's build/gen_stubs.php to generate argument info compatible with php 7.0 and above.
4+
*
5+
* See README.md for function documentation.
6+
*
7+
* @generate-class-entries
8+
*/
9+
10+
class SimdJsonException extends RuntimeException {
11+
}

0 commit comments

Comments
 (0)