diff --git a/.github/workflows/arginfo-files.yml b/.github/workflows/arginfo-files.yml new file mode 100644 index 000000000..95ab278d7 --- /dev/null +++ b/.github/workflows/arginfo-files.yml @@ -0,0 +1,44 @@ +name: "Check generated arginfo files" + +on: + pull_request: + branches: + - "v*.*" + - "master" + - "feature/*" + push: + branches: + - "v*.*" + - "master" + - "feature/*" + +jobs: + check-arginfo: + name: "Check generated arginfo files" + runs-on: "ubuntu-20.04" + + strategy: + matrix: + php-version: + - "8.2" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + submodules: true + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + tools: "phpize" + + - name: "Run phpize" + run: phpize + + - name: "Rebuild arginfo files from stubs" + run: "php ./build/gen_stub.php" + + - name: "Check arginfo file diff" + run: git add . -N && git diff --exit-code diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 72c162604..16fef612d 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -32,7 +32,6 @@ jobs: uses: "shivammathur/setup-php@v2" with: php-version: "${{ matrix.php-version }}" - extensions: ":mongodb" tools: "phpize" - name: "Configure driver" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 25fa7e71d..30fcaf853 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -65,7 +65,6 @@ jobs: uses: "shivammathur/setup-php@v2" with: php-version: "${{ matrix.php-version }}" - extensions: ":mongodb" tools: "phpize" - name: "Configure driver" diff --git a/.gitignore b/.gitignore index 8695a1183..4f8e0bf72 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ mongocryptd.pid *.out *.mem *.php +!*.stub.php tests/*/*.sh tests/*/*/*/*.sh tests/*/*/*/*/*.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9d16610ed..2d55529fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,6 +21,13 @@ phpize > /dev/null && \ make clean > /dev/null && make all > /dev/null && make install ``` +## Generating arginfo from stub files + +Arginfo structures are generated from stub files using the `gen_stub.php` +file. Note that this requires `phpize` to be run for PHP 8.2 to make use +of all features. After changing a stub file, run `./build/gen_stub.php` +to regenerate the corresponding arginfo files and commit the results. + ## Testing The extension's test use the PHPT format from PHP internals. This format is diff --git a/config.m4 b/config.m4 index 454f57c05..aca144bd1 100644 --- a/config.m4 +++ b/config.m4 @@ -66,7 +66,6 @@ if test "$PHP_MONGODB" != "no"; then AX_CHECK_COMPILE_FLAG(-Wenum-compare, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wenum-compare" ,, -Werror) AX_CHECK_COMPILE_FLAG(-Wempty-body, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wempty-body" ,, -Werror) AX_CHECK_COMPILE_FLAG(-Wparentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wparentheses" ,, -Werror) - AX_CHECK_COMPILE_FLAG(-Wdeclaration-after-statement, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdeclaration-after-statement" ,, -Werror) AX_CHECK_COMPILE_FLAG(-Wmaybe-uninitialized, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wmaybe-uninitialized" ,, -Werror) AX_CHECK_COMPILE_FLAG(-Wimplicit-fallthrough, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wimplicit-fallthrough" ,, -Werror) AX_CHECK_COMPILE_FLAG(-Werror, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Werror" ,, -Werror) diff --git a/php_phongo.c b/php_phongo.c index 7292a3447..e93f54c20 100644 --- a/php_phongo.c +++ b/php_phongo.c @@ -44,7 +44,6 @@ ZEND_TSRMLS_CACHE_DEFINE(); static int32_t phongo_num_threads = 0; /* Declare zend_class_entry dependencies, which are initialized in MINIT */ -zend_class_entry* php_phongo_date_immutable_ce; zend_class_entry* php_phongo_json_serializable_ce; /* {{{ phongo_std_object_handlers */ @@ -181,17 +180,12 @@ PHP_MINIT_FUNCTION(mongodb) /* {{{ */ phongo_std_object_handlers.get_gc = php_phongo_std_get_gc; /* Initialize zend_class_entry dependencies. - * - * Although DateTimeImmutable was introduced in PHP 5.5.0, - * php_date_get_immutable_ce() is not available in PHP versions before - * 5.5.24 and 5.6.8. * * Although JsonSerializable was introduced in PHP 5.4.0, * php_json_serializable_ce is not exported in PHP versions before 5.4.26 * and 5.5.10. For later PHP versions, looking up the class manually also * helps with distros that disable LTDL_LAZY for dlopen() (e.g. Fedora). */ - php_phongo_date_immutable_ce = php_phongo_fetch_internal_class(ZEND_STRL("datetimeimmutable")); php_phongo_json_serializable_ce = php_phongo_fetch_internal_class(ZEND_STRL("jsonserializable")); if (php_phongo_json_serializable_ce == NULL) { diff --git a/php_phongo.h b/php_phongo.h index 29dceef46..bd3a93828 100644 --- a/php_phongo.h +++ b/php_phongo.h @@ -109,6 +109,20 @@ zend_object_handlers* phongo_get_std_object_handlers(void); (intern)->created_by_pid = (int) getpid(); \ } while (0) +#define PHONGO_DISABLED_CONSTRUCTOR(classname) \ + static PHP_METHOD(classname, __construct) \ + { \ + PHONGO_PARSE_PARAMETERS_NONE(); \ + phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Accessing private constructor"); \ + } + +#define PHONGO_DISABLED_WAKEUP(classname) \ + static PHP_METHOD(classname, __wakeup) \ + { \ + PHONGO_PARSE_PARAMETERS_NONE(); \ + phongo_throw_exception(PHONGO_ERROR_RUNTIME, "MongoDB\\Driver objects cannot be serialized"); \ + } + /* Shared function entries for disabling constructors and unserialize() */ PHP_FUNCTION(MongoDB_disabled___construct); PHP_FUNCTION(MongoDB_disabled___wakeup); diff --git a/scripts/clang-format.sh b/scripts/clang-format.sh index e414869db..d454b485a 100755 --- a/scripts/clang-format.sh +++ b/scripts/clang-format.sh @@ -3,12 +3,12 @@ CLANG_ARGS="-Werror" if test x"$1" = xchanged; then - FILES1=`git ls-files | grep -v "src/contrib" | grep '\.[ch]$'` - FILES2=`git ls-files --others --exclude-standard | grep -v "src/contrib" | grep '\.[ch]$'` + FILES1=`git ls-files | grep -v "src/contrib" | grep -v "_arginfo.h" | grep '\.[ch]$'` + FILES2=`git ls-files --others --exclude-standard | grep -v "src/contrib" | grep -v "_arginfo.h" | grep '\.[ch]$'` FILES="$FILES1 $FILES2" else - FILES1=`git ls-files | grep -v "src/contrib" | grep '\.[ch]$'` - FILES2=`git ls-files --others --exclude-standard | grep -v "src/contrib" | grep '\.[ch]$'` + FILES1=`git ls-files | grep -v "src/contrib" | grep -v "_arginfo.h" | grep '\.[ch]$'` + FILES2=`git ls-files --others --exclude-standard | grep -v "src/contrib" | grep -v "_arginfo.h" | grep '\.[ch]$'` FILES="$FILES1 $FILES2" fi diff --git a/src/BSON/Binary.c b/src/BSON/Binary.c index 3f993d7bf..5a0bd3fc2 100644 --- a/src/BSON/Binary.c +++ b/src/BSON/Binary.c @@ -22,6 +22,7 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "Binary_arginfo.h" #define PHONGO_BINARY_UUID_SIZE 16 @@ -92,7 +93,7 @@ static HashTable* php_phongo_binary_get_properties_hash(phongo_compat_object_han /* {{{ proto void MongoDB\BSON\Binary::__construct(string $data, int $type) Construct a new BSON binary type */ -static PHP_METHOD(Binary, __construct) +static PHP_METHOD(MongoDB_BSON_Binary, __construct) { php_phongo_binary_t* intern; char* data; @@ -111,7 +112,7 @@ static PHP_METHOD(Binary, __construct) /* {{{ proto MongoDB\BSON\Binary MongoDB\BSON\Binary::__set_state(array $properties) */ -static PHP_METHOD(Binary, __set_state) +static PHP_METHOD(MongoDB_BSON_Binary, __set_state) { php_phongo_binary_t* intern; HashTable* props; @@ -131,7 +132,7 @@ static PHP_METHOD(Binary, __set_state) /* {{{ proto string MongoDB\BSON\Binary::__toString() Return the Binary's data string. */ -static PHP_METHOD(Binary, __toString) +static PHP_METHOD(MongoDB_BSON_Binary, __toString) { php_phongo_binary_t* intern; @@ -144,7 +145,7 @@ static PHP_METHOD(Binary, __toString) /* {{{ proto string MongoDB\BSON\Binary::getData() */ -static PHP_METHOD(Binary, getData) +static PHP_METHOD(MongoDB_BSON_Binary, getData) { php_phongo_binary_t* intern; @@ -157,7 +158,7 @@ static PHP_METHOD(Binary, getData) /* {{{ proto integer MongoDB\BSON\Binary::getType() */ -static PHP_METHOD(Binary, getType) +static PHP_METHOD(MongoDB_BSON_Binary, getType) { php_phongo_binary_t* intern; @@ -170,7 +171,7 @@ static PHP_METHOD(Binary, getType) /* {{{ proto array MongoDB\BSON\Binary::jsonSerialize() */ -static PHP_METHOD(Binary, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_Binary, jsonSerialize) { php_phongo_binary_t* intern; char type[3]; @@ -194,7 +195,7 @@ static PHP_METHOD(Binary, jsonSerialize) /* {{{ proto string MongoDB\BSON\Binary::serialize() */ -static PHP_METHOD(Binary, serialize) +static PHP_METHOD(MongoDB_BSON_Binary, serialize) { php_phongo_binary_t* intern; zval retval; @@ -222,7 +223,7 @@ static PHP_METHOD(Binary, serialize) /* {{{ proto void MongoDB\BSON\Binary::unserialize(string $serialized) */ -static PHP_METHOD(Binary, unserialize) +static PHP_METHOD(MongoDB_BSON_Binary, unserialize) { php_phongo_binary_t* intern; char* serialized; @@ -252,7 +253,7 @@ static PHP_METHOD(Binary, unserialize) /* {{{ proto array MongoDB\Driver\Binary::__serialize() */ -static PHP_METHOD(Binary, __serialize) +static PHP_METHOD(MongoDB_BSON_Binary, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -261,7 +262,7 @@ static PHP_METHOD(Binary, __serialize) /* {{{ proto void MongoDB\Driver\Binary::__unserialize(array $data) */ -static PHP_METHOD(Binary, __unserialize) +static PHP_METHOD(MongoDB_BSON_Binary, __unserialize) { zval* data; @@ -272,50 +273,6 @@ static PHP_METHOD(Binary, __unserialize) php_phongo_binary_init_from_hash(Z_BINARY_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\BSON\Binary function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_Binary___construct, 0, 0, 2) - ZEND_ARG_INFO(0, data) - ZEND_ARG_INFO(0, type) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Binary___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_Binary___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Binary___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Binary_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Binary_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Binary_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_binary_me[] = { - PHP_ME(Binary, __construct, ai_Binary___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Binary, __serialize, ai_Binary_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Binary, __set_state, ai_Binary___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(Binary, __toString, ai_Binary___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Binary, __unserialize, ai_Binary___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Binary, jsonSerialize, ai_Binary_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Binary, serialize, ai_Binary_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Binary, unserialize, ai_Binary_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Binary, getData, ai_Binary_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Binary, getType, ai_Binary_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\Binary object handlers */ static zend_object_handlers php_phongo_handler_binary; @@ -400,17 +357,8 @@ static HashTable* php_phongo_binary_get_properties(phongo_compat_object_handler_ void php_phongo_binary_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Binary", php_phongo_binary_me); - php_phongo_binary_ce = zend_register_internal_class(&ce); + php_phongo_binary_ce = register_class_MongoDB_BSON_Binary(php_phongo_binary_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_binary_ce->create_object = php_phongo_binary_create_object; - PHONGO_CE_FINAL(php_phongo_binary_ce); - - zend_class_implements(php_phongo_binary_ce, 1, php_phongo_binary_interface_ce); - zend_class_implements(php_phongo_binary_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_binary_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_binary_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_binary_ce, 1, zend_ce_stringable); @@ -423,14 +371,4 @@ void php_phongo_binary_init_ce(INIT_FUNC_ARGS) /* {{{ */ php_phongo_handler_binary.get_properties = php_phongo_binary_get_properties; php_phongo_handler_binary.free_obj = php_phongo_binary_free_object; php_phongo_handler_binary.offset = XtOffsetOf(php_phongo_binary_t, std); - - zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_GENERIC"), BSON_SUBTYPE_BINARY); - zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_FUNCTION"), BSON_SUBTYPE_FUNCTION); - zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_OLD_BINARY"), BSON_SUBTYPE_BINARY_DEPRECATED); - zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_OLD_UUID"), BSON_SUBTYPE_UUID_DEPRECATED); - zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_UUID"), BSON_SUBTYPE_UUID); - zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_MD5"), BSON_SUBTYPE_MD5); - zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_ENCRYPTED"), BSON_SUBTYPE_ENCRYPTED); - zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_COLUMN"), BSON_SUBTYPE_COLUMN); - zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_USER_DEFINED"), BSON_SUBTYPE_USER); } /* }}} */ diff --git a/src/BSON/Binary.stub.php b/src/BSON/Binary.stub.php new file mode 100644 index 000000000..1fee479ef --- /dev/null +++ b/src/BSON/Binary.stub.php @@ -0,0 +1,92 @@ += 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/BinaryInterface.c b/src/BSON/BinaryInterface.c index 2d02e7d97..7799e3526 100644 --- a/src/BSON/BinaryInterface.c +++ b/src/BSON/BinaryInterface.c @@ -17,30 +17,11 @@ #include #include "php_phongo.h" +#include "BinaryInterface_arginfo.h" zend_class_entry* php_phongo_binary_interface_ce; -/* {{{ MongoDB\BSON\BinaryInterface function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_BinaryInterface___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_BinaryInterface_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_binary_interface_me[] = { - ZEND_ABSTRACT_ME(BinaryInterface, getData, ai_BinaryInterface_void) - ZEND_ABSTRACT_ME(BinaryInterface, getType, ai_BinaryInterface_void) - ZEND_ABSTRACT_ME(BinaryInterface, __toString, ai_BinaryInterface___toString) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - void php_phongo_binary_interface_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "BinaryInterface", php_phongo_binary_interface_me); - php_phongo_binary_interface_ce = zend_register_internal_interface(&ce); + php_phongo_binary_interface_ce = register_class_MongoDB_BSON_BinaryInterface(); } /* }}} */ diff --git a/src/BSON/BinaryInterface.stub.php b/src/BSON/BinaryInterface.stub.php new file mode 100644 index 000000000..582c0b2d8 --- /dev/null +++ b/src/BSON/BinaryInterface.stub.php @@ -0,0 +1,20 @@ += 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Binary_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Binary_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +static ZEND_METHOD(MongoDB_BSON_Binary, __construct); +static ZEND_METHOD(MongoDB_BSON_Binary, getData); +static ZEND_METHOD(MongoDB_BSON_Binary, getType); +static ZEND_METHOD(MongoDB_BSON_Binary, __set_state); +static ZEND_METHOD(MongoDB_BSON_Binary, __toString); +static ZEND_METHOD(MongoDB_BSON_Binary, serialize); +static ZEND_METHOD(MongoDB_BSON_Binary, unserialize); +static ZEND_METHOD(MongoDB_BSON_Binary, __unserialize); +static ZEND_METHOD(MongoDB_BSON_Binary, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_Binary, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_Binary, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_Binary_methods[] = { + ZEND_ME(MongoDB_BSON_Binary, __construct, arginfo_class_MongoDB_BSON_Binary___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Binary, getData, arginfo_class_MongoDB_BSON_Binary_getData, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Binary, getType, arginfo_class_MongoDB_BSON_Binary_getType, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Binary, __set_state, arginfo_class_MongoDB_BSON_Binary___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(MongoDB_BSON_Binary, __toString, arginfo_class_MongoDB_BSON_Binary___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Binary, serialize, arginfo_class_MongoDB_BSON_Binary_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Binary, unserialize, arginfo_class_MongoDB_BSON_Binary_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Binary, __unserialize, arginfo_class_MongoDB_BSON_Binary___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Binary, __serialize, arginfo_class_MongoDB_BSON_Binary___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_Binary, jsonSerialize, arginfo_class_MongoDB_BSON_Binary_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_Binary, jsonSerialize, arginfo_class_MongoDB_BSON_Binary_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_Binary(zend_class_entry *class_entry_MongoDB_BSON_BinaryInterface, zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Binary", class_MongoDB_BSON_Binary_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 4, class_entry_MongoDB_BSON_BinaryInterface, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + zval const_TYPE_GENERIC_value; + ZVAL_LONG(&const_TYPE_GENERIC_value, BSON_SUBTYPE_BINARY); + zend_string *const_TYPE_GENERIC_name = zend_string_init_interned("TYPE_GENERIC", sizeof("TYPE_GENERIC") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_GENERIC_name, &const_TYPE_GENERIC_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_GENERIC_name); + + zval const_TYPE_FUNCTION_value; + ZVAL_LONG(&const_TYPE_FUNCTION_value, BSON_SUBTYPE_FUNCTION); + zend_string *const_TYPE_FUNCTION_name = zend_string_init_interned("TYPE_FUNCTION", sizeof("TYPE_FUNCTION") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_FUNCTION_name, &const_TYPE_FUNCTION_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_FUNCTION_name); + + zval const_TYPE_OLD_BINARY_value; + ZVAL_LONG(&const_TYPE_OLD_BINARY_value, BSON_SUBTYPE_BINARY_DEPRECATED); + zend_string *const_TYPE_OLD_BINARY_name = zend_string_init_interned("TYPE_OLD_BINARY", sizeof("TYPE_OLD_BINARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_OLD_BINARY_name, &const_TYPE_OLD_BINARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_OLD_BINARY_name); + + zval const_TYPE_OLD_UUID_value; + ZVAL_LONG(&const_TYPE_OLD_UUID_value, BSON_SUBTYPE_UUID_DEPRECATED); + zend_string *const_TYPE_OLD_UUID_name = zend_string_init_interned("TYPE_OLD_UUID", sizeof("TYPE_OLD_UUID") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_OLD_UUID_name, &const_TYPE_OLD_UUID_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_OLD_UUID_name); + + zval const_TYPE_UUID_value; + ZVAL_LONG(&const_TYPE_UUID_value, BSON_SUBTYPE_UUID); + zend_string *const_TYPE_UUID_name = zend_string_init_interned("TYPE_UUID", sizeof("TYPE_UUID") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_UUID_name, &const_TYPE_UUID_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_UUID_name); + + zval const_TYPE_MD5_value; + ZVAL_LONG(&const_TYPE_MD5_value, BSON_SUBTYPE_MD5); + zend_string *const_TYPE_MD5_name = zend_string_init_interned("TYPE_MD5", sizeof("TYPE_MD5") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_MD5_name, &const_TYPE_MD5_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_MD5_name); + + zval const_TYPE_ENCRYPTED_value; + ZVAL_LONG(&const_TYPE_ENCRYPTED_value, BSON_SUBTYPE_ENCRYPTED); + zend_string *const_TYPE_ENCRYPTED_name = zend_string_init_interned("TYPE_ENCRYPTED", sizeof("TYPE_ENCRYPTED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_ENCRYPTED_name, &const_TYPE_ENCRYPTED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_ENCRYPTED_name); + + zval const_TYPE_COLUMN_value; + ZVAL_LONG(&const_TYPE_COLUMN_value, BSON_SUBTYPE_COLUMN); + zend_string *const_TYPE_COLUMN_name = zend_string_init_interned("TYPE_COLUMN", sizeof("TYPE_COLUMN") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_COLUMN_name, &const_TYPE_COLUMN_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_COLUMN_name); + + zval const_TYPE_USER_DEFINED_value; + ZVAL_LONG(&const_TYPE_USER_DEFINED_value, BSON_SUBTYPE_USER); + zend_string *const_TYPE_USER_DEFINED_name = zend_string_init_interned("TYPE_USER_DEFINED", sizeof("TYPE_USER_DEFINED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_USER_DEFINED_name, &const_TYPE_USER_DEFINED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_USER_DEFINED_name); + + return class_entry; +} diff --git a/src/BSON/DBPointer.c b/src/BSON/DBPointer.c index e1d954876..c848771d3 100644 --- a/src/BSON/DBPointer.c +++ b/src/BSON/DBPointer.c @@ -23,6 +23,7 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "DBPointer_arginfo.h" zend_class_entry* php_phongo_dbpointer_ce; @@ -90,9 +91,11 @@ HashTable* php_phongo_dbpointer_get_properties_hash(phongo_compat_object_handler return props; } /* }}} */ +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_DBPointer) + /* {{{ proto string MongoDB\BSON\DBPointer::__toString() Return the DBPointer's namespace string and ObjectId. */ -static PHP_METHOD(DBPointer, __toString) +static PHP_METHOD(MongoDB_BSON_DBPointer, __toString) { php_phongo_dbpointer_t* intern; char* retval; @@ -109,7 +112,7 @@ static PHP_METHOD(DBPointer, __toString) /* {{{ proto array MongoDB\BSON\Symbol::jsonSerialize() */ -static PHP_METHOD(DBPointer, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_DBPointer, jsonSerialize) { php_phongo_dbpointer_t* intern; zval zdb_pointer; @@ -131,7 +134,7 @@ static PHP_METHOD(DBPointer, jsonSerialize) /* {{{ proto string MongoDB\BSON\DBPointer::serialize() */ -static PHP_METHOD(DBPointer, serialize) +static PHP_METHOD(MongoDB_BSON_DBPointer, serialize) { php_phongo_dbpointer_t* intern; zval retval; @@ -159,7 +162,7 @@ static PHP_METHOD(DBPointer, serialize) /* {{{ proto void MongoDB\BSON\DBPointer::unserialize(string $serialized) */ -static PHP_METHOD(DBPointer, unserialize) +static PHP_METHOD(MongoDB_BSON_DBPointer, unserialize) { php_phongo_dbpointer_t* intern; char* serialized; @@ -189,7 +192,7 @@ static PHP_METHOD(DBPointer, unserialize) /* {{{ proto array MongoDB\Driver\DBPointer::__serialize() */ -static PHP_METHOD(DBPointer, __serialize) +static PHP_METHOD(MongoDB_BSON_DBPointer, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -198,7 +201,7 @@ static PHP_METHOD(DBPointer, __serialize) /* {{{ proto void MongoDB\Driver\DBPointer::__unserialize(array $data) */ -static PHP_METHOD(DBPointer, __unserialize) +static PHP_METHOD(MongoDB_BSON_DBPointer, __unserialize) { zval* data; @@ -209,39 +212,6 @@ static PHP_METHOD(DBPointer, __unserialize) php_phongo_dbpointer_init_from_hash(Z_DBPOINTER_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\BSON\DBPointer function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_DBPointer___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_DBPointer___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_DBPointer_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_DBPointer_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_DBPointer_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_dbpointer_me[] = { - /* __set_state intentionally missing */ - PHP_ME(DBPointer, __serialize, ai_DBPointer_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(DBPointer, __toString, ai_DBPointer___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(DBPointer, __unserialize, ai_DBPointer___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(DBPointer, jsonSerialize, ai_DBPointer_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(DBPointer, serialize, ai_DBPointer_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(DBPointer, unserialize, ai_DBPointer_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_DBPointer_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\DBPointer object handlers */ static zend_object_handlers php_phongo_handler_dbpointer; @@ -323,16 +293,8 @@ static HashTable* php_phongo_dbpointer_get_properties(phongo_compat_object_handl void php_phongo_dbpointer_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "DBPointer", php_phongo_dbpointer_me); - php_phongo_dbpointer_ce = zend_register_internal_class(&ce); + php_phongo_dbpointer_ce = register_class_MongoDB_BSON_DBPointer(php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_dbpointer_ce->create_object = php_phongo_dbpointer_create_object; - PHONGO_CE_FINAL(php_phongo_dbpointer_ce); - - zend_class_implements(php_phongo_dbpointer_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_dbpointer_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_dbpointer_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_dbpointer_ce, 1, zend_ce_stringable); diff --git a/src/BSON/DBPointer.stub.php b/src/BSON/DBPointer.stub.php new file mode 100644 index 000000000..4bfa12fd7 --- /dev/null +++ b/src/BSON/DBPointer.stub.php @@ -0,0 +1,32 @@ += 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/DBPointer_arginfo.h b/src/BSON/DBPointer_arginfo.h new file mode 100644 index 000000000..577fa4616 --- /dev/null +++ b/src/BSON/DBPointer_arginfo.h @@ -0,0 +1,74 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 9f87f398d061bfa61312f34693a7e1a47a6803d5 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_DBPointer___construct, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_DBPointer___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_BSON_DBPointer_serialize arginfo_class_MongoDB_BSON_DBPointer___toString + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_DBPointer_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_DBPointer___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_DBPointer___serialize, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_DBPointer_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_DBPointer_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +static ZEND_METHOD(MongoDB_BSON_DBPointer, __construct); +static ZEND_METHOD(MongoDB_BSON_DBPointer, __toString); +static ZEND_METHOD(MongoDB_BSON_DBPointer, serialize); +static ZEND_METHOD(MongoDB_BSON_DBPointer, unserialize); +static ZEND_METHOD(MongoDB_BSON_DBPointer, __unserialize); +static ZEND_METHOD(MongoDB_BSON_DBPointer, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_DBPointer, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_DBPointer, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_DBPointer_methods[] = { + ZEND_ME(MongoDB_BSON_DBPointer, __construct, arginfo_class_MongoDB_BSON_DBPointer___construct, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_DBPointer, __toString, arginfo_class_MongoDB_BSON_DBPointer___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_DBPointer, serialize, arginfo_class_MongoDB_BSON_DBPointer_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_DBPointer, unserialize, arginfo_class_MongoDB_BSON_DBPointer_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_DBPointer, __unserialize, arginfo_class_MongoDB_BSON_DBPointer___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_DBPointer, __serialize, arginfo_class_MongoDB_BSON_DBPointer___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_DBPointer, jsonSerialize, arginfo_class_MongoDB_BSON_DBPointer_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_DBPointer, jsonSerialize, arginfo_class_MongoDB_BSON_DBPointer_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_DBPointer(zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "DBPointer", class_MongoDB_BSON_DBPointer_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 3, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/Decimal128.c b/src/BSON/Decimal128.c index 21c5a9d1c..673a13f8d 100644 --- a/src/BSON/Decimal128.c +++ b/src/BSON/Decimal128.c @@ -23,6 +23,7 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "Decimal128_arginfo.h" zend_class_entry* php_phongo_decimal128_ce; @@ -82,7 +83,7 @@ static HashTable* php_phongo_decimal128_get_properties_hash(phongo_compat_object /* {{{ proto void MongoDB\BSON\Decimal128::__construct(string $value) Construct a new BSON Decimal128 type */ -static PHP_METHOD(Decimal128, __construct) +static PHP_METHOD(MongoDB_BSON_Decimal128, __construct) { php_phongo_decimal128_t* intern; char* value; @@ -99,7 +100,7 @@ static PHP_METHOD(Decimal128, __construct) /* {{{ proto MongoDB\BSON\Decimal128 MongoDB\BSON\Decimal128::__set_state(array $properties) */ -static PHP_METHOD(Decimal128, __set_state) +static PHP_METHOD(MongoDB_BSON_Decimal128, __set_state) { php_phongo_decimal128_t* intern; HashTable* props; @@ -119,7 +120,7 @@ static PHP_METHOD(Decimal128, __set_state) /* {{{ proto string MongoDB\BSON\Decimal128::__toString() */ -static PHP_METHOD(Decimal128, __toString) +static PHP_METHOD(MongoDB_BSON_Decimal128, __toString) { php_phongo_decimal128_t* intern; char outbuf[BSON_DECIMAL128_STRING]; @@ -135,7 +136,7 @@ static PHP_METHOD(Decimal128, __toString) /* {{{ proto array MongoDB\BSON\Decimal128::jsonSerialize() */ -static PHP_METHOD(Decimal128, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_Decimal128, jsonSerialize) { php_phongo_decimal128_t* intern; char outbuf[BSON_DECIMAL128_STRING] = ""; @@ -151,7 +152,7 @@ static PHP_METHOD(Decimal128, jsonSerialize) /* {{{ proto string MongoDB\BSON\Decimal128::serialize() */ -static PHP_METHOD(Decimal128, serialize) +static PHP_METHOD(MongoDB_BSON_Decimal128, serialize) { php_phongo_decimal128_t* intern; zval retval; @@ -180,7 +181,7 @@ static PHP_METHOD(Decimal128, serialize) /* {{{ proto void MongoDB\BSON\Decimal128::unserialize(string $serialized) */ -static PHP_METHOD(Decimal128, unserialize) +static PHP_METHOD(MongoDB_BSON_Decimal128, unserialize) { php_phongo_decimal128_t* intern; char* serialized; @@ -210,7 +211,7 @@ static PHP_METHOD(Decimal128, unserialize) /* {{{ proto array MongoDB\Driver\Decimal128::__serialize() */ -static PHP_METHOD(Decimal128, __serialize) +static PHP_METHOD(MongoDB_BSON_Decimal128, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -219,7 +220,7 @@ static PHP_METHOD(Decimal128, __serialize) /* {{{ proto void MongoDB\Driver\Decimal128::__unserialize(array $data) */ -static PHP_METHOD(Decimal128, __unserialize) +static PHP_METHOD(MongoDB_BSON_Decimal128, __unserialize) { zval* data; @@ -230,47 +231,6 @@ static PHP_METHOD(Decimal128, __unserialize) php_phongo_decimal128_init_from_hash(Z_DECIMAL128_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\BSON\Decimal128 function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_Decimal128___construct, 0, 0, 1) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Decimal128___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_Decimal128___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Decimal128___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Decimal128_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Decimal128_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Decimal128_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_decimal128_me[] = { - PHP_ME(Decimal128, __construct, ai_Decimal128___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Decimal128, __serialize, ai_Decimal128_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Decimal128, __set_state, ai_Decimal128___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(Decimal128, __toString, ai_Decimal128___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Decimal128, __unserialize, ai_Decimal128___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Decimal128, jsonSerialize, ai_Decimal128_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Decimal128, serialize, ai_Decimal128_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Decimal128, unserialize, ai_Decimal128_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\Decimal128 object handlers */ static zend_object_handlers php_phongo_handler_decimal128; @@ -331,17 +291,8 @@ static HashTable* php_phongo_decimal128_get_properties(phongo_compat_object_hand void php_phongo_decimal128_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Decimal128", php_phongo_decimal128_me); - php_phongo_decimal128_ce = zend_register_internal_class(&ce); + php_phongo_decimal128_ce = register_class_MongoDB_BSON_Decimal128(php_phongo_decimal128_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_decimal128_ce->create_object = php_phongo_decimal128_create_object; - PHONGO_CE_FINAL(php_phongo_decimal128_ce); - - zend_class_implements(php_phongo_decimal128_ce, 1, php_phongo_decimal128_interface_ce); - zend_class_implements(php_phongo_decimal128_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_decimal128_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_decimal128_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_decimal128_ce, 1, zend_ce_stringable); diff --git a/src/BSON/Decimal128.stub.php b/src/BSON/Decimal128.stub.php new file mode 100644 index 000000000..52be3e7d0 --- /dev/null +++ b/src/BSON/Decimal128.stub.php @@ -0,0 +1,34 @@ += 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/Decimal128Interface.c b/src/BSON/Decimal128Interface.c index f4d559611..80afb7912 100644 --- a/src/BSON/Decimal128Interface.c +++ b/src/BSON/Decimal128Interface.c @@ -17,25 +17,11 @@ #include #include "php_phongo.h" +#include "Decimal128Interface_arginfo.h" zend_class_entry* php_phongo_decimal128_interface_ce; -/* {{{ MongoDB\BSON\Decimal128Interface function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Decimal128Interface___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_decimal128_interface_me[] = { - ZEND_ABSTRACT_ME(Decimal128Interface, __toString, ai_Decimal128Interface___toString) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - void php_phongo_decimal128_interface_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Decimal128Interface", php_phongo_decimal128_interface_me); - php_phongo_decimal128_interface_ce = zend_register_internal_interface(&ce); + php_phongo_decimal128_interface_ce = register_class_MongoDB_BSON_Decimal128Interface(); } /* }}} */ diff --git a/src/BSON/Decimal128Interface.stub.php b/src/BSON/Decimal128Interface.stub.php new file mode 100644 index 000000000..22cd4ab33 --- /dev/null +++ b/src/BSON/Decimal128Interface.stub.php @@ -0,0 +1,15 @@ += 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Decimal128_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Decimal128_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +static ZEND_METHOD(MongoDB_BSON_Decimal128, __construct); +static ZEND_METHOD(MongoDB_BSON_Decimal128, __toString); +static ZEND_METHOD(MongoDB_BSON_Decimal128, __set_state); +static ZEND_METHOD(MongoDB_BSON_Decimal128, serialize); +static ZEND_METHOD(MongoDB_BSON_Decimal128, unserialize); +static ZEND_METHOD(MongoDB_BSON_Decimal128, __unserialize); +static ZEND_METHOD(MongoDB_BSON_Decimal128, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_Decimal128, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_Decimal128, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_Decimal128_methods[] = { + ZEND_ME(MongoDB_BSON_Decimal128, __construct, arginfo_class_MongoDB_BSON_Decimal128___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Decimal128, __toString, arginfo_class_MongoDB_BSON_Decimal128___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Decimal128, __set_state, arginfo_class_MongoDB_BSON_Decimal128___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(MongoDB_BSON_Decimal128, serialize, arginfo_class_MongoDB_BSON_Decimal128_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Decimal128, unserialize, arginfo_class_MongoDB_BSON_Decimal128_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Decimal128, __unserialize, arginfo_class_MongoDB_BSON_Decimal128___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Decimal128, __serialize, arginfo_class_MongoDB_BSON_Decimal128___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_Decimal128, jsonSerialize, arginfo_class_MongoDB_BSON_Decimal128_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_Decimal128, jsonSerialize, arginfo_class_MongoDB_BSON_Decimal128_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_Decimal128(zend_class_entry *class_entry_MongoDB_BSON_Decimal128Interface, zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Decimal128", class_MongoDB_BSON_Decimal128_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 4, class_entry_MongoDB_BSON_Decimal128Interface, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/Int64.c b/src/BSON/Int64.c index f570a3cec..cd527aa06 100644 --- a/src/BSON/Int64.c +++ b/src/BSON/Int64.c @@ -22,6 +22,7 @@ #include "php_phongo.h" #include "phongo_error.h" #include "phongo_util.h" +#include "Int64_arginfo.h" zend_class_entry* php_phongo_int64_ce; @@ -85,9 +86,11 @@ HashTable* php_phongo_int64_get_properties_hash(phongo_compat_object_handler_typ return props; } /* }}} */ +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_Int64) + /* {{{ proto string MongoDB\BSON\Int64::__toString() Return the Int64's value as a string. */ -static PHP_METHOD(Int64, __toString) +static PHP_METHOD(MongoDB_BSON_Int64, __toString) { php_phongo_int64_t* intern; @@ -100,7 +103,7 @@ static PHP_METHOD(Int64, __toString) /* {{{ proto array MongoDB\BSON\Int64::jsonSerialize() */ -static PHP_METHOD(Int64, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_Int64, jsonSerialize) { php_phongo_int64_t* intern; @@ -115,7 +118,7 @@ static PHP_METHOD(Int64, jsonSerialize) /* {{{ proto string MongoDB\BSON\Int64::serialize() */ -static PHP_METHOD(Int64, serialize) +static PHP_METHOD(MongoDB_BSON_Int64, serialize) { php_phongo_int64_t* intern; zval retval; @@ -142,7 +145,7 @@ static PHP_METHOD(Int64, serialize) /* {{{ proto void MongoDB\BSON\Int64::unserialize(string $serialized) */ -static PHP_METHOD(Int64, unserialize) +static PHP_METHOD(MongoDB_BSON_Int64, unserialize) { php_phongo_int64_t* intern; char* serialized; @@ -172,7 +175,7 @@ static PHP_METHOD(Int64, unserialize) /* {{{ proto array MongoDB\Driver\Int64::__serialize() */ -static PHP_METHOD(Int64, __serialize) +static PHP_METHOD(MongoDB_BSON_Int64, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -181,7 +184,7 @@ static PHP_METHOD(Int64, __serialize) /* {{{ proto void MongoDB\Driver\Int64::__unserialize(array $data) */ -static PHP_METHOD(Int64, __unserialize) +static PHP_METHOD(MongoDB_BSON_Int64, __unserialize) { zval* data; @@ -192,39 +195,6 @@ static PHP_METHOD(Int64, __unserialize) php_phongo_int64_init_from_hash(Z_INT64_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\BSON\Int64 function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_Int64___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Int64___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Int64_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Int64_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Int64_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_int64_me[] = { - /* __set_state intentionally missing */ - PHP_ME(Int64, __serialize, ai_Int64_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Int64, __toString, ai_Int64___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Int64, __unserialize, ai_Int64___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Int64, jsonSerialize, ai_Int64_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Int64, serialize, ai_Int64_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Int64, unserialize, ai_Int64_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_Int64_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\Int64 object handlers */ static zend_object_handlers php_phongo_handler_int64; @@ -299,16 +269,8 @@ static HashTable* php_phongo_int64_get_properties(phongo_compat_object_handler_t void php_phongo_int64_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Int64", php_phongo_int64_me); - php_phongo_int64_ce = zend_register_internal_class(&ce); + php_phongo_int64_ce = register_class_MongoDB_BSON_Int64(php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_int64_ce->create_object = php_phongo_int64_create_object; - PHONGO_CE_FINAL(php_phongo_int64_ce); - - zend_class_implements(php_phongo_int64_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_int64_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_int64_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_int64_ce, 1, zend_ce_stringable); diff --git a/src/BSON/Int64.stub.php b/src/BSON/Int64.stub.php new file mode 100644 index 000000000..487f9b7af --- /dev/null +++ b/src/BSON/Int64.stub.php @@ -0,0 +1,32 @@ += 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/Int64_arginfo.h b/src/BSON/Int64_arginfo.h new file mode 100644 index 000000000..c8d00fef3 --- /dev/null +++ b/src/BSON/Int64_arginfo.h @@ -0,0 +1,74 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: c6215d669e84919bca49dc8a770c29037cb390d5 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Int64___construct, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Int64___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_BSON_Int64_serialize arginfo_class_MongoDB_BSON_Int64___toString + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Int64_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Int64___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Int64___serialize, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Int64_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Int64_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +static ZEND_METHOD(MongoDB_BSON_Int64, __construct); +static ZEND_METHOD(MongoDB_BSON_Int64, __toString); +static ZEND_METHOD(MongoDB_BSON_Int64, serialize); +static ZEND_METHOD(MongoDB_BSON_Int64, unserialize); +static ZEND_METHOD(MongoDB_BSON_Int64, __unserialize); +static ZEND_METHOD(MongoDB_BSON_Int64, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_Int64, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_Int64, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_Int64_methods[] = { + ZEND_ME(MongoDB_BSON_Int64, __construct, arginfo_class_MongoDB_BSON_Int64___construct, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Int64, __toString, arginfo_class_MongoDB_BSON_Int64___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Int64, serialize, arginfo_class_MongoDB_BSON_Int64_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Int64, unserialize, arginfo_class_MongoDB_BSON_Int64_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Int64, __unserialize, arginfo_class_MongoDB_BSON_Int64___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Int64, __serialize, arginfo_class_MongoDB_BSON_Int64___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_Int64, jsonSerialize, arginfo_class_MongoDB_BSON_Int64_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_Int64, jsonSerialize, arginfo_class_MongoDB_BSON_Int64_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_Int64(zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Int64", class_MongoDB_BSON_Int64_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 3, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/Javascript.c b/src/BSON/Javascript.c index d157b1d85..ece5a5084 100644 --- a/src/BSON/Javascript.c +++ b/src/BSON/Javascript.c @@ -24,6 +24,7 @@ #include "php_phongo.h" #include "phongo_bson_encode.h" #include "phongo_error.h" +#include "Javascript_arginfo.h" zend_class_entry* php_phongo_javascript_ce; @@ -118,7 +119,7 @@ HashTable* php_phongo_javascript_get_properties_hash(phongo_compat_object_handle Construct a new BSON Javascript type. The scope is a document mapping identifiers and values, representing the scope in which the code string will be evaluated. Note that this type cannot be represented as Extended JSON. */ -static PHP_METHOD(Javascript, __construct) +static PHP_METHOD(MongoDB_BSON_Javascript, __construct) { php_phongo_javascript_t* intern; char* code; @@ -138,7 +139,7 @@ static PHP_METHOD(Javascript, __construct) /* {{{ proto MongoDB\BSON\Javascript MongoDB\BSON\Javascript::__set_state(array $properties) */ -static PHP_METHOD(Javascript, __set_state) +static PHP_METHOD(MongoDB_BSON_Javascript, __set_state) { php_phongo_javascript_t* intern; HashTable* props; @@ -158,7 +159,7 @@ static PHP_METHOD(Javascript, __set_state) /* {{{ proto string MongoDB\BSON\Javascript::__toString() Return the Javascript's code string. */ -static PHP_METHOD(Javascript, __toString) +static PHP_METHOD(MongoDB_BSON_Javascript, __toString) { php_phongo_javascript_t* intern; @@ -171,7 +172,7 @@ static PHP_METHOD(Javascript, __toString) /* {{{ proto string MongoDB\BSON\Javascript::getCode() */ -static PHP_METHOD(Javascript, getCode) +static PHP_METHOD(MongoDB_BSON_Javascript, getCode) { php_phongo_javascript_t* intern; @@ -184,7 +185,7 @@ static PHP_METHOD(Javascript, getCode) /* {{{ proto object|null MongoDB\BSON\Javascript::getScope() */ -static PHP_METHOD(Javascript, getScope) +static PHP_METHOD(MongoDB_BSON_Javascript, getScope) { php_phongo_javascript_t* intern; @@ -214,7 +215,7 @@ static PHP_METHOD(Javascript, getScope) /* {{{ proto array MongoDB\BSON\Javascript::jsonSerialize() */ -static PHP_METHOD(Javascript, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_Javascript, jsonSerialize) { php_phongo_javascript_t* intern; @@ -240,7 +241,7 @@ static PHP_METHOD(Javascript, jsonSerialize) /* {{{ proto string MongoDB\BSON\Javascript::serialize() */ -static PHP_METHOD(Javascript, serialize) +static PHP_METHOD(MongoDB_BSON_Javascript, serialize) { php_phongo_javascript_t* intern; zval retval; @@ -280,7 +281,7 @@ static PHP_METHOD(Javascript, serialize) /* {{{ proto void MongoDB\BSON\Javascript::unserialize(string $serialized) */ -static PHP_METHOD(Javascript, unserialize) +static PHP_METHOD(MongoDB_BSON_Javascript, unserialize) { php_phongo_javascript_t* intern; char* serialized; @@ -310,7 +311,7 @@ static PHP_METHOD(Javascript, unserialize) /* {{{ proto array MongoDB\Driver\Javascript::__serialize() */ -static PHP_METHOD(Javascript, __serialize) +static PHP_METHOD(MongoDB_BSON_Javascript, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -319,7 +320,7 @@ static PHP_METHOD(Javascript, __serialize) /* {{{ proto void MongoDB\Driver\Javascript::__unserialize(array $data) */ -static PHP_METHOD(Javascript, __unserialize) +static PHP_METHOD(MongoDB_BSON_Javascript, __unserialize) { zval* data; @@ -330,50 +331,6 @@ static PHP_METHOD(Javascript, __unserialize) php_phongo_javascript_init_from_hash(Z_JAVASCRIPT_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\BSON\Javascript function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_Javascript___construct, 0, 0, 1) - ZEND_ARG_INFO(0, javascript) - ZEND_ARG_INFO(0, scope) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Javascript___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_Javascript___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Javascript___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Javascript_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Javascript_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Javascript_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_javascript_me[] = { - PHP_ME(Javascript, __construct, ai_Javascript___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Javascript, __serialize, ai_Javascript_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Javascript, __set_state, ai_Javascript___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(Javascript, __toString, ai_Javascript___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Javascript, __unserialize, ai_Javascript___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Javascript, jsonSerialize, ai_Javascript_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Javascript, serialize, ai_Javascript_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Javascript, unserialize, ai_Javascript_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Javascript, getCode, ai_Javascript_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Javascript, getScope, ai_Javascript_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\Javascript object handlers */ static zend_object_handlers php_phongo_handler_javascript; @@ -454,17 +411,8 @@ static HashTable* php_phongo_javascript_get_properties(phongo_compat_object_hand void php_phongo_javascript_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Javascript", php_phongo_javascript_me); - php_phongo_javascript_ce = zend_register_internal_class(&ce); + php_phongo_javascript_ce = register_class_MongoDB_BSON_Javascript(php_phongo_javascript_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_javascript_ce->create_object = php_phongo_javascript_create_object; - PHONGO_CE_FINAL(php_phongo_javascript_ce); - - zend_class_implements(php_phongo_javascript_ce, 1, php_phongo_javascript_interface_ce); - zend_class_implements(php_phongo_javascript_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_javascript_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_javascript_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_javascript_ce, 1, zend_ce_stringable); diff --git a/src/BSON/Javascript.stub.php b/src/BSON/Javascript.stub.php new file mode 100644 index 000000000..decbfecfa --- /dev/null +++ b/src/BSON/Javascript.stub.php @@ -0,0 +1,43 @@ += 80000 + final public function __construct(string $code, array|object|null $scope = null) {} +#else + /** @param array|object|null $scope */ + final public function __construct(string $code, $scope = null) {} +#endif + + public static function __set_state(array $properties): Javascript {} + + final public function getCode(): string {} + + final public function getScope(): ?object {} + + final public function __toString(): string {} + + final public function serialize(): string {} + + /** @param string $serialized */ + final public function unserialize($serialized): void {} + + final public function __unserialize(array $data): void {} + + final public function __serialize(): array {} + +#if PHP_VERSION_ID >= 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/JavascriptInterface.c b/src/BSON/JavascriptInterface.c index a7f41476b..ddc597fc0 100644 --- a/src/BSON/JavascriptInterface.c +++ b/src/BSON/JavascriptInterface.c @@ -17,30 +17,11 @@ #include #include "php_phongo.h" +#include "JavascriptInterface_arginfo.h" zend_class_entry* php_phongo_javascript_interface_ce; -/* {{{ MongoDB\BSON\JavascriptInterface function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_JavascriptInterface___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_JavascriptInterface_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_javascript_interface_me[] = { - ZEND_ABSTRACT_ME(JavascriptInterface, getCode, ai_JavascriptInterface_void) - ZEND_ABSTRACT_ME(JavascriptInterface, getScope, ai_JavascriptInterface_void) - ZEND_ABSTRACT_ME(JavascriptInterface, __toString, ai_JavascriptInterface___toString) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - void php_phongo_javascript_interface_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "JavascriptInterface", php_phongo_javascript_interface_me); - php_phongo_javascript_interface_ce = zend_register_internal_interface(&ce); + php_phongo_javascript_interface_ce = register_class_MongoDB_BSON_JavascriptInterface(); } /* }}} */ diff --git a/src/BSON/JavascriptInterface.stub.php b/src/BSON/JavascriptInterface.stub.php new file mode 100644 index 000000000..d9b2452f6 --- /dev/null +++ b/src/BSON/JavascriptInterface.stub.php @@ -0,0 +1,21 @@ += 80000 +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Javascript___construct, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, code, IS_STRING, 0) + ZEND_ARG_TYPE_MASK(0, scope, MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_NULL, "null") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Javascript___construct, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, code, IS_STRING, 0) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, scope, "null") +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_BSON_Javascript___set_state, 0, 1, MongoDB\\BSON\\Javascript, 0) + ZEND_ARG_TYPE_INFO(0, properties, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Javascript_getCode, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Javascript_getScope, 0, 0, IS_OBJECT, 1) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_BSON_Javascript___toString arginfo_class_MongoDB_BSON_Javascript_getCode + +#define arginfo_class_MongoDB_BSON_Javascript_serialize arginfo_class_MongoDB_BSON_Javascript_getCode + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Javascript_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Javascript___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Javascript___serialize, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Javascript_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Javascript_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_Javascript, __construct); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_Javascript, __construct); +#endif +static ZEND_METHOD(MongoDB_BSON_Javascript, __set_state); +static ZEND_METHOD(MongoDB_BSON_Javascript, getCode); +static ZEND_METHOD(MongoDB_BSON_Javascript, getScope); +static ZEND_METHOD(MongoDB_BSON_Javascript, __toString); +static ZEND_METHOD(MongoDB_BSON_Javascript, serialize); +static ZEND_METHOD(MongoDB_BSON_Javascript, unserialize); +static ZEND_METHOD(MongoDB_BSON_Javascript, __unserialize); +static ZEND_METHOD(MongoDB_BSON_Javascript, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_Javascript, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_Javascript, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_Javascript_methods[] = { +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_Javascript, __construct, arginfo_class_MongoDB_BSON_Javascript___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_Javascript, __construct, arginfo_class_MongoDB_BSON_Javascript___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_BSON_Javascript, __set_state, arginfo_class_MongoDB_BSON_Javascript___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(MongoDB_BSON_Javascript, getCode, arginfo_class_MongoDB_BSON_Javascript_getCode, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Javascript, getScope, arginfo_class_MongoDB_BSON_Javascript_getScope, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Javascript, __toString, arginfo_class_MongoDB_BSON_Javascript___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Javascript, serialize, arginfo_class_MongoDB_BSON_Javascript_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Javascript, unserialize, arginfo_class_MongoDB_BSON_Javascript_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Javascript, __unserialize, arginfo_class_MongoDB_BSON_Javascript___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Javascript, __serialize, arginfo_class_MongoDB_BSON_Javascript___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_Javascript, jsonSerialize, arginfo_class_MongoDB_BSON_Javascript_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_Javascript, jsonSerialize, arginfo_class_MongoDB_BSON_Javascript_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_Javascript(zend_class_entry *class_entry_MongoDB_BSON_JavascriptInterface, zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Javascript", class_MongoDB_BSON_Javascript_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 4, class_entry_MongoDB_BSON_JavascriptInterface, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/MaxKey.c b/src/BSON/MaxKey.c index a1f4ed8b3..4cdab89e8 100644 --- a/src/BSON/MaxKey.c +++ b/src/BSON/MaxKey.c @@ -21,12 +21,13 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "MaxKey_arginfo.h" zend_class_entry* php_phongo_maxkey_ce; /* {{{ proto MongoDB\BSON\MaxKey MongoDB\BSON\MaxKey::__set_state(array $properties) */ -static PHP_METHOD(MaxKey, __set_state) +static PHP_METHOD(MongoDB_BSON_MaxKey, __set_state) { zval* array; @@ -39,7 +40,7 @@ static PHP_METHOD(MaxKey, __set_state) /* {{{ proto array MongoDB\BSON\MaxKey::jsonSerialize() */ -static PHP_METHOD(MaxKey, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_MaxKey, jsonSerialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -49,7 +50,7 @@ static PHP_METHOD(MaxKey, jsonSerialize) /* {{{ proto string MongoDB\BSON\MaxKey::serialize() */ -static PHP_METHOD(MaxKey, serialize) +static PHP_METHOD(MongoDB_BSON_MaxKey, serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -58,7 +59,7 @@ static PHP_METHOD(MaxKey, serialize) /* {{{ proto void MongoDB\BSON\MaxKey::unserialize(string $serialized) */ -static PHP_METHOD(MaxKey, unserialize) +static PHP_METHOD(MongoDB_BSON_MaxKey, unserialize) { char* serialized; size_t serialized_len; @@ -70,7 +71,7 @@ static PHP_METHOD(MaxKey, unserialize) /* {{{ proto array MongoDB\Driver\MaxKey::__serialize() */ -static PHP_METHOD(MaxKey, __serialize) +static PHP_METHOD(MongoDB_BSON_MaxKey, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -79,7 +80,7 @@ static PHP_METHOD(MaxKey, __serialize) /* {{{ proto void MongoDB\Driver\MaxKey::__unserialize(array $data) */ -static PHP_METHOD(MaxKey, __unserialize) +static PHP_METHOD(MongoDB_BSON_MaxKey, __unserialize) { zval* data; @@ -88,38 +89,6 @@ static PHP_METHOD(MaxKey, __unserialize) PHONGO_PARSE_PARAMETERS_END(); } /* }}} */ -/* {{{ MongoDB\BSON\MaxKey function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_MaxKey___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_MaxKey___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_MaxKey_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_MaxKey_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_MaxKey_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_maxkey_me[] = { - PHP_ME(MaxKey, __serialize, ai_MaxKey_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(MaxKey, __set_state, ai_MaxKey___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(MaxKey, __unserialize, ai_MaxKey___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(MaxKey, jsonSerialize, ai_MaxKey_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(MaxKey, serialize, ai_MaxKey_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(MaxKey, unserialize, ai_MaxKey_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\MaxKey object handlers */ static zend_object_handlers php_phongo_handler_maxkey; @@ -145,17 +114,8 @@ static zend_object* php_phongo_maxkey_create_object(zend_class_entry* class_type void php_phongo_maxkey_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MaxKey", php_phongo_maxkey_me); - php_phongo_maxkey_ce = zend_register_internal_class(&ce); + php_phongo_maxkey_ce = register_class_MongoDB_BSON_MaxKey(php_phongo_maxkey_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_maxkey_ce->create_object = php_phongo_maxkey_create_object; - PHONGO_CE_FINAL(php_phongo_maxkey_ce); - - zend_class_implements(php_phongo_maxkey_ce, 1, php_phongo_maxkey_interface_ce); - zend_class_implements(php_phongo_maxkey_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_maxkey_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_maxkey_ce, 1, zend_ce_serializable); memcpy(&php_phongo_handler_maxkey, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); /* Re-assign default handler previously removed in php_phongo.c */ diff --git a/src/BSON/MaxKey.stub.php b/src/BSON/MaxKey.stub.php new file mode 100644 index 000000000..ac17bfd51 --- /dev/null +++ b/src/BSON/MaxKey.stub.php @@ -0,0 +1,30 @@ += 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/MaxKeyInterface.c b/src/BSON/MaxKeyInterface.c index 99cbb564a..510f3116a 100644 --- a/src/BSON/MaxKeyInterface.c +++ b/src/BSON/MaxKeyInterface.c @@ -17,19 +17,11 @@ #include #include "php_phongo.h" +#include "MaxKeyInterface_arginfo.h" zend_class_entry* php_phongo_maxkey_interface_ce; -/* {{{ MongoDB\BSON\MaxKeyInterface function entries */ -static zend_function_entry php_phongo_maxkey_interface_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_maxkey_interface_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MaxKeyInterface", php_phongo_maxkey_interface_me); - php_phongo_maxkey_interface_ce = zend_register_internal_interface(&ce); + php_phongo_maxkey_interface_ce = register_class_MongoDB_BSON_MaxKeyInterface(); } /* }}} */ diff --git a/src/BSON/MaxKeyInterface.stub.php b/src/BSON/MaxKeyInterface.stub.php new file mode 100644 index 000000000..0323e637a --- /dev/null +++ b/src/BSON/MaxKeyInterface.stub.php @@ -0,0 +1,13 @@ += 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_MaxKey_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_MaxKey_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +static ZEND_METHOD(MongoDB_BSON_MaxKey, __set_state); +static ZEND_METHOD(MongoDB_BSON_MaxKey, serialize); +static ZEND_METHOD(MongoDB_BSON_MaxKey, unserialize); +static ZEND_METHOD(MongoDB_BSON_MaxKey, __unserialize); +static ZEND_METHOD(MongoDB_BSON_MaxKey, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_MaxKey, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_MaxKey, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_MaxKey_methods[] = { + ZEND_ME(MongoDB_BSON_MaxKey, __set_state, arginfo_class_MongoDB_BSON_MaxKey___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(MongoDB_BSON_MaxKey, serialize, arginfo_class_MongoDB_BSON_MaxKey_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_MaxKey, unserialize, arginfo_class_MongoDB_BSON_MaxKey_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_MaxKey, __unserialize, arginfo_class_MongoDB_BSON_MaxKey___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_MaxKey, __serialize, arginfo_class_MongoDB_BSON_MaxKey___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_MaxKey, jsonSerialize, arginfo_class_MongoDB_BSON_MaxKey_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_MaxKey, jsonSerialize, arginfo_class_MongoDB_BSON_MaxKey_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_MaxKey(zend_class_entry *class_entry_MongoDB_BSON_MaxKeyInterface, zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MaxKey", class_MongoDB_BSON_MaxKey_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 4, class_entry_MongoDB_BSON_MaxKeyInterface, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/MinKey.c b/src/BSON/MinKey.c index e5bdc8d75..4f60541e6 100644 --- a/src/BSON/MinKey.c +++ b/src/BSON/MinKey.c @@ -21,12 +21,13 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "MinKey_arginfo.h" zend_class_entry* php_phongo_minkey_ce; /* {{{ proto MongoDB\BSON\MinKey MongoDB\BSON\MinKey::__set_state(array $properties) */ -static PHP_METHOD(MinKey, __set_state) +static PHP_METHOD(MongoDB_BSON_MinKey, __set_state) { zval* array; @@ -39,7 +40,7 @@ static PHP_METHOD(MinKey, __set_state) /* {{{ proto array MongoDB\BSON\MinKey::jsonSerialize() */ -static PHP_METHOD(MinKey, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_MinKey, jsonSerialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -49,7 +50,7 @@ static PHP_METHOD(MinKey, jsonSerialize) /* {{{ proto string MongoDB\BSON\MinKey::serialize() */ -static PHP_METHOD(MinKey, serialize) +static PHP_METHOD(MongoDB_BSON_MinKey, serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -58,7 +59,7 @@ static PHP_METHOD(MinKey, serialize) /* {{{ proto void MongoDB\BSON\MinKey::unserialize(string $serialized) */ -static PHP_METHOD(MinKey, unserialize) +static PHP_METHOD(MongoDB_BSON_MinKey, unserialize) { char* serialized; size_t serialized_len; @@ -70,7 +71,7 @@ static PHP_METHOD(MinKey, unserialize) /* {{{ proto array MongoDB\Driver\MinKey::__serialize() */ -static PHP_METHOD(MinKey, __serialize) +static PHP_METHOD(MongoDB_BSON_MinKey, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -79,7 +80,7 @@ static PHP_METHOD(MinKey, __serialize) /* {{{ proto void MongoDB\Driver\MinKey::__unserialize(array $data) */ -static PHP_METHOD(MinKey, __unserialize) +static PHP_METHOD(MongoDB_BSON_MinKey, __unserialize) { zval* data; @@ -88,38 +89,6 @@ static PHP_METHOD(MinKey, __unserialize) PHONGO_PARSE_PARAMETERS_END(); } /* }}} */ -/* {{{ MongoDB\BSON\MinKey function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_MinKey___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_MinKey___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_MinKey_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_MinKey_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_MinKey_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_minkey_me[] = { - PHP_ME(MinKey, __serialize, ai_MinKey_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(MinKey, __set_state, ai_MinKey___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(MinKey, __unserialize, ai_MinKey___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(MinKey, jsonSerialize, ai_MinKey_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(MinKey, serialize, ai_MinKey_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(MinKey, unserialize, ai_MinKey_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\MinKey object handlers */ static zend_object_handlers php_phongo_handler_minkey; @@ -145,17 +114,8 @@ static zend_object* php_phongo_minkey_create_object(zend_class_entry* class_type void php_phongo_minkey_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MinKey", php_phongo_minkey_me); - php_phongo_minkey_ce = zend_register_internal_class(&ce); + php_phongo_minkey_ce = register_class_MongoDB_BSON_MinKey(php_phongo_minkey_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_minkey_ce->create_object = php_phongo_minkey_create_object; - PHONGO_CE_FINAL(php_phongo_minkey_ce); - - zend_class_implements(php_phongo_minkey_ce, 1, php_phongo_minkey_interface_ce); - zend_class_implements(php_phongo_minkey_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_minkey_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_minkey_ce, 1, zend_ce_serializable); memcpy(&php_phongo_handler_minkey, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); /* Re-assign default handler previously removed in php_phongo.c */ diff --git a/src/BSON/MinKey.stub.php b/src/BSON/MinKey.stub.php new file mode 100644 index 000000000..514f640a5 --- /dev/null +++ b/src/BSON/MinKey.stub.php @@ -0,0 +1,30 @@ += 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/MinKeyInterface.c b/src/BSON/MinKeyInterface.c index 44025a9fb..a70900878 100644 --- a/src/BSON/MinKeyInterface.c +++ b/src/BSON/MinKeyInterface.c @@ -17,19 +17,11 @@ #include #include "php_phongo.h" +#include "MinKeyInterface_arginfo.h" zend_class_entry* php_phongo_minkey_interface_ce; -/* {{{ MongoDB\BSON\MinKeyInterface function entries */ -static zend_function_entry php_phongo_minkey_interface_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_minkey_interface_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MinKeyInterface", php_phongo_minkey_interface_me); - php_phongo_minkey_interface_ce = zend_register_internal_interface(&ce); + php_phongo_minkey_interface_ce = register_class_MongoDB_BSON_MinKeyInterface(); } /* }}} */ diff --git a/src/BSON/MinKeyInterface.stub.php b/src/BSON/MinKeyInterface.stub.php new file mode 100644 index 000000000..e7bd42db2 --- /dev/null +++ b/src/BSON/MinKeyInterface.stub.php @@ -0,0 +1,13 @@ += 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_MinKey_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_MinKey_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +static ZEND_METHOD(MongoDB_BSON_MinKey, __set_state); +static ZEND_METHOD(MongoDB_BSON_MinKey, serialize); +static ZEND_METHOD(MongoDB_BSON_MinKey, unserialize); +static ZEND_METHOD(MongoDB_BSON_MinKey, __unserialize); +static ZEND_METHOD(MongoDB_BSON_MinKey, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_MinKey, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_MinKey, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_MinKey_methods[] = { + ZEND_ME(MongoDB_BSON_MinKey, __set_state, arginfo_class_MongoDB_BSON_MinKey___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(MongoDB_BSON_MinKey, serialize, arginfo_class_MongoDB_BSON_MinKey_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_MinKey, unserialize, arginfo_class_MongoDB_BSON_MinKey_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_MinKey, __unserialize, arginfo_class_MongoDB_BSON_MinKey___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_MinKey, __serialize, arginfo_class_MongoDB_BSON_MinKey___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_MinKey, jsonSerialize, arginfo_class_MongoDB_BSON_MinKey_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_MinKey, jsonSerialize, arginfo_class_MongoDB_BSON_MinKey_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_MinKey(zend_class_entry *class_entry_MongoDB_BSON_MinKeyInterface, zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MinKey", class_MongoDB_BSON_MinKey_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 4, class_entry_MongoDB_BSON_MinKeyInterface, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/ObjectId.c b/src/BSON/ObjectId.c index 388c4a16a..ed6d00696 100644 --- a/src/BSON/ObjectId.c +++ b/src/BSON/ObjectId.c @@ -23,6 +23,7 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "ObjectId_arginfo.h" #define PHONGO_OID_SIZE sizeof(((php_phongo_objectid_t*) 0)->oid) #define PHONGO_OID_LEN (PHONGO_OID_SIZE - 1) @@ -103,7 +104,7 @@ static HashTable* php_phongo_objectid_get_properties_hash(phongo_compat_object_h /* {{{ proto void MongoDB\BSON\ObjectId::__construct([string $id]) Constructs a new BSON ObjectId type, optionally from a hex string. */ -static PHP_METHOD(ObjectId, __construct) +static PHP_METHOD(MongoDB_BSON_ObjectId, __construct) { php_phongo_objectid_t* intern; char* id = NULL; @@ -125,7 +126,7 @@ static PHP_METHOD(ObjectId, __construct) /* {{{ proto integer MongoDB\BSON\ObjectId::getTimestamp() */ -static PHP_METHOD(ObjectId, getTimestamp) +static PHP_METHOD(MongoDB_BSON_ObjectId, getTimestamp) { php_phongo_objectid_t* intern; bson_oid_t tmp_oid; @@ -140,7 +141,7 @@ static PHP_METHOD(ObjectId, getTimestamp) /* {{{ proto MongoDB\BSON\ObjectId MongoDB\BSON\ObjectId::__set_state(array $properties) */ -static PHP_METHOD(ObjectId, __set_state) +static PHP_METHOD(MongoDB_BSON_ObjectId, __set_state) { php_phongo_objectid_t* intern; HashTable* props; @@ -160,7 +161,7 @@ static PHP_METHOD(ObjectId, __set_state) /* {{{ proto string MongoDB\BSON\ObjectId::__toString() */ -static PHP_METHOD(ObjectId, __toString) +static PHP_METHOD(MongoDB_BSON_ObjectId, __toString) { php_phongo_objectid_t* intern; @@ -173,7 +174,7 @@ static PHP_METHOD(ObjectId, __toString) /* {{{ proto array MongoDB\BSON\ObjectId::jsonSerialize() */ -static PHP_METHOD(ObjectId, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_ObjectId, jsonSerialize) { php_phongo_objectid_t* intern; @@ -187,7 +188,7 @@ static PHP_METHOD(ObjectId, jsonSerialize) /* {{{ proto string MongoDB\BSON\ObjectId::serialize() */ -static PHP_METHOD(ObjectId, serialize) +static PHP_METHOD(MongoDB_BSON_ObjectId, serialize) { php_phongo_objectid_t* intern; zval retval; @@ -214,7 +215,7 @@ static PHP_METHOD(ObjectId, serialize) /* {{{ proto void MongoDB\BSON\ObjectId::unserialize(string $serialized) */ -static PHP_METHOD(ObjectId, unserialize) +static PHP_METHOD(MongoDB_BSON_ObjectId, unserialize) { php_phongo_objectid_t* intern; char* serialized; @@ -244,7 +245,7 @@ static PHP_METHOD(ObjectId, unserialize) /* {{{ proto array MongoDB\Driver\ObjectId::__serialize() */ -static PHP_METHOD(ObjectId, __serialize) +static PHP_METHOD(MongoDB_BSON_ObjectId, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -253,7 +254,7 @@ static PHP_METHOD(ObjectId, __serialize) /* {{{ proto void MongoDB\Driver\ObjectId::__unserialize(array $data) */ -static PHP_METHOD(ObjectId, __unserialize) +static PHP_METHOD(MongoDB_BSON_ObjectId, __unserialize) { zval* data; @@ -264,48 +265,6 @@ static PHP_METHOD(ObjectId, __unserialize) php_phongo_objectid_init_from_hash(Z_OBJECTID_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\BSON\ObjectId function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_ObjectId___construct, 0, 0, 0) - ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ObjectId___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_ObjectId___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ObjectId___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_ObjectId_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ObjectId_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ObjectId_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_objectid_me[] = { - PHP_ME(ObjectId, __construct, ai_ObjectId___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ObjectId, getTimestamp, ai_ObjectId_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ObjectId, __serialize, ai_ObjectId_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ObjectId, __set_state, ai_ObjectId___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(ObjectId, __toString, ai_ObjectId___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ObjectId, __unserialize, ai_ObjectId___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ObjectId, jsonSerialize, ai_ObjectId_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ObjectId, serialize, ai_ObjectId_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ObjectId, unserialize, ai_ObjectId_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\ObjectId object handlers */ static zend_object_handlers php_phongo_handler_objectid; @@ -379,17 +338,8 @@ static HashTable* php_phongo_objectid_get_properties(phongo_compat_object_handle void php_phongo_objectid_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "ObjectId", php_phongo_objectid_me); - php_phongo_objectid_ce = zend_register_internal_class(&ce); + php_phongo_objectid_ce = register_class_MongoDB_BSON_ObjectId(php_phongo_objectid_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_objectid_ce->create_object = php_phongo_objectid_create_object; - PHONGO_CE_FINAL(php_phongo_objectid_ce); - - zend_class_implements(php_phongo_objectid_ce, 1, php_phongo_objectid_interface_ce); - zend_class_implements(php_phongo_objectid_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_objectid_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_objectid_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_objectid_ce, 1, zend_ce_stringable); diff --git a/src/BSON/ObjectId.stub.php b/src/BSON/ObjectId.stub.php new file mode 100644 index 000000000..ededaa840 --- /dev/null +++ b/src/BSON/ObjectId.stub.php @@ -0,0 +1,36 @@ += 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/ObjectIdInterface.c b/src/BSON/ObjectIdInterface.c index a572b5b9b..b25c7826e 100644 --- a/src/BSON/ObjectIdInterface.c +++ b/src/BSON/ObjectIdInterface.c @@ -17,29 +17,11 @@ #include #include "php_phongo.h" +#include "ObjectIdInterface_arginfo.h" zend_class_entry* php_phongo_objectid_interface_ce; -/* {{{ MongoDB\BSON\ObjectIdInterface function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_ObjectIdInterface___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ObjectIdInterface_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_objectid_interface_me[] = { - ZEND_ABSTRACT_ME(ObjectIdInterface, getTimestamp, ai_ObjectIdInterface_void) - ZEND_ABSTRACT_ME(ObjectIdInterface, __toString, ai_ObjectIdInterface___toString) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - void php_phongo_objectid_interface_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "ObjectIdInterface", php_phongo_objectid_interface_me); - php_phongo_objectid_interface_ce = zend_register_internal_interface(&ce); + php_phongo_objectid_interface_ce = register_class_MongoDB_BSON_ObjectIdInterface(); } /* }}} */ diff --git a/src/BSON/ObjectIdInterface.stub.php b/src/BSON/ObjectIdInterface.stub.php new file mode 100644 index 000000000..bad461513 --- /dev/null +++ b/src/BSON/ObjectIdInterface.stub.php @@ -0,0 +1,18 @@ += 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_ObjectId_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_ObjectId_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +static ZEND_METHOD(MongoDB_BSON_ObjectId, __construct); +static ZEND_METHOD(MongoDB_BSON_ObjectId, getTimestamp); +static ZEND_METHOD(MongoDB_BSON_ObjectId, __toString); +static ZEND_METHOD(MongoDB_BSON_ObjectId, __set_state); +static ZEND_METHOD(MongoDB_BSON_ObjectId, serialize); +static ZEND_METHOD(MongoDB_BSON_ObjectId, unserialize); +static ZEND_METHOD(MongoDB_BSON_ObjectId, __unserialize); +static ZEND_METHOD(MongoDB_BSON_ObjectId, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_ObjectId, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_ObjectId, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_ObjectId_methods[] = { + ZEND_ME(MongoDB_BSON_ObjectId, __construct, arginfo_class_MongoDB_BSON_ObjectId___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_ObjectId, getTimestamp, arginfo_class_MongoDB_BSON_ObjectId_getTimestamp, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_ObjectId, __toString, arginfo_class_MongoDB_BSON_ObjectId___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_ObjectId, __set_state, arginfo_class_MongoDB_BSON_ObjectId___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(MongoDB_BSON_ObjectId, serialize, arginfo_class_MongoDB_BSON_ObjectId_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_ObjectId, unserialize, arginfo_class_MongoDB_BSON_ObjectId_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_ObjectId, __unserialize, arginfo_class_MongoDB_BSON_ObjectId___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_ObjectId, __serialize, arginfo_class_MongoDB_BSON_ObjectId___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_ObjectId, jsonSerialize, arginfo_class_MongoDB_BSON_ObjectId_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_ObjectId, jsonSerialize, arginfo_class_MongoDB_BSON_ObjectId_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_ObjectId(zend_class_entry *class_entry_MongoDB_BSON_ObjectIdInterface, zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "ObjectId", class_MongoDB_BSON_ObjectId_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 4, class_entry_MongoDB_BSON_ObjectIdInterface, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/Persistable.c b/src/BSON/Persistable.c index 29949f4ab..d933c31e6 100644 --- a/src/BSON/Persistable.c +++ b/src/BSON/Persistable.c @@ -17,20 +17,11 @@ #include #include "php_phongo.h" +#include "Persistable_arginfo.h" zend_class_entry* php_phongo_persistable_ce; -/* {{{ MongoDB\BSON\Persistable function entries */ -static zend_function_entry php_phongo_persistable_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_persistable_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Persistable", php_phongo_persistable_me); - php_phongo_persistable_ce = zend_register_internal_interface(&ce); - zend_class_implements(php_phongo_persistable_ce, 2, php_phongo_unserializable_ce, php_phongo_serializable_ce); + php_phongo_persistable_ce = register_class_MongoDB_BSON_Persistable(php_phongo_serializable_ce, php_phongo_unserializable_ce); } /* }}} */ diff --git a/src/BSON/Persistable.stub.php b/src/BSON/Persistable.stub.php new file mode 100644 index 000000000..afe31436a --- /dev/null +++ b/src/BSON/Persistable.stub.php @@ -0,0 +1,13 @@ +create_object = php_phongo_regex_create_object; - PHONGO_CE_FINAL(php_phongo_regex_ce); - - zend_class_implements(php_phongo_regex_ce, 1, php_phongo_regex_interface_ce); - zend_class_implements(php_phongo_regex_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_regex_ce, 1, zend_ce_serializable); - zend_class_implements(php_phongo_regex_ce, 1, php_phongo_json_serializable_ce); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_regex_ce, 1, zend_ce_stringable); diff --git a/src/BSON/Regex.stub.php b/src/BSON/Regex.stub.php new file mode 100644 index 000000000..f37dbf64c --- /dev/null +++ b/src/BSON/Regex.stub.php @@ -0,0 +1,38 @@ += 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/RegexInterface.c b/src/BSON/RegexInterface.c index c8c0e2673..25cff7e33 100644 --- a/src/BSON/RegexInterface.c +++ b/src/BSON/RegexInterface.c @@ -17,30 +17,11 @@ #include #include "php_phongo.h" +#include "RegexInterface_arginfo.h" zend_class_entry* php_phongo_regex_interface_ce; -/* {{{ MongoDB\BSON\RegexInterface function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_RegexInterface___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_RegexInterface_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_regex_interface_me[] = { - ZEND_ABSTRACT_ME(RegexInterface, getFlags, ai_RegexInterface_void) - ZEND_ABSTRACT_ME(RegexInterface, getPattern, ai_RegexInterface_void) - ZEND_ABSTRACT_ME(RegexInterface, __toString, ai_RegexInterface___toString) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - void php_phongo_regex_interface_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "RegexInterface", php_phongo_regex_interface_me); - php_phongo_regex_interface_ce = zend_register_internal_interface(&ce); + php_phongo_regex_interface_ce = register_class_MongoDB_BSON_RegexInterface(); } /* }}} */ diff --git a/src/BSON/RegexInterface.stub.php b/src/BSON/RegexInterface.stub.php new file mode 100644 index 000000000..7c29110c6 --- /dev/null +++ b/src/BSON/RegexInterface.stub.php @@ -0,0 +1,21 @@ += 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Regex_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Regex_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +static ZEND_METHOD(MongoDB_BSON_Regex, __construct); +static ZEND_METHOD(MongoDB_BSON_Regex, getPattern); +static ZEND_METHOD(MongoDB_BSON_Regex, getFlags); +static ZEND_METHOD(MongoDB_BSON_Regex, __toString); +static ZEND_METHOD(MongoDB_BSON_Regex, __set_state); +static ZEND_METHOD(MongoDB_BSON_Regex, serialize); +static ZEND_METHOD(MongoDB_BSON_Regex, unserialize); +static ZEND_METHOD(MongoDB_BSON_Regex, __unserialize); +static ZEND_METHOD(MongoDB_BSON_Regex, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_Regex, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_Regex, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_Regex_methods[] = { + ZEND_ME(MongoDB_BSON_Regex, __construct, arginfo_class_MongoDB_BSON_Regex___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Regex, getPattern, arginfo_class_MongoDB_BSON_Regex_getPattern, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Regex, getFlags, arginfo_class_MongoDB_BSON_Regex_getFlags, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Regex, __toString, arginfo_class_MongoDB_BSON_Regex___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Regex, __set_state, arginfo_class_MongoDB_BSON_Regex___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(MongoDB_BSON_Regex, serialize, arginfo_class_MongoDB_BSON_Regex_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Regex, unserialize, arginfo_class_MongoDB_BSON_Regex_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Regex, __unserialize, arginfo_class_MongoDB_BSON_Regex___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Regex, __serialize, arginfo_class_MongoDB_BSON_Regex___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_Regex, jsonSerialize, arginfo_class_MongoDB_BSON_Regex_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_Regex, jsonSerialize, arginfo_class_MongoDB_BSON_Regex_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_Regex(zend_class_entry *class_entry_MongoDB_BSON_RegexInterface, zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Regex", class_MongoDB_BSON_Regex_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 4, class_entry_MongoDB_BSON_RegexInterface, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/Serializable.c b/src/BSON/Serializable.c index 5563b29eb..6072a729d 100644 --- a/src/BSON/Serializable.c +++ b/src/BSON/Serializable.c @@ -17,26 +17,11 @@ #include #include "php_phongo.h" +#include "Serializable_arginfo.h" zend_class_entry* php_phongo_serializable_ce; -/* {{{ MongoDB\BSON\Serializable function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_Serializable_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_serializable_me[] = { - /* clang-format off */ - ZEND_ABSTRACT_ME(Serializable, bsonSerialize, ai_Serializable_void) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - void php_phongo_serializable_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Serializable", php_phongo_serializable_me); - php_phongo_serializable_ce = zend_register_internal_interface(&ce); - zend_class_implements(php_phongo_serializable_ce, 1, php_phongo_type_ce); + php_phongo_serializable_ce = register_class_MongoDB_BSON_Serializable(php_phongo_type_ce); } /* }}} */ diff --git a/src/BSON/Serializable.stub.php b/src/BSON/Serializable.stub.php new file mode 100644 index 000000000..eafdd0b22 --- /dev/null +++ b/src/BSON/Serializable.stub.php @@ -0,0 +1,20 @@ += 80000 + /** @tentative-return-type */ + public function bsonSerialize(): array|object; +#else + /** @return array|object */ + public function bsonSerialize(); +#endif + } +} diff --git a/src/BSON/Serializable_arginfo.h b/src/BSON/Serializable_arginfo.h new file mode 100644 index 000000000..b96cb4201 --- /dev/null +++ b/src/BSON/Serializable_arginfo.h @@ -0,0 +1,40 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 22bef071736dda02427583bb0f259a8a3f2ccffe */ + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_BSON_Serializable_bsonSerialize, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Serializable_bsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +#if PHP_VERSION_ID >= 80000 +#endif +#if !(PHP_VERSION_ID >= 80000) +#endif + + +static const zend_function_entry class_MongoDB_BSON_Serializable_methods[] = { +#if PHP_VERSION_ID >= 80000 + ZEND_ABSTRACT_ME_WITH_FLAGS(MongoDB_BSON_Serializable, bsonSerialize, arginfo_class_MongoDB_BSON_Serializable_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ABSTRACT_ME_WITH_FLAGS(MongoDB_BSON_Serializable, bsonSerialize, arginfo_class_MongoDB_BSON_Serializable_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_Serializable(zend_class_entry *class_entry_MongoDB_BSON_Type) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Serializable", class_MongoDB_BSON_Serializable_methods); + class_entry = zend_register_internal_interface(&ce); + zend_class_implements(class_entry, 1, class_entry_MongoDB_BSON_Type); + + return class_entry; +} diff --git a/src/BSON/Symbol.c b/src/BSON/Symbol.c index 20f36f4c6..8d44efa98 100644 --- a/src/BSON/Symbol.c +++ b/src/BSON/Symbol.c @@ -21,6 +21,7 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "Symbol_arginfo.h" zend_class_entry* php_phongo_symbol_ce; @@ -76,9 +77,11 @@ HashTable* php_phongo_symbol_get_properties_hash(phongo_compat_object_handler_ty return props; } /* }}} */ +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_Symbol) + /* {{{ proto string MongoDB\BSON\Symbol::__toString() Return the Symbol's symbol string. */ -static PHP_METHOD(Symbol, __toString) +static PHP_METHOD(MongoDB_BSON_Symbol, __toString) { php_phongo_symbol_t* intern; @@ -91,7 +94,7 @@ static PHP_METHOD(Symbol, __toString) /* {{{ proto array MongoDB\BSON\Symbol::jsonSerialize() */ -static PHP_METHOD(Symbol, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_Symbol, jsonSerialize) { php_phongo_symbol_t* intern; @@ -105,7 +108,7 @@ static PHP_METHOD(Symbol, jsonSerialize) /* {{{ proto string MongoDB\BSON\Symbol::serialize() */ -static PHP_METHOD(Symbol, serialize) +static PHP_METHOD(MongoDB_BSON_Symbol, serialize) { php_phongo_symbol_t* intern; zval retval; @@ -132,7 +135,7 @@ static PHP_METHOD(Symbol, serialize) /* {{{ proto void MongoDB\BSON\Symbol::unserialize(string $serialized) */ -static PHP_METHOD(Symbol, unserialize) +static PHP_METHOD(MongoDB_BSON_Symbol, unserialize) { php_phongo_symbol_t* intern; char* serialized; @@ -162,7 +165,7 @@ static PHP_METHOD(Symbol, unserialize) /* {{{ proto array MongoDB\Driver\Symbol::__serialize() */ -static PHP_METHOD(Symbol, __serialize) +static PHP_METHOD(MongoDB_BSON_Symbol, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -171,7 +174,7 @@ static PHP_METHOD(Symbol, __serialize) /* {{{ proto void MongoDB\Driver\Symbol::__unserialize(array $data) */ -static PHP_METHOD(Symbol, __unserialize) +static PHP_METHOD(MongoDB_BSON_Symbol, __unserialize) { zval* data; @@ -182,39 +185,6 @@ static PHP_METHOD(Symbol, __unserialize) php_phongo_symbol_init_from_hash(Z_SYMBOL_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\BSON\Symbol function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_Symbol___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Symbol___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Symbol_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Symbol_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Symbol_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_symbol_me[] = { - /* __set_state intentionally missing */ - PHP_ME(Symbol, __serialize, ai_Symbol_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Symbol, __toString, ai_Symbol___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Symbol, __unserialize, ai_Symbol___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Symbol, jsonSerialize, ai_Symbol_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Symbol, serialize, ai_Symbol_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Symbol, unserialize, ai_Symbol_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_Symbol_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\Symbol object handlers */ static zend_object_handlers php_phongo_handler_symbol; @@ -289,16 +259,8 @@ static HashTable* php_phongo_symbol_get_properties(phongo_compat_object_handler_ void php_phongo_symbol_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Symbol", php_phongo_symbol_me); - php_phongo_symbol_ce = zend_register_internal_class(&ce); + php_phongo_symbol_ce = register_class_MongoDB_BSON_Symbol(php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_symbol_ce->create_object = php_phongo_symbol_create_object; - PHONGO_CE_FINAL(php_phongo_symbol_ce); - - zend_class_implements(php_phongo_symbol_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_symbol_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_symbol_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_symbol_ce, 1, zend_ce_stringable); diff --git a/src/BSON/Symbol.stub.php b/src/BSON/Symbol.stub.php new file mode 100644 index 000000000..278aa5b23 --- /dev/null +++ b/src/BSON/Symbol.stub.php @@ -0,0 +1,32 @@ += 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/Symbol_arginfo.h b/src/BSON/Symbol_arginfo.h new file mode 100644 index 000000000..eaac6d630 --- /dev/null +++ b/src/BSON/Symbol_arginfo.h @@ -0,0 +1,74 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 2e833687b33ec7a6e25da5be58d2a483b63bac18 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Symbol___construct, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Symbol___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_BSON_Symbol_serialize arginfo_class_MongoDB_BSON_Symbol___toString + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Symbol_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Symbol___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Symbol___serialize, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Symbol_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Symbol_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +static ZEND_METHOD(MongoDB_BSON_Symbol, __construct); +static ZEND_METHOD(MongoDB_BSON_Symbol, __toString); +static ZEND_METHOD(MongoDB_BSON_Symbol, serialize); +static ZEND_METHOD(MongoDB_BSON_Symbol, unserialize); +static ZEND_METHOD(MongoDB_BSON_Symbol, __unserialize); +static ZEND_METHOD(MongoDB_BSON_Symbol, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_Symbol, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_Symbol, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_Symbol_methods[] = { + ZEND_ME(MongoDB_BSON_Symbol, __construct, arginfo_class_MongoDB_BSON_Symbol___construct, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Symbol, __toString, arginfo_class_MongoDB_BSON_Symbol___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Symbol, serialize, arginfo_class_MongoDB_BSON_Symbol_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Symbol, unserialize, arginfo_class_MongoDB_BSON_Symbol_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Symbol, __unserialize, arginfo_class_MongoDB_BSON_Symbol___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Symbol, __serialize, arginfo_class_MongoDB_BSON_Symbol___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_Symbol, jsonSerialize, arginfo_class_MongoDB_BSON_Symbol_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_Symbol, jsonSerialize, arginfo_class_MongoDB_BSON_Symbol_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_Symbol(zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Symbol", class_MongoDB_BSON_Symbol_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 3, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/Timestamp.c b/src/BSON/Timestamp.c index c4b77863c..fd58d4c72 100644 --- a/src/BSON/Timestamp.c +++ b/src/BSON/Timestamp.c @@ -22,6 +22,7 @@ #include "php_phongo.h" #include "phongo_error.h" #include "phongo_util.h" +#include "Timestamp_arginfo.h" zend_class_entry* php_phongo_timestamp_ce; @@ -122,7 +123,7 @@ static HashTable* php_phongo_timestamp_get_properties_hash(phongo_compat_object_ /* {{{ proto void MongoDB\BSON\Timestamp::__construct(int|string $increment, int|string $timestamp) Construct a new BSON timestamp type, which consists of a 4-byte increment and 4-byte timestamp. */ -static PHP_METHOD(Timestamp, __construct) +static PHP_METHOD(MongoDB_BSON_Timestamp, __construct) { php_phongo_timestamp_t* intern; zval * increment = NULL, *timestamp = NULL; @@ -162,7 +163,7 @@ static PHP_METHOD(Timestamp, __construct) /* {{{ proto integer MongoDB\BSON\Timestamp::getIncrement() */ -static PHP_METHOD(Timestamp, getIncrement) +static PHP_METHOD(MongoDB_BSON_Timestamp, getIncrement) { php_phongo_timestamp_t* intern; @@ -175,7 +176,7 @@ static PHP_METHOD(Timestamp, getIncrement) /* {{{ proto integer MongoDB\BSON\Timestamp::getTimestamp() */ -static PHP_METHOD(Timestamp, getTimestamp) +static PHP_METHOD(MongoDB_BSON_Timestamp, getTimestamp) { php_phongo_timestamp_t* intern; @@ -188,7 +189,7 @@ static PHP_METHOD(Timestamp, getTimestamp) /* {{{ proto MongoDB\BSON\Timestamp MongoDB\BSON\Timestamp::__set_state(array $properties) */ -static PHP_METHOD(Timestamp, __set_state) +static PHP_METHOD(MongoDB_BSON_Timestamp, __set_state) { php_phongo_timestamp_t* intern; HashTable* props; @@ -208,7 +209,7 @@ static PHP_METHOD(Timestamp, __set_state) /* {{{ proto string MongoDB\BSON\Timestamp::__toString() Returns a string in the form: [increment:timestamp] */ -static PHP_METHOD(Timestamp, __toString) +static PHP_METHOD(MongoDB_BSON_Timestamp, __toString) { php_phongo_timestamp_t* intern; char* retval; @@ -225,7 +226,7 @@ static PHP_METHOD(Timestamp, __toString) /* {{{ proto array MongoDB\BSON\Timestamp::jsonSerialize() */ -static PHP_METHOD(Timestamp, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_Timestamp, jsonSerialize) { php_phongo_timestamp_t* intern; @@ -247,7 +248,7 @@ static PHP_METHOD(Timestamp, jsonSerialize) /* {{{ proto string MongoDB\BSON\Timestamp::serialize() */ -static PHP_METHOD(Timestamp, serialize) +static PHP_METHOD(MongoDB_BSON_Timestamp, serialize) { php_phongo_timestamp_t* intern; zval retval; @@ -282,7 +283,7 @@ static PHP_METHOD(Timestamp, serialize) /* {{{ proto void MongoDB\BSON\Timestamp::unserialize(string $serialized) */ -static PHP_METHOD(Timestamp, unserialize) +static PHP_METHOD(MongoDB_BSON_Timestamp, unserialize) { php_phongo_timestamp_t* intern; char* serialized; @@ -312,7 +313,7 @@ static PHP_METHOD(Timestamp, unserialize) /* {{{ proto array MongoDB\Driver\Timestamp::__serialize() */ -static PHP_METHOD(Timestamp, __serialize) +static PHP_METHOD(MongoDB_BSON_Timestamp, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -321,7 +322,7 @@ static PHP_METHOD(Timestamp, __serialize) /* {{{ proto void MongoDB\Driver\Timestamp::__unserialize(array $data) */ -static PHP_METHOD(Timestamp, __unserialize) +static PHP_METHOD(MongoDB_BSON_Timestamp, __unserialize) { zval* data; @@ -332,50 +333,6 @@ static PHP_METHOD(Timestamp, __unserialize) php_phongo_timestamp_init_from_hash(Z_TIMESTAMP_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\BSON\Timestamp function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp___construct, 0, 0, 2) - ZEND_ARG_INFO(0, increment) - ZEND_ARG_INFO(0, timestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_Timestamp___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Timestamp_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_timestamp_me[] = { - PHP_ME(Timestamp, __construct, ai_Timestamp___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Timestamp, __serialize, ai_Timestamp_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Timestamp, __set_state, ai_Timestamp___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(Timestamp, __toString, ai_Timestamp___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Timestamp, __unserialize, ai_Timestamp___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Timestamp, jsonSerialize, ai_Timestamp_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Timestamp, serialize, ai_Timestamp_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Timestamp, unserialize, ai_Timestamp_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Timestamp, getIncrement, ai_Timestamp_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Timestamp, getTimestamp, ai_Timestamp_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\Timestamp object handlers */ static zend_object_handlers php_phongo_handler_timestamp; @@ -455,17 +412,8 @@ static HashTable* php_phongo_timestamp_get_properties(phongo_compat_object_handl void php_phongo_timestamp_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Timestamp", php_phongo_timestamp_me); - php_phongo_timestamp_ce = zend_register_internal_class(&ce); + php_phongo_timestamp_ce = register_class_MongoDB_BSON_Timestamp(php_phongo_timestamp_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_timestamp_ce->create_object = php_phongo_timestamp_create_object; - PHONGO_CE_FINAL(php_phongo_timestamp_ce); - - zend_class_implements(php_phongo_timestamp_ce, 1, php_phongo_timestamp_interface_ce); - zend_class_implements(php_phongo_timestamp_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_timestamp_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_timestamp_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_timestamp_ce, 1, zend_ce_stringable); diff --git a/src/BSON/Timestamp.stub.php b/src/BSON/Timestamp.stub.php new file mode 100644 index 000000000..2b99a13d4 --- /dev/null +++ b/src/BSON/Timestamp.stub.php @@ -0,0 +1,46 @@ += 80000 + public final function __construct(int|string $increment, int|string $timestamp) {} +#else + /** + * @param int|string $increment + * @param int|string $timestamp + */ + public final function __construct($increment, $timestamp) {} +#endif + + public final function getTimestamp(): int {} + + public final function getIncrement(): int {} + + public final function __toString(): string {} + + public static function __set_state(array $properties): Timestamp {} + + final public function serialize(): string {} + + /** @param string $serialized */ + final public function unserialize($serialized): void {} + + final public function __unserialize(array $data): void {} + + final public function __serialize(): array {} + +#if PHP_VERSION_ID >= 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/TimestampInterface.c b/src/BSON/TimestampInterface.c index 4963eae03..e2e876889 100644 --- a/src/BSON/TimestampInterface.c +++ b/src/BSON/TimestampInterface.c @@ -17,30 +17,11 @@ #include #include "php_phongo.h" +#include "TimestampInterface_arginfo.h" zend_class_entry* php_phongo_timestamp_interface_ce; -/* {{{ MongoDB\BSON\TimestampInterface function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_TimestampInterface___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_TimestampInterface_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_timestamp_interface_me[] = { - ZEND_ABSTRACT_ME(TimestampInterface, getIncrement, ai_TimestampInterface_void) - ZEND_ABSTRACT_ME(TimestampInterface, getTimestamp, ai_TimestampInterface_void) - ZEND_ABSTRACT_ME(TimestampInterface, __toString, ai_TimestampInterface___toString) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - void php_phongo_timestamp_interface_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "TimestampInterface", php_phongo_timestamp_interface_me); - php_phongo_timestamp_interface_ce = zend_register_internal_interface(&ce); + php_phongo_timestamp_interface_ce = register_class_MongoDB_BSON_TimestampInterface(); } /* }}} */ diff --git a/src/BSON/TimestampInterface.stub.php b/src/BSON/TimestampInterface.stub.php new file mode 100644 index 000000000..93b26a109 --- /dev/null +++ b/src/BSON/TimestampInterface.stub.php @@ -0,0 +1,21 @@ += 80000 +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Timestamp___construct, 0, 0, 2) + ZEND_ARG_TYPE_MASK(0, increment, MAY_BE_LONG|MAY_BE_STRING, NULL) + ZEND_ARG_TYPE_MASK(0, timestamp, MAY_BE_LONG|MAY_BE_STRING, NULL) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Timestamp___construct, 0, 0, 2) + ZEND_ARG_INFO(0, increment) + ZEND_ARG_INFO(0, timestamp) +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Timestamp_getTimestamp, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_BSON_Timestamp_getIncrement arginfo_class_MongoDB_BSON_Timestamp_getTimestamp + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Timestamp___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_BSON_Timestamp___set_state, 0, 1, MongoDB\\BSON\\Timestamp, 0) + ZEND_ARG_TYPE_INFO(0, properties, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_BSON_Timestamp_serialize arginfo_class_MongoDB_BSON_Timestamp___toString + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Timestamp_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Timestamp___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Timestamp___serialize, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Timestamp_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Timestamp_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_Timestamp, __construct); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_Timestamp, __construct); +#endif +static ZEND_METHOD(MongoDB_BSON_Timestamp, getTimestamp); +static ZEND_METHOD(MongoDB_BSON_Timestamp, getIncrement); +static ZEND_METHOD(MongoDB_BSON_Timestamp, __toString); +static ZEND_METHOD(MongoDB_BSON_Timestamp, __set_state); +static ZEND_METHOD(MongoDB_BSON_Timestamp, serialize); +static ZEND_METHOD(MongoDB_BSON_Timestamp, unserialize); +static ZEND_METHOD(MongoDB_BSON_Timestamp, __unserialize); +static ZEND_METHOD(MongoDB_BSON_Timestamp, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_Timestamp, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_Timestamp, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_Timestamp_methods[] = { +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_Timestamp, __construct, arginfo_class_MongoDB_BSON_Timestamp___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_Timestamp, __construct, arginfo_class_MongoDB_BSON_Timestamp___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_BSON_Timestamp, getTimestamp, arginfo_class_MongoDB_BSON_Timestamp_getTimestamp, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Timestamp, getIncrement, arginfo_class_MongoDB_BSON_Timestamp_getIncrement, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Timestamp, __toString, arginfo_class_MongoDB_BSON_Timestamp___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Timestamp, __set_state, arginfo_class_MongoDB_BSON_Timestamp___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(MongoDB_BSON_Timestamp, serialize, arginfo_class_MongoDB_BSON_Timestamp_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Timestamp, unserialize, arginfo_class_MongoDB_BSON_Timestamp_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Timestamp, __unserialize, arginfo_class_MongoDB_BSON_Timestamp___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Timestamp, __serialize, arginfo_class_MongoDB_BSON_Timestamp___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_Timestamp, jsonSerialize, arginfo_class_MongoDB_BSON_Timestamp_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_Timestamp, jsonSerialize, arginfo_class_MongoDB_BSON_Timestamp_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_Timestamp(zend_class_entry *class_entry_MongoDB_BSON_TimestampInterface, zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Timestamp", class_MongoDB_BSON_Timestamp_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 4, class_entry_MongoDB_BSON_TimestampInterface, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/Type.c b/src/BSON/Type.c index 34ff9e527..a7cd2c0c6 100644 --- a/src/BSON/Type.c +++ b/src/BSON/Type.c @@ -17,19 +17,11 @@ #include #include "php_phongo.h" +#include "Type_arginfo.h" zend_class_entry* php_phongo_type_ce; -/* {{{ MongoDB\BSON\Type function entries */ -static zend_function_entry php_phongo_type_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_type_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Type", php_phongo_type_me); - php_phongo_type_ce = zend_register_internal_interface(&ce); + php_phongo_type_ce = register_class_MongoDB_BSON_Type(); } /* }}} */ diff --git a/src/BSON/Type.stub.php b/src/BSON/Type.stub.php new file mode 100644 index 000000000..d606d8f5e --- /dev/null +++ b/src/BSON/Type.stub.php @@ -0,0 +1,13 @@ +name)); @@ -182,7 +181,7 @@ static PHP_METHOD(UTCDateTime, __construct) /* {{{ proto MongoDB\BSON\UTCDateTime MongoDB\BSON\UTCDateTime::__set_state(array $properties) */ -static PHP_METHOD(UTCDateTime, __set_state) +static PHP_METHOD(MongoDB_BSON_UTCDateTime, __set_state) { php_phongo_utcdatetime_t* intern; HashTable* props; @@ -202,7 +201,7 @@ static PHP_METHOD(UTCDateTime, __set_state) /* {{{ proto string MongoDB\BSON\UTCDateTime::__toString() Returns the UTCDateTime's milliseconds as a string */ -static PHP_METHOD(UTCDateTime, __toString) +static PHP_METHOD(MongoDB_BSON_UTCDateTime, __toString) { php_phongo_utcdatetime_t* intern; @@ -215,7 +214,7 @@ static PHP_METHOD(UTCDateTime, __toString) /* {{{ proto DateTime MongoDB\BSON\UTCDateTime::toDateTime() Returns a DateTime object representing this UTCDateTime */ -static PHP_METHOD(UTCDateTime, toDateTime) +static PHP_METHOD(MongoDB_BSON_UTCDateTime, toDateTime) { php_phongo_utcdatetime_t* intern; php_date_obj* datetime_obj; @@ -239,7 +238,7 @@ static PHP_METHOD(UTCDateTime, toDateTime) /* {{{ proto array MongoDB\BSON\UTCDateTime::jsonSerialize() */ -static PHP_METHOD(UTCDateTime, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_UTCDateTime, jsonSerialize) { php_phongo_utcdatetime_t* intern; @@ -260,7 +259,7 @@ static PHP_METHOD(UTCDateTime, jsonSerialize) /* {{{ proto string MongoDB\BSON\UTCDateTime::serialize() */ -static PHP_METHOD(UTCDateTime, serialize) +static PHP_METHOD(MongoDB_BSON_UTCDateTime, serialize) { php_phongo_utcdatetime_t* intern; zval retval; @@ -287,7 +286,7 @@ static PHP_METHOD(UTCDateTime, serialize) /* {{{ proto void MongoDB\BSON\UTCDateTime::unserialize(string $serialized) */ -static PHP_METHOD(UTCDateTime, unserialize) +static PHP_METHOD(MongoDB_BSON_UTCDateTime, unserialize) { php_phongo_utcdatetime_t* intern; char* serialized; @@ -317,7 +316,7 @@ static PHP_METHOD(UTCDateTime, unserialize) /* {{{ proto array MongoDB\Driver\UTCDateTime::__serialize() */ -static PHP_METHOD(UTCDateTime, __serialize) +static PHP_METHOD(MongoDB_BSON_UTCDateTime, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -326,7 +325,7 @@ static PHP_METHOD(UTCDateTime, __serialize) /* {{{ proto void MongoDB\Driver\UTCDateTime::__unserialize(array $data) */ -static PHP_METHOD(UTCDateTime, __unserialize) +static PHP_METHOD(MongoDB_BSON_UTCDateTime, __unserialize) { zval* data; @@ -337,48 +336,6 @@ static PHP_METHOD(UTCDateTime, __unserialize) php_phongo_utcdatetime_init_from_hash(Z_UTCDATETIME_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\BSON\UTCDateTime function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime___construct, 0, 0, 0) - ZEND_ARG_INFO(0, milliseconds) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_UTCDateTime___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_UTCDateTime_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_utcdatetime_me[] = { - PHP_ME(UTCDateTime, __construct, ai_UTCDateTime___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(UTCDateTime, __serialize, ai_UTCDateTime_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(UTCDateTime, __set_state, ai_UTCDateTime___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(UTCDateTime, __toString, ai_UTCDateTime___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(UTCDateTime, __unserialize, ai_UTCDateTime___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(UTCDateTime, jsonSerialize, ai_UTCDateTime_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(UTCDateTime, serialize, ai_UTCDateTime_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(UTCDateTime, unserialize, ai_UTCDateTime_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(UTCDateTime, toDateTime, ai_UTCDateTime_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\UTCDateTime object handlers */ static zend_object_handlers php_phongo_handler_utcdatetime; @@ -453,17 +410,8 @@ static HashTable* php_phongo_utcdatetime_get_properties(phongo_compat_object_han void php_phongo_utcdatetime_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "UTCDateTime", php_phongo_utcdatetime_me); - php_phongo_utcdatetime_ce = zend_register_internal_class(&ce); + php_phongo_utcdatetime_ce = register_class_MongoDB_BSON_UTCDateTime(php_phongo_utcdatetime_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_utcdatetime_ce->create_object = php_phongo_utcdatetime_create_object; - PHONGO_CE_FINAL(php_phongo_utcdatetime_ce); - - zend_class_implements(php_phongo_utcdatetime_ce, 1, php_phongo_utcdatetime_interface_ce); - zend_class_implements(php_phongo_utcdatetime_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_utcdatetime_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_utcdatetime_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_utcdatetime_ce, 1, zend_ce_stringable); diff --git a/src/BSON/UTCDateTime.stub.php b/src/BSON/UTCDateTime.stub.php new file mode 100644 index 000000000..b5ba5155d --- /dev/null +++ b/src/BSON/UTCDateTime.stub.php @@ -0,0 +1,41 @@ += 80000 + public final function __construct(int|string|float|\DateTimeInterface|null $milliseconds = null) {} +#else + /** @param int|string|float|\DateTimeInterface|null $milliseconds */ + public final function __construct($milliseconds = null) {} +#endif + + public final function toDateTime(): \DateTime {} + + public final function __toString(): string {} + + public static function __set_state(array $properties): UTCDateTime {} + + final public function serialize(): string {} + + /** @param string $serialized */ + final public function unserialize($serialized): void {} + + final public function __unserialize(array $data): void {} + + final public function __serialize(): array {} + +#if PHP_VERSION_ID >= 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/UTCDateTimeInterface.c b/src/BSON/UTCDateTimeInterface.c index 7c5e8947c..439011d45 100644 --- a/src/BSON/UTCDateTimeInterface.c +++ b/src/BSON/UTCDateTimeInterface.c @@ -17,29 +17,11 @@ #include #include "php_phongo.h" +#include "UTCDateTimeInterface_arginfo.h" zend_class_entry* php_phongo_utcdatetime_interface_ce; -/* {{{ MongoDB\BSON\UTCDateTimeInterface function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_UTCDateTimeInterface___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTimeInterface_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_utcdatetime_interface_me[] = { - ZEND_ABSTRACT_ME(UTCDateTimeInterface, toDateTime, ai_UTCDateTimeInterface_void) - ZEND_ABSTRACT_ME(UTCDateTimeInterface, __toString, ai_UTCDateTimeInterface___toString) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - void php_phongo_utcdatetime_interface_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "UTCDateTimeInterface", php_phongo_utcdatetime_interface_me); - php_phongo_utcdatetime_interface_ce = zend_register_internal_interface(&ce); + php_phongo_utcdatetime_interface_ce = register_class_MongoDB_BSON_UTCDateTimeInterface(); } /* }}} */ diff --git a/src/BSON/UTCDateTimeInterface.stub.php b/src/BSON/UTCDateTimeInterface.stub.php new file mode 100644 index 000000000..98605ca88 --- /dev/null +++ b/src/BSON/UTCDateTimeInterface.stub.php @@ -0,0 +1,18 @@ += 80000 +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime___construct, 0, 0, 0) + ZEND_ARG_OBJ_TYPE_MASK(0, milliseconds, DateTimeInterface, MAY_BE_LONG|MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_NULL, "null") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime___construct, 0, 0, 0) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, milliseconds, "null") +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime_toDateTime, 0, 0, DateTime, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime___set_state, 0, 1, MongoDB\\BSON\\\125TCDateTime, 0) + ZEND_ARG_TYPE_INFO(0, properties, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_BSON_UTCDateTime_serialize arginfo_class_MongoDB_BSON_UTCDateTime___toString + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime___serialize, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, __construct); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, __construct); +#endif +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, toDateTime); +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, __toString); +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, __set_state); +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, serialize); +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, unserialize); +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, __unserialize); +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_UTCDateTime, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_UTCDateTime_methods[] = { +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_UTCDateTime, __construct, arginfo_class_MongoDB_BSON_UTCDateTime___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_UTCDateTime, __construct, arginfo_class_MongoDB_BSON_UTCDateTime___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_BSON_UTCDateTime, toDateTime, arginfo_class_MongoDB_BSON_UTCDateTime_toDateTime, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_UTCDateTime, __toString, arginfo_class_MongoDB_BSON_UTCDateTime___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_UTCDateTime, __set_state, arginfo_class_MongoDB_BSON_UTCDateTime___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(MongoDB_BSON_UTCDateTime, serialize, arginfo_class_MongoDB_BSON_UTCDateTime_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_UTCDateTime, unserialize, arginfo_class_MongoDB_BSON_UTCDateTime_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_UTCDateTime, __unserialize, arginfo_class_MongoDB_BSON_UTCDateTime___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_UTCDateTime, __serialize, arginfo_class_MongoDB_BSON_UTCDateTime___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_UTCDateTime, jsonSerialize, arginfo_class_MongoDB_BSON_UTCDateTime_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_UTCDateTime, jsonSerialize, arginfo_class_MongoDB_BSON_UTCDateTime_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_UTCDateTime(zend_class_entry *class_entry_MongoDB_BSON_UTCDateTimeInterface, zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "UTCDateTime", class_MongoDB_BSON_UTCDateTime_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 4, class_entry_MongoDB_BSON_UTCDateTimeInterface, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/Undefined.c b/src/BSON/Undefined.c index f6e0253ce..6d7e23b83 100644 --- a/src/BSON/Undefined.c +++ b/src/BSON/Undefined.c @@ -21,12 +21,15 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "Undefined_arginfo.h" zend_class_entry* php_phongo_undefined_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_Undefined) + /* {{{ proto string MongoDB\BSON\Undefined::__toString() Return the empty string. */ -static PHP_METHOD(Undefined, __toString) +static PHP_METHOD(MongoDB_BSON_Undefined, __toString) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -35,7 +38,7 @@ static PHP_METHOD(Undefined, __toString) /* {{{ proto array MongoDB\BSON\Undefined::jsonSerialize() */ -static PHP_METHOD(Undefined, jsonSerialize) +static PHP_METHOD(MongoDB_BSON_Undefined, jsonSerialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -45,7 +48,7 @@ static PHP_METHOD(Undefined, jsonSerialize) /* {{{ proto string MongoDB\BSON\Undefined::serialize() */ -static PHP_METHOD(Undefined, serialize) +static PHP_METHOD(MongoDB_BSON_Undefined, serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -54,7 +57,7 @@ static PHP_METHOD(Undefined, serialize) /* {{{ proto void MongoDB\BSON\Undefined::unserialize(string $serialized) */ -static PHP_METHOD(Undefined, unserialize) +static PHP_METHOD(MongoDB_BSON_Undefined, unserialize) { char* serialized; size_t serialized_len; @@ -66,7 +69,7 @@ static PHP_METHOD(Undefined, unserialize) /* {{{ proto array MongoDB\Driver\Undefined::__serialize() */ -static PHP_METHOD(Undefined, __serialize) +static PHP_METHOD(MongoDB_BSON_Undefined, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -75,7 +78,7 @@ static PHP_METHOD(Undefined, __serialize) /* {{{ proto void MongoDB\Driver\Undefined::__unserialize(array $data) */ -static PHP_METHOD(Undefined, __unserialize) +static PHP_METHOD(MongoDB_BSON_Undefined, __unserialize) { zval* data; @@ -84,39 +87,6 @@ static PHP_METHOD(Undefined, __unserialize) PHONGO_PARSE_PARAMETERS_END(); } /* }}} */ -/* {{{ MongoDB\BSON\Undefined function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_Undefined___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Undefined___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Undefined_jsonSerialize, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Undefined_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Undefined_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_undefined_me[] = { - /* __set_state intentionally missing */ - PHP_ME(Undefined, __serialize, ai_Undefined_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Undefined, __toString, ai_Undefined___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Undefined, __unserialize, ai_Undefined___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Undefined, jsonSerialize, ai_Undefined_jsonSerialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Undefined, serialize, ai_Undefined_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Undefined, unserialize, ai_Undefined_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_Undefined_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\BSON\Undefined object handlers */ static zend_object_handlers php_phongo_handler_undefined; @@ -142,16 +112,8 @@ static zend_object* php_phongo_undefined_create_object(zend_class_entry* class_t void php_phongo_undefined_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Undefined", php_phongo_undefined_me); - php_phongo_undefined_ce = zend_register_internal_class(&ce); + php_phongo_undefined_ce = register_class_MongoDB_BSON_Undefined(php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable); php_phongo_undefined_ce->create_object = php_phongo_undefined_create_object; - PHONGO_CE_FINAL(php_phongo_undefined_ce); - - zend_class_implements(php_phongo_undefined_ce, 1, php_phongo_json_serializable_ce); - zend_class_implements(php_phongo_undefined_ce, 1, php_phongo_type_ce); - zend_class_implements(php_phongo_undefined_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_undefined_ce, 1, zend_ce_stringable); diff --git a/src/BSON/Undefined.stub.php b/src/BSON/Undefined.stub.php new file mode 100644 index 000000000..b70ea012a --- /dev/null +++ b/src/BSON/Undefined.stub.php @@ -0,0 +1,32 @@ += 80000 + final public function jsonSerialize(): mixed {} +#else + /** @return mixed */ + final public function jsonSerialize() {} +#endif + } +} diff --git a/src/BSON/Undefined_arginfo.h b/src/BSON/Undefined_arginfo.h new file mode 100644 index 000000000..451ddcd4e --- /dev/null +++ b/src/BSON/Undefined_arginfo.h @@ -0,0 +1,74 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 25ffea1990a4c900470860c9fe80eccbbc05df39 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Undefined___construct, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Undefined___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_BSON_Undefined_serialize arginfo_class_MongoDB_BSON_Undefined___toString + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Undefined_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Undefined___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Undefined___serialize, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_BSON_Undefined_jsonSerialize, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Undefined_jsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + + +static ZEND_METHOD(MongoDB_BSON_Undefined, __construct); +static ZEND_METHOD(MongoDB_BSON_Undefined, __toString); +static ZEND_METHOD(MongoDB_BSON_Undefined, serialize); +static ZEND_METHOD(MongoDB_BSON_Undefined, unserialize); +static ZEND_METHOD(MongoDB_BSON_Undefined, __unserialize); +static ZEND_METHOD(MongoDB_BSON_Undefined, __serialize); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_BSON_Undefined, jsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_BSON_Undefined, jsonSerialize); +#endif + + +static const zend_function_entry class_MongoDB_BSON_Undefined_methods[] = { + ZEND_ME(MongoDB_BSON_Undefined, __construct, arginfo_class_MongoDB_BSON_Undefined___construct, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Undefined, __toString, arginfo_class_MongoDB_BSON_Undefined___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Undefined, serialize, arginfo_class_MongoDB_BSON_Undefined_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Undefined, unserialize, arginfo_class_MongoDB_BSON_Undefined_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Undefined, __unserialize, arginfo_class_MongoDB_BSON_Undefined___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_BSON_Undefined, __serialize, arginfo_class_MongoDB_BSON_Undefined___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_BSON_Undefined, jsonSerialize, arginfo_class_MongoDB_BSON_Undefined_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_BSON_Undefined, jsonSerialize, arginfo_class_MongoDB_BSON_Undefined_jsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_BSON_Undefined(zend_class_entry *class_entry_JsonSerializable, zend_class_entry *class_entry_MongoDB_BSON_Type, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Undefined", class_MongoDB_BSON_Undefined_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 3, class_entry_JsonSerializable, class_entry_MongoDB_BSON_Type, class_entry_Serializable); + + return class_entry; +} diff --git a/src/BSON/Unserializable.c b/src/BSON/Unserializable.c index 62eb49c20..b47a339db 100644 --- a/src/BSON/Unserializable.c +++ b/src/BSON/Unserializable.c @@ -17,26 +17,11 @@ #include #include "php_phongo.h" +#include "Unserializable_arginfo.h" zend_class_entry* php_phongo_unserializable_ce; -/* {{{ MongoDB\BSON\Unserializable function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_Unserializable_bsonUnserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_unserializable_me[] = { - /* clang-format off */ - ZEND_ABSTRACT_ME(Unserializable, bsonUnserialize, ai_Unserializable_bsonUnserialize) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - void php_phongo_unserializable_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Unserializable", php_phongo_unserializable_me); - php_phongo_unserializable_ce = zend_register_internal_interface(&ce); + php_phongo_unserializable_ce = register_class_MongoDB_BSON_Unserializable(); } /* }}} */ diff --git a/src/BSON/Unserializable.stub.php b/src/BSON/Unserializable.stub.php new file mode 100644 index 000000000..eab8d62a7 --- /dev/null +++ b/src/BSON/Unserializable.stub.php @@ -0,0 +1,15 @@ +num_ops); } /* }}} */ -/* {{{ MongoDB\Driver\BulkWrite function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite___construct, 0, 0, 0) - ZEND_ARG_ARRAY_INFO(0, options, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_BulkWrite_count, 0, 0, IS_LONG, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_insert, 0, 0, 1) - ZEND_ARG_INFO(0, document) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_update, 0, 0, 2) - ZEND_ARG_INFO(0, query) - ZEND_ARG_INFO(0, newObj) - ZEND_ARG_ARRAY_INFO(0, updateOptions, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_delete, 0, 0, 1) - ZEND_ARG_INFO(0, query) - ZEND_ARG_ARRAY_INFO(0, deleteOptions, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_bulkwrite_me[] = { - PHP_ME(BulkWrite, __construct, ai_BulkWrite___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(BulkWrite, insert, ai_BulkWrite_insert, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(BulkWrite, update, ai_BulkWrite_update, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(BulkWrite, delete, ai_BulkWrite_delete, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(BulkWrite, count, ai_BulkWrite_count, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_BulkWrite_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_BulkWrite) /* {{{ MongoDB\Driver\BulkWrite object handlers */ static zend_object_handlers php_phongo_handler_bulkwrite; @@ -707,18 +671,12 @@ static HashTable* php_phongo_bulkwrite_get_debug_info(phongo_compat_object_handl void php_phongo_bulkwrite_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "BulkWrite", php_phongo_bulkwrite_me); - php_phongo_bulkwrite_ce = zend_register_internal_class(&ce); + php_phongo_bulkwrite_ce = register_class_MongoDB_Driver_BulkWrite(zend_ce_countable); php_phongo_bulkwrite_ce->create_object = php_phongo_bulkwrite_create_object; - PHONGO_CE_FINAL(php_phongo_bulkwrite_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_bulkwrite_ce); memcpy(&php_phongo_handler_bulkwrite, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_bulkwrite.get_debug_info = php_phongo_bulkwrite_get_debug_info; php_phongo_handler_bulkwrite.free_obj = php_phongo_bulkwrite_free_object; php_phongo_handler_bulkwrite.offset = XtOffsetOf(php_phongo_bulkwrite_t, std); - - zend_class_implements(php_phongo_bulkwrite_ce, 1, zend_ce_countable); } /* }}} */ diff --git a/src/MongoDB/BulkWrite.stub.php b/src/MongoDB/BulkWrite.stub.php new file mode 100644 index 000000000..506cd4dec --- /dev/null +++ b/src/MongoDB/BulkWrite.stub.php @@ -0,0 +1,44 @@ += 80000 + public function delete(array|object $filter, array $deleteOptions = []): void {} +#else + /** @param array|object $filter */ + public function delete($filter, array $deleteOptions = []): void {} +#endif + +#if PHP_VERSION_ID >= 80000 + public final function insert(array|object $document): mixed {} +#else + /** + * @param array|object $document + * @return mixed + */ + public final function insert($document) {} +#endif + +#if PHP_VERSION_ID >= 80000 + public function update(array|object $filter, array|object $newObj, array $updateOptions = []): void {} +#else + /** + * @param array|object $filter + * @param array|object $newObj + */ + public function update($filter, $newObj, array $updateOptions = []): void {} +#endif + + final public function __wakeup(): void {} +} diff --git a/src/MongoDB/BulkWrite_arginfo.h b/src/MongoDB/BulkWrite_arginfo.h new file mode 100644 index 000000000..5c2434913 --- /dev/null +++ b/src/MongoDB/BulkWrite_arginfo.h @@ -0,0 +1,115 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 3325b767b4321a1837fa7a8aef924a39e6e6816d */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_BulkWrite___construct, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_BulkWrite_count, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_BulkWrite_delete, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_MASK(0, filter, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, deleteOptions, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_BulkWrite_delete, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, filter) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, deleteOptions, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() +#endif + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_BulkWrite_insert, 0, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_MASK(0, document, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_BulkWrite_insert, 0, 0, 1) + ZEND_ARG_INFO(0, document) +ZEND_END_ARG_INFO() +#endif + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_BulkWrite_update, 0, 2, IS_VOID, 0) + ZEND_ARG_TYPE_MASK(0, filter, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) + ZEND_ARG_TYPE_MASK(0, newObj, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, updateOptions, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_BulkWrite_update, 0, 2, IS_VOID, 0) + ZEND_ARG_INFO(0, filter) + ZEND_ARG_INFO(0, newObj) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, updateOptions, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_BulkWrite___wakeup, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() + + +static ZEND_METHOD(MongoDB_Driver_BulkWrite, __construct); +static ZEND_METHOD(MongoDB_Driver_BulkWrite, count); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_BulkWrite, delete); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_BulkWrite, delete); +#endif +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_BulkWrite, insert); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_BulkWrite, insert); +#endif +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_BulkWrite, update); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_BulkWrite, update); +#endif +static ZEND_METHOD(MongoDB_Driver_BulkWrite, __wakeup); + + +static const zend_function_entry class_MongoDB_Driver_BulkWrite_methods[] = { + ZEND_ME(MongoDB_Driver_BulkWrite, __construct, arginfo_class_MongoDB_Driver_BulkWrite___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_BulkWrite, count, arginfo_class_MongoDB_Driver_BulkWrite_count, ZEND_ACC_PUBLIC) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_BulkWrite, delete, arginfo_class_MongoDB_Driver_BulkWrite_delete, ZEND_ACC_PUBLIC) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_BulkWrite, delete, arginfo_class_MongoDB_Driver_BulkWrite_delete, ZEND_ACC_PUBLIC) +#endif +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_BulkWrite, insert, arginfo_class_MongoDB_Driver_BulkWrite_insert, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_BulkWrite, insert, arginfo_class_MongoDB_Driver_BulkWrite_insert, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_BulkWrite, update, arginfo_class_MongoDB_Driver_BulkWrite_update, ZEND_ACC_PUBLIC) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_BulkWrite, update, arginfo_class_MongoDB_Driver_BulkWrite_update, ZEND_ACC_PUBLIC) +#endif + ZEND_ME(MongoDB_Driver_BulkWrite, __wakeup, arginfo_class_MongoDB_Driver_BulkWrite___wakeup, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_BulkWrite(zend_class_entry *class_entry_Countable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "BulkWrite", class_MongoDB_Driver_BulkWrite_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 1, class_entry_Countable); + + return class_entry; +} diff --git a/src/MongoDB/ClientEncryption.c b/src/MongoDB/ClientEncryption.c index 65c215ae3..e4fe1c089 100644 --- a/src/MongoDB/ClientEncryption.c +++ b/src/MongoDB/ClientEncryption.c @@ -28,6 +28,7 @@ #include "phongo_util.h" #include "MongoDB/ClientEncryption.h" +#include "ClientEncryption_arginfo.h" zend_class_entry* php_phongo_clientencryption_ce; @@ -38,7 +39,7 @@ static void phongo_clientencryption_decrypt(php_phongo_clientencryption_t* clien /* {{{ proto void MongoDB\Driver\ClientEncryption::__construct(array $options) Constructs a new ClientEncryption */ -static PHP_METHOD(ClientEncryption, __construct) +static PHP_METHOD(MongoDB_Driver_ClientEncryption, __construct) { zval* options; @@ -52,7 +53,7 @@ static PHP_METHOD(ClientEncryption, __construct) /* {{{ proto MongoDB\BSON\Binary MongoDB\Driver\ClientEncryption::createDataKey(string $kmsProvider[, array $options]) Creates a new key document and inserts into the key vault collection. */ -static PHP_METHOD(ClientEncryption, createDataKey) +static PHP_METHOD(MongoDB_Driver_ClientEncryption, createDataKey) { char* kms_provider = NULL; size_t kms_provider_len = 0; @@ -72,7 +73,7 @@ static PHP_METHOD(ClientEncryption, createDataKey) /* {{{ proto MongoDB\BSON\Binary MongoDB\Driver\ClientEncryption::encrypt(mixed $value[, array $options]) Encrypts a value with a given key and algorithm */ -static PHP_METHOD(ClientEncryption, encrypt) +static PHP_METHOD(MongoDB_Driver_ClientEncryption, encrypt) { zval* value = NULL; zval* options = NULL; @@ -91,7 +92,7 @@ static PHP_METHOD(ClientEncryption, encrypt) /* {{{ proto mixed MongoDB\Driver\ClientEncryption::decrypt(MongoDB\BSON\BinaryInterface $value) Decrypts an encrypted value (BSON binary of subtype 6). Returns the original BSON value */ -static PHP_METHOD(ClientEncryption, decrypt) +static PHP_METHOD(MongoDB_Driver_ClientEncryption, decrypt) { zval* ciphertext; php_phongo_clientencryption_t* intern; @@ -105,38 +106,7 @@ static PHP_METHOD(ClientEncryption, decrypt) phongo_clientencryption_decrypt(intern, ciphertext, return_value); } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(ai_ClientEncryption___construct, 0, 0, 0) - ZEND_ARG_ARRAY_INFO(0, options, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ClientEncryption_createDataKey, 0, 0, 1) - ZEND_ARG_INFO(0, kmsProvider) - ZEND_ARG_ARRAY_INFO(0, options, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ClientEncryption_encrypt, 0, 0, 1) - ZEND_ARG_INFO(0, value) - ZEND_ARG_ARRAY_INFO(0, options, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ClientEncryption_decrypt, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, keyVaultClient, MongoDB\\BSON\\BinaryInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ClientEncryption_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_clientencryption_me[] = { - /* clang-format off */ - PHP_ME(ClientEncryption, __construct, ai_ClientEncryption___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ClientEncryption, createDataKey, ai_ClientEncryption_createDataKey, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ClientEncryption, encrypt, ai_ClientEncryption_encrypt, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ClientEncryption, decrypt, ai_ClientEncryption_decrypt, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_ClientEncryption_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_ClientEncryption) /* {{{ MongoDB\Driver\ClientEncryption object handlers */ static zend_object_handlers php_phongo_handler_clientencryption; @@ -186,24 +156,14 @@ static HashTable* php_phongo_clientencryption_get_debug_info(phongo_compat_objec void php_phongo_clientencryption_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ClientEncryption", php_phongo_clientencryption_me); - php_phongo_clientencryption_ce = zend_register_internal_class(&ce); + php_phongo_clientencryption_ce = register_class_MongoDB_Driver_ClientEncryption(); php_phongo_clientencryption_ce->create_object = php_phongo_clientencryption_create_object; - PHONGO_CE_FINAL(php_phongo_clientencryption_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_clientencryption_ce); memcpy(&php_phongo_handler_clientencryption, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_clientencryption.get_debug_info = php_phongo_clientencryption_get_debug_info; php_phongo_handler_clientencryption.free_obj = php_phongo_clientencryption_free_object; php_phongo_handler_clientencryption.offset = XtOffsetOf(php_phongo_clientencryption_t, std); - - zend_declare_class_constant_string(php_phongo_clientencryption_ce, ZEND_STRL("AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC"), MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); - zend_declare_class_constant_string(php_phongo_clientencryption_ce, ZEND_STRL("AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM"), MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM); - zend_declare_class_constant_string(php_phongo_clientencryption_ce, ZEND_STRL("ALGORITHM_INDEXED"), MONGOC_ENCRYPT_ALGORITHM_INDEXED); - zend_declare_class_constant_string(php_phongo_clientencryption_ce, ZEND_STRL("ALGORITHM_UNINDEXED"), MONGOC_ENCRYPT_ALGORITHM_UNINDEXED); - zend_declare_class_constant_string(php_phongo_clientencryption_ce, ZEND_STRL("QUERY_TYPE_EQUALITY"), MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY); } /* }}} */ #ifdef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION diff --git a/src/MongoDB/ClientEncryption.stub.php b/src/MongoDB/ClientEncryption.stub.php new file mode 100644 index 000000000..221fe0e35 --- /dev/null +++ b/src/MongoDB/ClientEncryption.stub.php @@ -0,0 +1,61 @@ += 80000 + final public function decrypt(\MongoDB\BSON\Binary $value): mixed {} +#else + /** @return mixed */ + final public function decrypt(\MongoDB\BSON\Binary $value) {} +#endif + +#if PHP_VERSION_ID >= 80000 + final public function encrypt(mixed $value, array $options = []): \MongoDB\BSON\Binary {} +#else + /** @param mixed $value */ + final public function encrypt($value, array $options = []): \MongoDB\BSON\Binary {} +#endif + + final public function __wakeup(): void {} +} diff --git a/src/MongoDB/ClientEncryption_arginfo.h b/src/MongoDB/ClientEncryption_arginfo.h new file mode 100644 index 000000000..f4a0619aa --- /dev/null +++ b/src/MongoDB/ClientEncryption_arginfo.h @@ -0,0 +1,123 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 169e941e986be2158c89ddba5d5f930cb8fa6bfe */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption___construct, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, options, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption_createDataKey, 0, 1, MongoDB\\BSON\\Binary, 0) + ZEND_ARG_TYPE_INFO(0, kmsProvider, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption_decrypt, 0, 1, IS_MIXED, 0) + ZEND_ARG_OBJ_INFO(0, value, MongoDB\\BSON\\Binary, 0) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption_decrypt, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, value, MongoDB\\BSON\\Binary, 0) +ZEND_END_ARG_INFO() +#endif + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption_encrypt, 0, 1, MongoDB\\BSON\\Binary, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption_encrypt, 0, 1, MongoDB\\BSON\\Binary, 0) + ZEND_ARG_INFO(0, value) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption___wakeup, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() + + +static ZEND_METHOD(MongoDB_Driver_ClientEncryption, __construct); +static ZEND_METHOD(MongoDB_Driver_ClientEncryption, createDataKey); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_ClientEncryption, decrypt); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_ClientEncryption, decrypt); +#endif +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_ClientEncryption, encrypt); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_ClientEncryption, encrypt); +#endif +static ZEND_METHOD(MongoDB_Driver_ClientEncryption, __wakeup); + + +static const zend_function_entry class_MongoDB_Driver_ClientEncryption_methods[] = { + ZEND_ME(MongoDB_Driver_ClientEncryption, __construct, arginfo_class_MongoDB_Driver_ClientEncryption___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ClientEncryption, createDataKey, arginfo_class_MongoDB_Driver_ClientEncryption_createDataKey, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_ClientEncryption, decrypt, arginfo_class_MongoDB_Driver_ClientEncryption_decrypt, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_ClientEncryption, decrypt, arginfo_class_MongoDB_Driver_ClientEncryption_decrypt, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_ClientEncryption, encrypt, arginfo_class_MongoDB_Driver_ClientEncryption_encrypt, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_ClientEncryption, encrypt, arginfo_class_MongoDB_Driver_ClientEncryption_encrypt, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_ClientEncryption, __wakeup, arginfo_class_MongoDB_Driver_ClientEncryption___wakeup, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_ClientEncryption(void) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ClientEncryption", class_MongoDB_Driver_ClientEncryption_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + + zval const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value; + zend_string *const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value_str = zend_string_init(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC, sizeof(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC) - 1, 1); + ZVAL_STR(&const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value, const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value_str); + zend_string *const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_name = zend_string_init_interned("AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC", sizeof("AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_name, &const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_name); + + zval const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value; + zend_string *const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value_str = zend_string_init(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM, sizeof(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM) - 1, 1); + ZVAL_STR(&const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value, const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value_str); + zend_string *const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_name = zend_string_init_interned("AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM", sizeof("AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_name, &const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_name); + + zval const_ALGORITHM_INDEXED_value; + zend_string *const_ALGORITHM_INDEXED_value_str = zend_string_init(MONGOC_ENCRYPT_ALGORITHM_INDEXED, sizeof(MONGOC_ENCRYPT_ALGORITHM_INDEXED) - 1, 1); + ZVAL_STR(&const_ALGORITHM_INDEXED_value, const_ALGORITHM_INDEXED_value_str); + zend_string *const_ALGORITHM_INDEXED_name = zend_string_init_interned("ALGORITHM_INDEXED", sizeof("ALGORITHM_INDEXED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_ALGORITHM_INDEXED_name, &const_ALGORITHM_INDEXED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_ALGORITHM_INDEXED_name); + + zval const_ALGORITHM_UNINDEXED_value; + zend_string *const_ALGORITHM_UNINDEXED_value_str = zend_string_init(MONGOC_ENCRYPT_ALGORITHM_UNINDEXED, sizeof(MONGOC_ENCRYPT_ALGORITHM_UNINDEXED) - 1, 1); + ZVAL_STR(&const_ALGORITHM_UNINDEXED_value, const_ALGORITHM_UNINDEXED_value_str); + zend_string *const_ALGORITHM_UNINDEXED_name = zend_string_init_interned("ALGORITHM_UNINDEXED", sizeof("ALGORITHM_UNINDEXED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_ALGORITHM_UNINDEXED_name, &const_ALGORITHM_UNINDEXED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_ALGORITHM_UNINDEXED_name); + + zval const_QUERY_TYPE_EQUALITY_value; + zend_string *const_QUERY_TYPE_EQUALITY_value_str = zend_string_init(MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY, sizeof(MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY) - 1, 1); + ZVAL_STR(&const_QUERY_TYPE_EQUALITY_value, const_QUERY_TYPE_EQUALITY_value_str); + zend_string *const_QUERY_TYPE_EQUALITY_name = zend_string_init_interned("QUERY_TYPE_EQUALITY", sizeof("QUERY_TYPE_EQUALITY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_QUERY_TYPE_EQUALITY_name, &const_QUERY_TYPE_EQUALITY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_QUERY_TYPE_EQUALITY_name); + + return class_entry; +} diff --git a/src/MongoDB/Command.c b/src/MongoDB/Command.c index d0c3f2333..424e154e7 100644 --- a/src/MongoDB/Command.c +++ b/src/MongoDB/Command.c @@ -24,6 +24,7 @@ #include "php_phongo.h" #include "phongo_bson_encode.h" #include "phongo_error.h" +#include "Command_arginfo.h" zend_class_entry* php_phongo_command_ce; @@ -98,7 +99,7 @@ static bool php_phongo_command_init(php_phongo_command_t* intern, zval* filter, /* {{{ proto void MongoDB\Driver\Command::__construct(array|object $document[, array $options = array()]) Constructs a new Command */ -static PHP_METHOD(Command, __construct) +static PHP_METHOD(MongoDB_Driver_Command, __construct) { php_phongo_command_t* intern; zval* document; @@ -115,23 +116,7 @@ static PHP_METHOD(Command, __construct) php_phongo_command_init(intern, document, options); } /* }}} */ -/* {{{ MongoDB\Driver\Command function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_Command___construct, 0, 0, 1) - ZEND_ARG_INFO(0, document) - ZEND_ARG_ARRAY_INFO(0, options, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Command_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_command_me[] = { - /* clang-format off */ - PHP_ME(Command, __construct, ai_Command___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_Command_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Command) /* {{{ MongoDB\Driver\Command object handlers */ static zend_object_handlers php_phongo_handler_command; @@ -190,12 +175,8 @@ static HashTable* php_phongo_command_get_debug_info(phongo_compat_object_handler void php_phongo_command_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Command", php_phongo_command_me); - php_phongo_command_ce = zend_register_internal_class(&ce); + php_phongo_command_ce = register_class_MongoDB_Driver_Command(); php_phongo_command_ce->create_object = php_phongo_command_create_object; - PHONGO_CE_FINAL(php_phongo_command_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_command_ce); memcpy(&php_phongo_handler_command, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/Command.stub.php b/src/MongoDB/Command.stub.php new file mode 100644 index 000000000..17cb08257 --- /dev/null +++ b/src/MongoDB/Command.stub.php @@ -0,0 +1,20 @@ += 80000 + final public function __construct(array|object $document, array $commandOptions = []) {} +#else + /** @param array|object $document */ + final public function __construct($document, array $commandOptions = []) {} +#endif + + final public function __wakeup(): void {} +} diff --git a/src/MongoDB/Command_arginfo.h b/src/MongoDB/Command_arginfo.h new file mode 100644 index 000000000..8708db47e --- /dev/null +++ b/src/MongoDB/Command_arginfo.h @@ -0,0 +1,51 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 3902d0f3c6602053c90a7ee4bc97ece0d6534157 */ + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Command___construct, 0, 0, 1) + ZEND_ARG_TYPE_MASK(0, document, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, commandOptions, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Command___construct, 0, 0, 1) + ZEND_ARG_INFO(0, document) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, commandOptions, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Command___wakeup, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() + + +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Command, __construct); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Command, __construct); +#endif +static ZEND_METHOD(MongoDB_Driver_Command, __wakeup); + + +static const zend_function_entry class_MongoDB_Driver_Command_methods[] = { +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Command, __construct, arginfo_class_MongoDB_Driver_Command___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Command, __construct, arginfo_class_MongoDB_Driver_Command___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_Command, __wakeup, arginfo_class_MongoDB_Driver_Command___wakeup, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_Command(void) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Command", class_MongoDB_Driver_Command_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Cursor.c b/src/MongoDB/Cursor.c index 4778e45c1..573346147 100644 --- a/src/MongoDB/Cursor.c +++ b/src/MongoDB/Cursor.c @@ -25,6 +25,7 @@ #include "MongoDB/Cursor.h" #include "MongoDB/Server.h" +#include "Cursor_arginfo.h" zend_class_entry* php_phongo_cursor_ce; @@ -54,7 +55,7 @@ static void php_phongo_cursor_free_current(php_phongo_cursor_t* cursor) /* {{{ * /* {{{ proto void MongoDB\Driver\Cursor::setTypeMap(array $typemap) Sets a type map to use for BSON unserialization */ -static PHP_METHOD(Cursor, setTypeMap) +static PHP_METHOD(MongoDB_Driver_Cursor, setTypeMap) { php_phongo_cursor_t* intern; php_phongo_bson_state state; @@ -127,7 +128,7 @@ static void php_phongo_cursor_id_new_from_id(zval* object, int64_t cursorid) /* /* {{{ proto array MongoDB\Driver\Cursor::toArray() Returns an array of all result documents for this cursor */ -static PHP_METHOD(Cursor, toArray) +static PHP_METHOD(MongoDB_Driver_Cursor, toArray) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -141,7 +142,7 @@ static PHP_METHOD(Cursor, toArray) /* {{{ proto MongoDB\Driver\CursorId MongoDB\Driver\Cursor::getId() Returns the CursorId for this cursor */ -static PHP_METHOD(Cursor, getId) +static PHP_METHOD(MongoDB_Driver_Cursor, getId) { php_phongo_cursor_t* intern; @@ -154,7 +155,7 @@ static PHP_METHOD(Cursor, getId) /* {{{ proto MongoDB\Driver\Server MongoDB\Driver\Cursor::getServer() Returns the Server object to which this cursor is attached */ -static PHP_METHOD(Cursor, getServer) +static PHP_METHOD(MongoDB_Driver_Cursor, getServer) { php_phongo_cursor_t* intern; @@ -167,7 +168,7 @@ static PHP_METHOD(Cursor, getServer) /* {{{ proto boolean MongoDB\Driver\Cursor::isDead() Checks if a cursor is still alive */ -static PHP_METHOD(Cursor, isDead) +static PHP_METHOD(MongoDB_Driver_Cursor, isDead) { php_phongo_cursor_t* intern; @@ -178,7 +179,7 @@ static PHP_METHOD(Cursor, isDead) RETURN_BOOL(!mongoc_cursor_more(intern->cursor)); } /* }}} */ -PHP_METHOD(Cursor, current) +static PHP_METHOD(MongoDB_Driver_Cursor, current) { php_phongo_cursor_t* intern = Z_CURSOR_OBJ_P(getThis()); zval* data; @@ -194,7 +195,7 @@ PHP_METHOD(Cursor, current) } } -PHP_METHOD(Cursor, key) +static PHP_METHOD(MongoDB_Driver_Cursor, key) { php_phongo_cursor_t* intern = Z_CURSOR_OBJ_P(getThis()); @@ -207,7 +208,7 @@ PHP_METHOD(Cursor, key) RETURN_LONG(intern->current); } -PHP_METHOD(Cursor, next) +static PHP_METHOD(MongoDB_Driver_Cursor, next) { php_phongo_cursor_t* intern = Z_CURSOR_OBJ_P(getThis()); const bson_t* doc; @@ -245,7 +246,7 @@ PHP_METHOD(Cursor, next) php_phongo_cursor_free_session_if_exhausted(intern); } -PHP_METHOD(Cursor, valid) +static PHP_METHOD(MongoDB_Driver_Cursor, valid) { php_phongo_cursor_t* intern = Z_CURSOR_OBJ_P(getThis()); @@ -254,7 +255,7 @@ PHP_METHOD(Cursor, valid) RETURN_BOOL(!Z_ISUNDEF(intern->visitor_data.zchild)); } -PHP_METHOD(Cursor, rewind) +static PHP_METHOD(MongoDB_Driver_Cursor, rewind) { php_phongo_cursor_t* intern = Z_CURSOR_OBJ_P(getThis()); const bson_t* doc; @@ -291,49 +292,8 @@ PHP_METHOD(Cursor, rewind) php_phongo_cursor_free_session_if_exhausted(intern); } -/* {{{ MongoDB\Driver\Cursor function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Cursor_current, 0, 0, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Cursor_key, 0, 0, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Cursor_next, 0, 0, IS_VOID, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Cursor_valid, 0, 0, _IS_BOOL, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_Cursor_rewind, 0, 0, IS_VOID, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Cursor_setTypeMap, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, typemap, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Cursor_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_cursor_me[] = { - PHP_ME(Cursor, setTypeMap, ai_Cursor_setTypeMap, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Cursor, toArray, ai_Cursor_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Cursor, getId, ai_Cursor_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Cursor, getServer, ai_Cursor_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Cursor, isDead, ai_Cursor_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - - PHP_ME(Cursor, current, ai_Cursor_current, ZEND_ACC_PUBLIC) - PHP_ME(Cursor, key, ai_Cursor_key, ZEND_ACC_PUBLIC) - PHP_ME(Cursor, next, ai_Cursor_next, ZEND_ACC_PUBLIC) - PHP_ME(Cursor, valid, ai_Cursor_valid, ZEND_ACC_PUBLIC) - PHP_ME(Cursor, rewind, ai_Cursor_rewind, ZEND_ACC_PUBLIC) - - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_Cursor_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_Cursor_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Cursor) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Cursor) /* {{{ MongoDB\Driver\Cursor object handlers */ static zend_object_handlers php_phongo_handler_cursor; @@ -475,17 +435,10 @@ static HashTable* php_phongo_cursor_get_debug_info(phongo_compat_object_handler_ void php_phongo_cursor_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Cursor", php_phongo_cursor_me); - php_phongo_cursor_ce = zend_register_internal_class(&ce); + php_phongo_cursor_ce = register_class_MongoDB_Driver_Cursor(zend_ce_iterator, php_phongo_cursor_interface_ce); php_phongo_cursor_ce->create_object = php_phongo_cursor_create_object; - PHONGO_CE_FINAL(php_phongo_cursor_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_cursor_ce); - zend_class_implements(php_phongo_cursor_ce, 1, zend_ce_iterator); - zend_class_implements(php_phongo_cursor_ce, 1, php_phongo_cursor_interface_ce); - memcpy(&php_phongo_handler_cursor, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_cursor.get_debug_info = php_phongo_cursor_get_debug_info; php_phongo_handler_cursor.free_obj = php_phongo_cursor_free_object; diff --git a/src/MongoDB/Cursor.stub.php b/src/MongoDB/Cursor.stub.php new file mode 100644 index 000000000..69af69ec5 --- /dev/null +++ b/src/MongoDB/Cursor.stub.php @@ -0,0 +1,40 @@ += 80000 + public function current(): array|object|null {} +#else + /** @return array|object|null */ + public function current() {} +#endif + + final public function getId(): CursorId {} + + final public function getServer(): Server {} + + final public function isDead(): bool {} + + public function key(): ?int {} + + public function next(): void {} + + public function rewind(): void {} + + final public function setTypeMap(array $typemap): void {} + + final public function toArray(): array {} + + public function valid(): bool {} + + final public function __wakeup(): void {} +} diff --git a/src/MongoDB/CursorId.c b/src/MongoDB/CursorId.c index e9730a855..1368e4663 100644 --- a/src/MongoDB/CursorId.c +++ b/src/MongoDB/CursorId.c @@ -22,6 +22,7 @@ #include "php_phongo.h" #include "phongo_error.h" #include "phongo_util.h" +#include "CursorId_arginfo.h" zend_class_entry* php_phongo_cursorid_ce; @@ -92,7 +93,7 @@ static HashTable* php_phongo_cursorid_get_properties_hash(phongo_compat_object_h /* {{{ proto MongoDB\Driver\CursorId MongoDB\Driver\CursorId::__set_state(array $properties) */ -static PHP_METHOD(CursorId, __set_state) +PHP_METHOD(MongoDB_Driver_CursorId, __set_state) { php_phongo_cursorid_t* intern; HashTable* props; @@ -112,7 +113,7 @@ static PHP_METHOD(CursorId, __set_state) /* {{{ proto string MongoDB\Driver\CursorId::__toString() Returns the string representation of the CursorId */ -static PHP_METHOD(CursorId, __toString) +PHP_METHOD(MongoDB_Driver_CursorId, __toString) { php_phongo_cursorid_t* intern; char* tmp; @@ -129,7 +130,7 @@ static PHP_METHOD(CursorId, __toString) /* {{{ proto string MongoDB\Driver\CursorId::serialize() */ -static PHP_METHOD(CursorId, serialize) +PHP_METHOD(MongoDB_Driver_CursorId, serialize) { php_phongo_cursorid_t* intern; zval retval; @@ -156,7 +157,7 @@ static PHP_METHOD(CursorId, serialize) /* {{{ proto void MongoDB\Driver\CursorId::unserialize(string $serialized) */ -static PHP_METHOD(CursorId, unserialize) +PHP_METHOD(MongoDB_Driver_CursorId, unserialize) { php_phongo_cursorid_t* intern; char* serialized; @@ -186,7 +187,7 @@ static PHP_METHOD(CursorId, unserialize) /* {{{ proto array MongoDB\Driver\CursorId::__serialize() */ -static PHP_METHOD(CursorId, __serialize) +PHP_METHOD(MongoDB_Driver_CursorId, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -195,7 +196,7 @@ static PHP_METHOD(CursorId, __serialize) /* {{{ proto void MongoDB\Driver\CursorId::__unserialize(array $data) */ -static PHP_METHOD(CursorId, __unserialize) +PHP_METHOD(MongoDB_Driver_CursorId, __unserialize) { zval* data; @@ -206,38 +207,7 @@ static PHP_METHOD(CursorId, __unserialize) php_phongo_cursorid_init_from_hash(Z_CURSORID_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\Driver\CursorId function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_CursorId___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_CursorId___toString, 0, 0, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_CursorId___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_CursorId_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_CursorId_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_cursorid_me[] = { - PHP_ME(CursorId, __serialize, ai_CursorId_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CursorId, __set_state, ai_CursorId___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(CursorId, __toString, ai_CursorId___toString, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CursorId, __unserialize, ai_CursorId___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CursorId, serialize, ai_CursorId_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CursorId, unserialize, ai_CursorId_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_CursorId_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_CursorId) /* {{{ MongoDB\Driver\CursorId object handlers */ static zend_object_handlers php_phongo_handler_cursorid; @@ -280,14 +250,8 @@ static HashTable* php_phongo_cursorid_get_properties(phongo_compat_object_handle void php_phongo_cursorid_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "CursorId", php_phongo_cursorid_me); - php_phongo_cursorid_ce = zend_register_internal_class(&ce); + php_phongo_cursorid_ce = register_class_MongoDB_Driver_CursorId(zend_ce_serializable); php_phongo_cursorid_ce->create_object = php_phongo_cursorid_create_object; - PHONGO_CE_FINAL(php_phongo_cursorid_ce); - - zend_class_implements(php_phongo_cursorid_ce, 1, zend_ce_serializable); #if PHP_VERSION_ID >= 80000 zend_class_implements(php_phongo_cursorid_ce, 1, zend_ce_stringable); diff --git a/src/MongoDB/CursorId.stub.php b/src/MongoDB/CursorId.stub.php new file mode 100644 index 000000000..cb5543b8f --- /dev/null +++ b/src/MongoDB/CursorId.stub.php @@ -0,0 +1,26 @@ +ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 1, class_entry_Serializable); + + return class_entry; +} diff --git a/src/MongoDB/CursorInterface.c b/src/MongoDB/CursorInterface.c index 23797ae53..53c747ea3 100644 --- a/src/MongoDB/CursorInterface.c +++ b/src/MongoDB/CursorInterface.c @@ -18,35 +18,11 @@ #include #include "php_phongo.h" +#include "CursorInterface_arginfo.h" zend_class_entry* php_phongo_cursor_interface_ce; -/* {{{ MongoDB\BSON\CursorInterface function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_CursorInterface_setTypeMap, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, typemap, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_CursorInterface_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_cursor_interface_me[] = { - /* clang-format off */ - ZEND_ABSTRACT_ME(CursorInterface, getId, ai_CursorInterface_void) - ZEND_ABSTRACT_ME(CursorInterface, getServer, ai_CursorInterface_void) - ZEND_ABSTRACT_ME(CursorInterface, isDead, ai_CursorInterface_void) - ZEND_ABSTRACT_ME(CursorInterface, setTypeMap, ai_CursorInterface_setTypeMap) - ZEND_ABSTRACT_ME(CursorInterface, toArray, ai_CursorInterface_void) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - void php_phongo_cursor_interface_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "CursorInterface", php_phongo_cursor_interface_me); - php_phongo_cursor_interface_ce = zend_register_internal_interface(&ce); - - zend_class_implements(php_phongo_cursor_interface_ce, 1, zend_ce_traversable); + php_phongo_cursor_interface_ce = register_class_MongoDB_Driver_CursorInterface(zend_ce_traversable); } /* }}} */ diff --git a/src/MongoDB/CursorInterface.stub.php b/src/MongoDB/CursorInterface.stub.php new file mode 100644 index 000000000..112555e8b --- /dev/null +++ b/src/MongoDB/CursorInterface.stub.php @@ -0,0 +1,26 @@ += 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_Driver_Cursor_current, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_NULL) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Cursor_current, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Cursor_getId, 0, 0, MongoDB\\Driver\\CursorId, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Cursor_getServer, 0, 0, MongoDB\\Driver\\Server, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Cursor_isDead, 0, 0, _IS_BOOL, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Cursor_key, 0, 0, IS_LONG, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Cursor_next, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_Cursor_rewind arginfo_class_MongoDB_Driver_Cursor_next + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Cursor_setTypeMap, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, typemap, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Cursor_toArray, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_Cursor_valid arginfo_class_MongoDB_Driver_Cursor_isDead + +#define arginfo_class_MongoDB_Driver_Cursor___wakeup arginfo_class_MongoDB_Driver_Cursor_next + + +static ZEND_METHOD(MongoDB_Driver_Cursor, __construct); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Cursor, current); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Cursor, current); +#endif +static ZEND_METHOD(MongoDB_Driver_Cursor, getId); +static ZEND_METHOD(MongoDB_Driver_Cursor, getServer); +static ZEND_METHOD(MongoDB_Driver_Cursor, isDead); +static ZEND_METHOD(MongoDB_Driver_Cursor, key); +static ZEND_METHOD(MongoDB_Driver_Cursor, next); +static ZEND_METHOD(MongoDB_Driver_Cursor, rewind); +static ZEND_METHOD(MongoDB_Driver_Cursor, setTypeMap); +static ZEND_METHOD(MongoDB_Driver_Cursor, toArray); +static ZEND_METHOD(MongoDB_Driver_Cursor, valid); +static ZEND_METHOD(MongoDB_Driver_Cursor, __wakeup); + + +static const zend_function_entry class_MongoDB_Driver_Cursor_methods[] = { + ZEND_ME(MongoDB_Driver_Cursor, __construct, arginfo_class_MongoDB_Driver_Cursor___construct, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Cursor, current, arginfo_class_MongoDB_Driver_Cursor_current, ZEND_ACC_PUBLIC) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Cursor, current, arginfo_class_MongoDB_Driver_Cursor_current, ZEND_ACC_PUBLIC) +#endif + ZEND_ME(MongoDB_Driver_Cursor, getId, arginfo_class_MongoDB_Driver_Cursor_getId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Cursor, getServer, arginfo_class_MongoDB_Driver_Cursor_getServer, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Cursor, isDead, arginfo_class_MongoDB_Driver_Cursor_isDead, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Cursor, key, arginfo_class_MongoDB_Driver_Cursor_key, ZEND_ACC_PUBLIC) + ZEND_ME(MongoDB_Driver_Cursor, next, arginfo_class_MongoDB_Driver_Cursor_next, ZEND_ACC_PUBLIC) + ZEND_ME(MongoDB_Driver_Cursor, rewind, arginfo_class_MongoDB_Driver_Cursor_rewind, ZEND_ACC_PUBLIC) + ZEND_ME(MongoDB_Driver_Cursor, setTypeMap, arginfo_class_MongoDB_Driver_Cursor_setTypeMap, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Cursor, toArray, arginfo_class_MongoDB_Driver_Cursor_toArray, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Cursor, valid, arginfo_class_MongoDB_Driver_Cursor_valid, ZEND_ACC_PUBLIC) + ZEND_ME(MongoDB_Driver_Cursor, __wakeup, arginfo_class_MongoDB_Driver_Cursor___wakeup, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_Cursor(zend_class_entry *class_entry_Iterator, zend_class_entry *class_entry_MongoDB_Driver_CursorInterface) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Cursor", class_MongoDB_Driver_Cursor_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 2, class_entry_Iterator, class_entry_MongoDB_Driver_CursorInterface); + + return class_entry; +} diff --git a/src/MongoDB/Exception/AuthenticationException.c b/src/MongoDB/Exception/AuthenticationException.c index c118a1173..d23bf0875 100644 --- a/src/MongoDB/Exception/AuthenticationException.c +++ b/src/MongoDB/Exception/AuthenticationException.c @@ -17,19 +17,11 @@ #include #include "php_phongo.h" +#include "AuthenticationException_arginfo.h" zend_class_entry* php_phongo_authenticationexception_ce; -/* {{{ MongoDB\Driver\Exception\AuthenticationException function entries */ -static zend_function_entry php_phongo_authenticationexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_authenticationexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "AuthenticationException", php_phongo_authenticationexception_me); - php_phongo_authenticationexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce); + php_phongo_authenticationexception_ce = register_class_MongoDB_Driver_Exception_AuthenticationException(php_phongo_connectionexception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/AuthenticationException.stub.php b/src/MongoDB/Exception/AuthenticationException.stub.php new file mode 100644 index 000000000..a63b0f156 --- /dev/null +++ b/src/MongoDB/Exception/AuthenticationException.stub.php @@ -0,0 +1,12 @@ + #include "php_phongo.h" +#include "BulkWriteException_arginfo.h" zend_class_entry* php_phongo_bulkwriteexception_ce; -/* {{{ MongoDB\Driver\Exception\BulkWriteException function entries */ -static zend_function_entry php_phongo_bulkwriteexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_bulkwriteexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "BulkWriteException", php_phongo_bulkwriteexception_me); - php_phongo_bulkwriteexception_ce = zend_register_internal_class_ex(&ce, php_phongo_writeexception_ce); + php_phongo_bulkwriteexception_ce = register_class_MongoDB_Driver_Exception_BulkWriteException(php_phongo_writeexception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/BulkWriteException.stub.php b/src/MongoDB/Exception/BulkWriteException.stub.php new file mode 100644 index 000000000..a8c562b0b --- /dev/null +++ b/src/MongoDB/Exception/BulkWriteException.stub.php @@ -0,0 +1,12 @@ + #include "php_phongo.h" +#include "ConnectionException_arginfo.h" zend_class_entry* php_phongo_connectionexception_ce; -/* {{{ MongoDB\Driver\Exception\ConnectionException function entries */ -static zend_function_entry php_phongo_connectionexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_connectionexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ConnectionException", php_phongo_connectionexception_me); - php_phongo_connectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce); + php_phongo_connectionexception_ce = register_class_MongoDB_Driver_Exception_ConnectionException(php_phongo_runtimeexception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/ConnectionException.stub.php b/src/MongoDB/Exception/ConnectionException.stub.php new file mode 100644 index 000000000..74fc8401b --- /dev/null +++ b/src/MongoDB/Exception/ConnectionException.stub.php @@ -0,0 +1,12 @@ + #include "php_phongo.h" +#include "ConnectionTimeoutException_arginfo.h" zend_class_entry* php_phongo_connectiontimeoutexception_ce; -/* {{{ MongoDB\Driver\Exception\ConnectionTimeoutException function entries */ -static zend_function_entry php_phongo_connectiontimeoutexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_connectiontimeoutexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ConnectionTimeoutException", php_phongo_connectiontimeoutexception_me); - php_phongo_connectiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce); - PHONGO_CE_FINAL(php_phongo_connectiontimeoutexception_ce); + php_phongo_connectiontimeoutexception_ce = register_class_MongoDB_Driver_Exception_ConnectionTimeoutException(php_phongo_connectionexception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/ConnectionTimeoutException.stub.php b/src/MongoDB/Exception/ConnectionTimeoutException.stub.php new file mode 100644 index 000000000..aef91e752 --- /dev/null +++ b/src/MongoDB/Exception/ConnectionTimeoutException.stub.php @@ -0,0 +1,12 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Exception/EncryptionException.c b/src/MongoDB/Exception/EncryptionException.c index 9016225e6..7f3d92936 100644 --- a/src/MongoDB/Exception/EncryptionException.c +++ b/src/MongoDB/Exception/EncryptionException.c @@ -17,19 +17,11 @@ #include #include "php_phongo.h" +#include "EncryptionException_arginfo.h" zend_class_entry* php_phongo_encryptionexception_ce; -/* {{{ MongoDB\Driver\Exception\EncryptionException function entries */ -static zend_function_entry php_phongo_encryptionexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_encryptionexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "EncryptionException", php_phongo_encryptionexception_me); - php_phongo_encryptionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce); + php_phongo_encryptionexception_ce = register_class_MongoDB_Driver_Exception_EncryptionException(php_phongo_runtimeexception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/EncryptionException.stub.php b/src/MongoDB/Exception/EncryptionException.stub.php new file mode 100644 index 000000000..c0fa579ee --- /dev/null +++ b/src/MongoDB/Exception/EncryptionException.stub.php @@ -0,0 +1,13 @@ + #include "php_phongo.h" +#include "Exception_arginfo.h" zend_class_entry* php_phongo_exception_ce; -/* {{{ MongoDB\Driver\Exception\Exception function entries */ -static zend_function_entry php_phongo_exception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_exception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "Exception", php_phongo_exception_me); - php_phongo_exception_ce = zend_register_internal_interface(&ce); - zend_class_implements(php_phongo_exception_ce, 1, zend_ce_throwable); + php_phongo_exception_ce = register_class_MongoDB_Driver_Exception_Exception(zend_ce_throwable); } /* }}} */ diff --git a/src/MongoDB/Exception/Exception.stub.php b/src/MongoDB/Exception/Exception.stub.php new file mode 100644 index 000000000..f3cff6024 --- /dev/null +++ b/src/MongoDB/Exception/Exception.stub.php @@ -0,0 +1,12 @@ + #include "php_phongo.h" +#include "ExecutionTimeoutException_arginfo.h" zend_class_entry* php_phongo_executiontimeoutexception_ce; -/* {{{ MongoDB\Driver\Exception\ExecutionTimeoutException function entries */ -static zend_function_entry php_phongo_executiontimeoutexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_executiontimeoutexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ExecutionTimeoutException", php_phongo_executiontimeoutexception_me); - php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_serverexception_ce); - PHONGO_CE_FINAL(php_phongo_executiontimeoutexception_ce); + php_phongo_executiontimeoutexception_ce = register_class_MongoDB_Driver_Exception_ExecutionTimeoutException(php_phongo_serverexception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/ExecutionTimeoutException.stub.php b/src/MongoDB/Exception/ExecutionTimeoutException.stub.php new file mode 100644 index 000000000..d1e67e5f0 --- /dev/null +++ b/src/MongoDB/Exception/ExecutionTimeoutException.stub.php @@ -0,0 +1,12 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Exception/InvalidArgumentException.c b/src/MongoDB/Exception/InvalidArgumentException.c index 515e30624..225d08364 100644 --- a/src/MongoDB/Exception/InvalidArgumentException.c +++ b/src/MongoDB/Exception/InvalidArgumentException.c @@ -18,20 +18,11 @@ #include #include "php_phongo.h" +#include "InvalidArgumentException_arginfo.h" zend_class_entry* php_phongo_invalidargumentexception_ce; -/* {{{ MongoDB\Driver\Exception\InvalidArgumentException function entries */ -static zend_function_entry php_phongo_invalidargumentexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_invalidargumentexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "InvalidArgumentException", php_phongo_invalidargumentexception_me); - php_phongo_invalidargumentexception_ce = zend_register_internal_class_ex(&ce, spl_ce_InvalidArgumentException); - zend_class_implements(php_phongo_invalidargumentexception_ce, 1, php_phongo_exception_ce); + php_phongo_invalidargumentexception_ce = register_class_MongoDB_Driver_Exception_InvalidArgumentException(spl_ce_InvalidArgumentException, php_phongo_exception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/InvalidArgumentException.stub.php b/src/MongoDB/Exception/InvalidArgumentException.stub.php new file mode 100644 index 000000000..510ae77fc --- /dev/null +++ b/src/MongoDB/Exception/InvalidArgumentException.stub.php @@ -0,0 +1,12 @@ + #include "php_phongo.h" +#include "LogicException_arginfo.h" zend_class_entry* php_phongo_logicexception_ce; -/* {{{ MongoDB\Driver\Exception\LogicException function entries */ -static zend_function_entry php_phongo_logicexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_logicexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "LogicException", php_phongo_logicexception_me); - php_phongo_logicexception_ce = zend_register_internal_class_ex(&ce, spl_ce_LogicException); - zend_class_implements(php_phongo_logicexception_ce, 1, php_phongo_exception_ce); + php_phongo_logicexception_ce = register_class_MongoDB_Driver_Exception_LogicException(spl_ce_LogicException, php_phongo_exception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/LogicException.stub.php b/src/MongoDB/Exception/LogicException.stub.php new file mode 100644 index 000000000..ace77cf1b --- /dev/null +++ b/src/MongoDB/Exception/LogicException.stub.php @@ -0,0 +1,12 @@ + #include "php_phongo.h" +#include "SSLConnectionException_arginfo.h" zend_class_entry* php_phongo_sslconnectionexception_ce; -/* {{{ MongoDB\Driver\Exception\SSLConnectionException function entries */ -static zend_function_entry php_phongo_sslconnectionexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_sslconnectionexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "SSLConnectionException", php_phongo_sslconnectionexception_me); - php_phongo_sslconnectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce); - PHONGO_CE_FINAL(php_phongo_sslconnectionexception_ce); + php_phongo_sslconnectionexception_ce = register_class_MongoDB_Driver_Exception_SSLConnectionException(php_phongo_connectionexception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/SSLConnectionException.stub.php b/src/MongoDB/Exception/SSLConnectionException.stub.php new file mode 100644 index 000000000..5401b8844 --- /dev/null +++ b/src/MongoDB/Exception/SSLConnectionException.stub.php @@ -0,0 +1,12 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Exception/ServerException.c b/src/MongoDB/Exception/ServerException.c index fdd5df603..c4500d1c8 100644 --- a/src/MongoDB/Exception/ServerException.c +++ b/src/MongoDB/Exception/ServerException.c @@ -17,19 +17,11 @@ #include #include "php_phongo.h" +#include "ServerException_arginfo.h" zend_class_entry* php_phongo_serverexception_ce; -/* {{{ MongoDB\Driver\Exception\ServerException function entries */ -static zend_function_entry php_phongo_serverexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_serverexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ServerException", php_phongo_serverexception_me); - php_phongo_serverexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce); + php_phongo_serverexception_ce = register_class_MongoDB_Driver_Exception_ServerException(php_phongo_runtimeexception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/ServerException.stub.php b/src/MongoDB/Exception/ServerException.stub.php new file mode 100644 index 000000000..46ca310a7 --- /dev/null +++ b/src/MongoDB/Exception/ServerException.stub.php @@ -0,0 +1,12 @@ + #include "php_phongo.h" +#include "UnexpectedValueException_arginfo.h" zend_class_entry* php_phongo_unexpectedvalueexception_ce; -/* {{{ MongoDB\Driver\Exception\UnexpectedValueException function entries */ -static zend_function_entry php_phongo_unexpectedvalueexception_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_unexpectedvalueexception_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "UnexpectedValueException", php_phongo_unexpectedvalueexception_me); - php_phongo_unexpectedvalueexception_ce = zend_register_internal_class_ex(&ce, spl_ce_UnexpectedValueException); - zend_class_implements(php_phongo_unexpectedvalueexception_ce, 1, php_phongo_exception_ce); + php_phongo_unexpectedvalueexception_ce = register_class_MongoDB_Driver_Exception_UnexpectedValueException(spl_ce_UnexpectedValueException, php_phongo_exception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/UnexpectedValueException.stub.php b/src/MongoDB/Exception/UnexpectedValueException.stub.php new file mode 100644 index 000000000..091b4f0d2 --- /dev/null +++ b/src/MongoDB/Exception/UnexpectedValueException.stub.php @@ -0,0 +1,12 @@ +ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; - - zend_declare_property_null(php_phongo_writeexception_ce, ZEND_STRL("writeResult"), ZEND_ACC_PROTECTED); + php_phongo_writeexception_ce = register_class_MongoDB_Driver_Exception_WriteException(php_phongo_serverexception_ce); } /* }}} */ diff --git a/src/MongoDB/Exception/WriteException.stub.php b/src/MongoDB/Exception/WriteException.stub.php new file mode 100644 index 000000000..dc95a78b2 --- /dev/null +++ b/src/MongoDB/Exception/WriteException.stub.php @@ -0,0 +1,16 @@ +ce_flags |= ZEND_ACC_ABSTRACT; + + zval property_writeResult_default_value; + ZVAL_NULL(&property_writeResult_default_value); + zend_string *property_writeResult_name = zend_string_init("writeResult", sizeof("writeResult") - 1, 1); + zend_declare_property_ex(class_entry, property_writeResult_name, &property_writeResult_default_value, ZEND_ACC_PROTECTED, NULL); + zend_string_release(property_writeResult_name); + + return class_entry; +} diff --git a/src/MongoDB/Manager.c b/src/MongoDB/Manager.c index e43bcef5e..b825a010e 100644 --- a/src/MongoDB/Manager.c +++ b/src/MongoDB/Manager.c @@ -36,6 +36,7 @@ #include "MongoDB/Server.h" #include "MongoDB/Session.h" #include "MongoDB/WriteConcern.h" +#include "Manager_arginfo.h" #define PHONGO_MANAGER_URI_DEFAULT "mongodb://127.0.0.1/" @@ -241,9 +242,11 @@ static bool php_phongo_manager_select_server(bool for_writes, bool inherit_read_ return false; } /* }}} */ +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Manager) + /* {{{ proto void MongoDB\Driver\Manager::__construct([string $uri = "mongodb://127.0.0.1/"[, array $options = array()[, array $driverOptions = array()]]]) Constructs a new Manager */ -static PHP_METHOD(Manager, __construct) +static PHP_METHOD(MongoDB_Driver_Manager, __construct) { php_phongo_manager_t* intern; char* uri_string = NULL; @@ -286,7 +289,7 @@ static PHP_METHOD(Manager, __construct) /* {{{ proto void MongoDB\Driver\Manager::addSubscriber(MongoDB\Driver\Monitoring\Subscriber $subscriber) Registers an event subscriber for this Manager */ -static PHP_METHOD(Manager, addSubscriber) +static PHP_METHOD(MongoDB_Driver_Manager, addSubscriber) { php_phongo_manager_t* intern; zval* subscriber; @@ -308,7 +311,7 @@ static PHP_METHOD(Manager, addSubscriber) /* {{{ proto MongoDB\Driver\ClientEncryption MongoDB\Driver\Manager::createClientEncryption(array $options) Return a ClientEncryption instance */ -static PHP_METHOD(Manager, createClientEncryption) +static PHP_METHOD(MongoDB_Driver_Manager, createClientEncryption) { zval* options; @@ -324,7 +327,7 @@ static PHP_METHOD(Manager, createClientEncryption) /* {{{ proto MongoDB\Driver\Cursor MongoDB\Driver\Manager::executeCommand(string $db, MongoDB\Driver\Command $command[, array $options = null]) Execute a Command */ -static PHP_METHOD(Manager, executeCommand) +static PHP_METHOD(MongoDB_Driver_Manager, executeCommand) { php_phongo_manager_t* intern; char* db; @@ -377,7 +380,7 @@ static PHP_METHOD(Manager, executeCommand) /* {{{ proto MongoDB\Driver\Cursor MongoDB\Driver\Manager::executeReadCommand(string $db, MongoDB\Driver\Command $command[, array $options = null]) Execute a ReadCommand */ -static PHP_METHOD(Manager, executeReadCommand) +static PHP_METHOD(MongoDB_Driver_Manager, executeReadCommand) { php_phongo_manager_t* intern; char* db; @@ -422,7 +425,7 @@ static PHP_METHOD(Manager, executeReadCommand) /* {{{ proto MongoDB\Driver\Cursor MongoDB\Driver\Manager::executeWriteCommand(string $db, MongoDB\Driver\Command $command[, array $options = null]) Execute a WriteCommand */ -static PHP_METHOD(Manager, executeWriteCommand) +static PHP_METHOD(MongoDB_Driver_Manager, executeWriteCommand) { php_phongo_manager_t* intern; char* db; @@ -461,7 +464,7 @@ static PHP_METHOD(Manager, executeWriteCommand) /* {{{ proto MongoDB\Driver\Cursor MongoDB\Driver\Manager::executeReadWriteCommand(string $db, MongoDB\Driver\Command $command[, array $options = null]) Execute a ReadWriteCommand */ -static PHP_METHOD(Manager, executeReadWriteCommand) +static PHP_METHOD(MongoDB_Driver_Manager, executeReadWriteCommand) { php_phongo_manager_t* intern; char* db; @@ -500,7 +503,7 @@ static PHP_METHOD(Manager, executeReadWriteCommand) /* {{{ proto MongoDB\Driver\Cursor MongoDB\Driver\Manager::executeQuery(string $namespace, MongoDB\Driver\Query $query[, array $options = null]) Execute a Query */ -static PHP_METHOD(Manager, executeQuery) +static PHP_METHOD(MongoDB_Driver_Manager, executeQuery) { php_phongo_manager_t* intern; char* namespace; @@ -553,7 +556,7 @@ static PHP_METHOD(Manager, executeQuery) /* {{{ proto MongoDB\Driver\WriteResult MongoDB\Driver\Manager::executeBulkWrite(string $namespace, MongoDB\Driver\BulkWrite $zbulk[, array $options = null]) Executes a BulkWrite (i.e. any number of insert, update, and delete ops) */ -static PHP_METHOD(Manager, executeBulkWrite) +static PHP_METHOD(MongoDB_Driver_Manager, executeBulkWrite) { php_phongo_manager_t* intern; char* namespace; @@ -601,7 +604,7 @@ static PHP_METHOD(Manager, executeBulkWrite) /* {{{ proto array|object|null MongoDB\Driver\Manager::getEncryptedFieldsMap() Returns the autoEncryption.encryptedFieldsMap driver option */ -static PHP_METHOD(Manager, getEncryptedFieldsMap) +static PHP_METHOD(MongoDB_Driver_Manager, getEncryptedFieldsMap) { php_phongo_manager_t* intern; @@ -616,7 +619,7 @@ static PHP_METHOD(Manager, getEncryptedFieldsMap) /* {{{ proto MongoDB\Driver\ReadConcern MongoDB\Driver\Manager::getReadConcern() Returns the ReadConcern associated with this Manager */ -static PHP_METHOD(Manager, getReadConcern) +static PHP_METHOD(MongoDB_Driver_Manager, getReadConcern) { php_phongo_manager_t* intern; @@ -629,7 +632,7 @@ static PHP_METHOD(Manager, getReadConcern) /* {{{ proto MongoDB\Driver\ReadPreference MongoDB\Driver\Manager::getReadPreference() Returns the ReadPreference associated with this Manager */ -static PHP_METHOD(Manager, getReadPreference) +static PHP_METHOD(MongoDB_Driver_Manager, getReadPreference) { php_phongo_manager_t* intern; @@ -642,7 +645,7 @@ static PHP_METHOD(Manager, getReadPreference) /* {{{ proto MongoDB\Driver\Server[] MongoDB\Driver\Manager::getServers() Returns the Servers associated with this Manager */ -static PHP_METHOD(Manager, getServers) +static PHP_METHOD(MongoDB_Driver_Manager, getServers) { php_phongo_manager_t* intern; mongoc_server_description_t** sds; @@ -667,7 +670,7 @@ static PHP_METHOD(Manager, getServers) /* {{{ proto MongoDB\Driver\WriteConcern MongoDB\Driver\Manager::getWriteConcern() Returns the WriteConcern associated with this Manager */ -static PHP_METHOD(Manager, getWriteConcern) +static PHP_METHOD(MongoDB_Driver_Manager, getWriteConcern) { php_phongo_manager_t* intern; @@ -680,7 +683,7 @@ static PHP_METHOD(Manager, getWriteConcern) /* {{{ proto void MongoDB\Driver\Manager::removeSubscriber(MongoDB\Driver\Monitoring\Subscriber $subscriber) Unregisters an event subscriber for this Manager */ -static PHP_METHOD(Manager, removeSubscriber) +static PHP_METHOD(MongoDB_Driver_Manager, removeSubscriber) { php_phongo_manager_t* intern; zval* subscriber; @@ -699,9 +702,9 @@ static PHP_METHOD(Manager, removeSubscriber) phongo_apm_remove_subscriber(intern->subscribers, subscriber); } /* }}} */ -/* {{{ proto MongoDB\Driver\Server MongoDB\Driver\Manager::selectServers([MongoDB\Driver\ReadPreference $readPreference = null]) +/* {{{ proto MongoDB\Driver\Server MongoDB\Driver\Manager::selectServer([MongoDB\Driver\ReadPreference $readPreference = null]) Selects a Server for the given ReadPreference (default: primary). */ -static PHP_METHOD(Manager, selectServer) +static PHP_METHOD(MongoDB_Driver_Manager, selectServer) { php_phongo_manager_t* intern; zval* zreadPreference = NULL; @@ -724,7 +727,7 @@ static PHP_METHOD(Manager, selectServer) /* {{{ proto MongoDB\Driver\Session MongoDB\Driver\Manager::startSession([array $options = null]) Returns a new client session */ -static PHP_METHOD(Manager, startSession) +static PHP_METHOD(MongoDB_Driver_Manager, startSession) { php_phongo_manager_t* intern; zval* options = NULL; @@ -808,85 +811,6 @@ static PHP_METHOD(Manager, startSession) } } /* }}} */ -/* {{{ MongoDB\Driver\Manager function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_Manager___construct, 0, 0, 0) - ZEND_ARG_INFO(0, uri) - ZEND_ARG_ARRAY_INFO(0, options, 0) - ZEND_ARG_ARRAY_INFO(0, driverOptions, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Manager_addSubscriber, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, subscriber, MongoDB\\Driver\\Monitoring\\Subscriber, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Manager_createClientEncryption, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, options, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeCommand, 0, 0, 2) - ZEND_ARG_INFO(0, db) - ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeRWCommand, 0, 0, 2) - ZEND_ARG_INFO(0, db) - ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) - ZEND_ARG_ARRAY_INFO(0, options, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeQuery, 0, 0, 2) - ZEND_ARG_INFO(0, namespace) - ZEND_ARG_OBJ_INFO(0, zquery, MongoDB\\Driver\\Query, 0) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeBulkWrite, 0, 0, 2) - ZEND_ARG_INFO(0, namespace) - ZEND_ARG_OBJ_INFO(0, zbulk, MongoDB\\Driver\\BulkWrite, 0) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Manager_removeSubscriber, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, subscriber, MongoDB\\Driver\\Monitoring\\Subscriber, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Manager_selectServer, 0, 0, 0) - ZEND_ARG_OBJ_INFO(0, readPreference, MongoDB\\Driver\\ReadPreference, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Manager_startSession, 0, 0, 0) - ZEND_ARG_ARRAY_INFO(0, options, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Manager_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_manager_me[] = { - /* clang-format off */ - PHP_ME(Manager, __construct, ai_Manager___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, addSubscriber, ai_Manager_addSubscriber, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, createClientEncryption, ai_Manager_createClientEncryption, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, executeCommand, ai_Manager_executeCommand, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, executeReadCommand, ai_Manager_executeRWCommand, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, executeWriteCommand, ai_Manager_executeRWCommand, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, executeReadWriteCommand, ai_Manager_executeCommand, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, executeQuery, ai_Manager_executeQuery, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, executeBulkWrite, ai_Manager_executeBulkWrite, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, getEncryptedFieldsMap, ai_Manager_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, getReadConcern, ai_Manager_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, getReadPreference, ai_Manager_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, getServers, ai_Manager_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, getWriteConcern, ai_Manager_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, removeSubscriber, ai_Manager_removeSubscriber, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, selectServer, ai_Manager_selectServer, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Manager, startSession, ai_Manager_startSession, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_Manager_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Manager object handlers */ static zend_object_handlers php_phongo_handler_manager; @@ -991,12 +915,8 @@ static HashTable* php_phongo_manager_get_debug_info(phongo_compat_object_handler void php_phongo_manager_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Manager", php_phongo_manager_me); - php_phongo_manager_ce = zend_register_internal_class(&ce); + php_phongo_manager_ce = register_class_MongoDB_Driver_Manager(); php_phongo_manager_ce->create_object = php_phongo_manager_create_object; - PHONGO_CE_FINAL(php_phongo_manager_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_manager_ce); memcpy(&php_phongo_handler_manager, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/Manager.stub.php b/src/MongoDB/Manager.stub.php new file mode 100644 index 000000000..3e7a5b2da --- /dev/null +++ b/src/MongoDB/Manager.stub.php @@ -0,0 +1,67 @@ += 80000 + final public function executeBulkWrite(string $namespace, BulkWrite $bulk, array|WriteConcern|null $options = null): WriteResult {} +#else + /** @param array|WriteConcern|null $options */ + final public function executeBulkWrite(string $namespace, BulkWrite $bulk, $options = null): WriteResult {} +#endif + +#if PHP_VERSION_ID >= 80000 + final public function executeCommand(string $db, Command $command, array|ReadPreference|null $options = null): Cursor {} +#else + /** @param array|ReadPreference|null $options */ + final public function executeCommand(string $db, Command $command, $options = null): Cursor {} +#endif + +#if PHP_VERSION_ID >= 80000 + final public function executeQuery(string $namespace, Query $query, array|ReadPreference|null $options = null): Cursor {} +#else + /** @param array|ReadPreference|null $options */ + final public function executeQuery(string $namespace, Query $query, $options = null): Cursor {} +#endif + + final public function executeReadCommand(string $db, Command $command, array $options = []): Cursor {} + + final public function executeReadWriteCommand(string $db, Command $command, array $options = []): Cursor {} + + final public function executeWriteCommand(string $db, Command $command, array $options = []): Cursor {} + +#if PHP_VERSION_ID >= 80000 + final public function getEncryptedFieldsMap(): array|object|null {} +#else + /** @return array|object|null */ + final public function getEncryptedFieldsMap() {} +#endif + + final public function getReadConcern(): ReadConcern {} + + final public function getReadPreference(): ReadPreference {} + + final public function getServers(): array {} + + final public function getWriteConcern(): WriteConcern {} + + final public function removeSubscriber(Monitoring\Subscriber $subscriber): void {} + + final public function selectServer(?ReadPreference $readPreference = null): Server {} + + final public function startSession(array $options = []): Session {} + + final public function __wakeup(): void {} +} diff --git a/src/MongoDB/Manager_arginfo.h b/src/MongoDB/Manager_arginfo.h new file mode 100644 index 000000000..759e59ab9 --- /dev/null +++ b/src/MongoDB/Manager_arginfo.h @@ -0,0 +1,203 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 516a26c70864397ba986d9855f4f876fe84bceb9 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Manager___construct, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, uri, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, uriOptions, IS_ARRAY, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, driverOptions, IS_ARRAY, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Manager_addSubscriber, 0, 1, IS_VOID, 0) + ZEND_ARG_OBJ_INFO(0, subscriber, MongoDB\\Driver\\Monitoring\\Subscriber, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_createClientEncryption, 0, 1, MongoDB\\Driver\\ClientEncryption, 0) + ZEND_ARG_TYPE_INFO(0, options, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_executeBulkWrite, 0, 2, MongoDB\\Driver\\WriteResult, 0) + ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, bulk, MongoDB\\Driver\\BulkWrite, 0) + ZEND_ARG_OBJ_TYPE_MASK(0, options, MongoDB\\Driver\\WriteConcern, MAY_BE_ARRAY|MAY_BE_NULL, "null") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_executeBulkWrite, 0, 2, MongoDB\\Driver\\WriteResult, 0) + ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, bulk, MongoDB\\Driver\\BulkWrite, 0) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, options, "null") +ZEND_END_ARG_INFO() +#endif + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_executeCommand, 0, 2, MongoDB\\Driver\\Cursor, 0) + ZEND_ARG_TYPE_INFO(0, db, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) + ZEND_ARG_OBJ_TYPE_MASK(0, options, MongoDB\\Driver\\ReadPreference, MAY_BE_ARRAY|MAY_BE_NULL, "null") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_executeCommand, 0, 2, MongoDB\\Driver\\Cursor, 0) + ZEND_ARG_TYPE_INFO(0, db, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, options, "null") +ZEND_END_ARG_INFO() +#endif + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_executeQuery, 0, 2, MongoDB\\Driver\\Cursor, 0) + ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, query, MongoDB\\Driver\\Query, 0) + ZEND_ARG_OBJ_TYPE_MASK(0, options, MongoDB\\Driver\\ReadPreference, MAY_BE_ARRAY|MAY_BE_NULL, "null") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_executeQuery, 0, 2, MongoDB\\Driver\\Cursor, 0) + ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, query, MongoDB\\Driver\\Query, 0) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, options, "null") +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_executeReadCommand, 0, 2, MongoDB\\Driver\\Cursor, 0) + ZEND_ARG_TYPE_INFO(0, db, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_Manager_executeReadWriteCommand arginfo_class_MongoDB_Driver_Manager_executeReadCommand + +#define arginfo_class_MongoDB_Driver_Manager_executeWriteCommand arginfo_class_MongoDB_Driver_Manager_executeReadCommand + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_Driver_Manager_getEncryptedFieldsMap, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_NULL) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Manager_getEncryptedFieldsMap, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_getReadConcern, 0, 0, MongoDB\\Driver\\ReadConcern, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_getReadPreference, 0, 0, MongoDB\\Driver\\ReadPreference, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Manager_getServers, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_getWriteConcern, 0, 0, MongoDB\\Driver\\WriteConcern, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_Manager_removeSubscriber arginfo_class_MongoDB_Driver_Manager_addSubscriber + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_selectServer, 0, 0, MongoDB\\Driver\\Server, 0) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, readPreference, MongoDB\\Driver\\ReadPreference, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_startSession, 0, 0, MongoDB\\Driver\\Session, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Manager___wakeup, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() + + +static ZEND_METHOD(MongoDB_Driver_Manager, __construct); +static ZEND_METHOD(MongoDB_Driver_Manager, addSubscriber); +static ZEND_METHOD(MongoDB_Driver_Manager, createClientEncryption); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Manager, executeBulkWrite); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Manager, executeBulkWrite); +#endif +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Manager, executeCommand); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Manager, executeCommand); +#endif +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Manager, executeQuery); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Manager, executeQuery); +#endif +static ZEND_METHOD(MongoDB_Driver_Manager, executeReadCommand); +static ZEND_METHOD(MongoDB_Driver_Manager, executeReadWriteCommand); +static ZEND_METHOD(MongoDB_Driver_Manager, executeWriteCommand); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Manager, getEncryptedFieldsMap); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Manager, getEncryptedFieldsMap); +#endif +static ZEND_METHOD(MongoDB_Driver_Manager, getReadConcern); +static ZEND_METHOD(MongoDB_Driver_Manager, getReadPreference); +static ZEND_METHOD(MongoDB_Driver_Manager, getServers); +static ZEND_METHOD(MongoDB_Driver_Manager, getWriteConcern); +static ZEND_METHOD(MongoDB_Driver_Manager, removeSubscriber); +static ZEND_METHOD(MongoDB_Driver_Manager, selectServer); +static ZEND_METHOD(MongoDB_Driver_Manager, startSession); +static ZEND_METHOD(MongoDB_Driver_Manager, __wakeup); + + +static const zend_function_entry class_MongoDB_Driver_Manager_methods[] = { + ZEND_ME(MongoDB_Driver_Manager, __construct, arginfo_class_MongoDB_Driver_Manager___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, addSubscriber, arginfo_class_MongoDB_Driver_Manager_addSubscriber, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, createClientEncryption, arginfo_class_MongoDB_Driver_Manager_createClientEncryption, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Manager, executeBulkWrite, arginfo_class_MongoDB_Driver_Manager_executeBulkWrite, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Manager, executeBulkWrite, arginfo_class_MongoDB_Driver_Manager_executeBulkWrite, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Manager, executeCommand, arginfo_class_MongoDB_Driver_Manager_executeCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Manager, executeCommand, arginfo_class_MongoDB_Driver_Manager_executeCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Manager, executeQuery, arginfo_class_MongoDB_Driver_Manager_executeQuery, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Manager, executeQuery, arginfo_class_MongoDB_Driver_Manager_executeQuery, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_Manager, executeReadCommand, arginfo_class_MongoDB_Driver_Manager_executeReadCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, executeReadWriteCommand, arginfo_class_MongoDB_Driver_Manager_executeReadWriteCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, executeWriteCommand, arginfo_class_MongoDB_Driver_Manager_executeWriteCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Manager, getEncryptedFieldsMap, arginfo_class_MongoDB_Driver_Manager_getEncryptedFieldsMap, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Manager, getEncryptedFieldsMap, arginfo_class_MongoDB_Driver_Manager_getEncryptedFieldsMap, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_Manager, getReadConcern, arginfo_class_MongoDB_Driver_Manager_getReadConcern, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, getReadPreference, arginfo_class_MongoDB_Driver_Manager_getReadPreference, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, getServers, arginfo_class_MongoDB_Driver_Manager_getServers, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, getWriteConcern, arginfo_class_MongoDB_Driver_Manager_getWriteConcern, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, removeSubscriber, arginfo_class_MongoDB_Driver_Manager_removeSubscriber, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, selectServer, arginfo_class_MongoDB_Driver_Manager_selectServer, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, startSession, arginfo_class_MongoDB_Driver_Manager_startSession, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Manager, __wakeup, arginfo_class_MongoDB_Driver_Manager___wakeup, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_Manager(void) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Manager", class_MongoDB_Driver_Manager_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/CommandFailedEvent.c b/src/MongoDB/Monitoring/CommandFailedEvent.c index 117b7e0bf..5a11d6e88 100644 --- a/src/MongoDB/Monitoring/CommandFailedEvent.c +++ b/src/MongoDB/Monitoring/CommandFailedEvent.c @@ -25,12 +25,16 @@ #include "BSON/ObjectId.h" #include "MongoDB/Server.h" +#include "CommandFailedEvent_arginfo.h" zend_class_entry* php_phongo_commandfailedevent_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_CommandFailedEvent) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Monitoring_CommandFailedEvent) + /* {{{ proto string CommandFailedEvent::getCommandName() Returns the command name for this event */ -PHP_METHOD(CommandFailedEvent, getCommandName) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getCommandName) { php_phongo_commandfailedevent_t* intern; @@ -43,7 +47,7 @@ PHP_METHOD(CommandFailedEvent, getCommandName) /* {{{ proto int CommandFailedEvent::getDurationMicros() Returns the event's duration in microseconds */ -PHP_METHOD(CommandFailedEvent, getDurationMicros) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDurationMicros) { php_phongo_commandfailedevent_t* intern; @@ -56,7 +60,7 @@ PHP_METHOD(CommandFailedEvent, getDurationMicros) /* {{{ proto Exception CommandFailedEvent::getError() Returns the error document associated with the event */ -PHP_METHOD(CommandFailedEvent, getError) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getError) { php_phongo_commandfailedevent_t* intern; @@ -69,7 +73,7 @@ PHP_METHOD(CommandFailedEvent, getError) /* {{{ proto string CommandFailedEvent::getOperationId() Returns the event's operation ID */ -PHP_METHOD(CommandFailedEvent, getOperationId) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getOperationId) { php_phongo_commandfailedevent_t* intern; char int_as_string[20]; @@ -84,7 +88,7 @@ PHP_METHOD(CommandFailedEvent, getOperationId) /* {{{ proto stdClass CommandFailedEvent::getReply() Returns the reply document associated with the event */ -PHP_METHOD(CommandFailedEvent, getReply) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getReply) { php_phongo_commandfailedevent_t* intern; php_phongo_bson_state state; @@ -105,7 +109,7 @@ PHP_METHOD(CommandFailedEvent, getReply) /* {{{ proto string CommandFailedEvent::getRequestId() Returns the event's request ID */ -PHP_METHOD(CommandFailedEvent, getRequestId) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getRequestId) { php_phongo_commandfailedevent_t* intern; char int_as_string[20]; @@ -120,7 +124,7 @@ PHP_METHOD(CommandFailedEvent, getRequestId) /* {{{ proto MongoDB\Driver\Server CommandFailedEvent::getServer() Returns the Server from which the event originated */ -PHP_METHOD(CommandFailedEvent, getServer) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServer) { php_phongo_commandfailedevent_t* intern; @@ -133,7 +137,7 @@ PHP_METHOD(CommandFailedEvent, getServer) /* {{{ proto MongoDB\BSON\ObjectId|null CommandFailedEvent::getServiceId() Returns the event's service ID */ -PHP_METHOD(CommandFailedEvent, getServiceId) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServiceId) { php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis()); @@ -148,7 +152,7 @@ PHP_METHOD(CommandFailedEvent, getServiceId) /* {{{ proto int|null CommandFailedEvent::getServerConnectionId() Returns the event's server connection ID */ -PHP_METHOD(CommandFailedEvent, getServerConnectionId) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServerConnectionId) { php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis()); @@ -168,28 +172,6 @@ PHP_METHOD(CommandFailedEvent, getServerConnectionId) * This class is only constructed internally. */ -/* {{{ MongoDB\Driver\Monitoring\CommandFailedEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_CommandFailedEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_commandfailedevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_CommandFailedEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(CommandFailedEvent, getCommandName, ai_CommandFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandFailedEvent, getError, ai_CommandFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandFailedEvent, getDurationMicros, ai_CommandFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandFailedEvent, getOperationId, ai_CommandFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandFailedEvent, getReply, ai_CommandFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandFailedEvent, getRequestId, ai_CommandFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandFailedEvent, getServer, ai_CommandFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandFailedEvent, getServiceId, ai_CommandFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandFailedEvent, getServerConnectionId, ai_CommandFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_CommandFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\CommandFailedEvent object handlers */ static zend_object_handlers php_phongo_handler_commandfailedevent; @@ -290,14 +272,8 @@ static HashTable* php_phongo_commandfailedevent_get_debug_info(phongo_compat_obj void php_phongo_commandfailedevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "CommandFailedEvent", php_phongo_commandfailedevent_me); - php_phongo_commandfailedevent_ce = zend_register_internal_class(&ce); + php_phongo_commandfailedevent_ce = register_class_MongoDB_Driver_Monitoring_CommandFailedEvent(); php_phongo_commandfailedevent_ce->create_object = php_phongo_commandfailedevent_create_object; - PHONGO_CE_FINAL(php_phongo_commandfailedevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_commandfailedevent_ce); memcpy(&php_phongo_handler_commandfailedevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/Monitoring/CommandFailedEvent.stub.php b/src/MongoDB/Monitoring/CommandFailedEvent.stub.php new file mode 100644 index 000000000..56422072b --- /dev/null +++ b/src/MongoDB/Monitoring/CommandFailedEvent.stub.php @@ -0,0 +1,33 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/CommandStartedEvent.c b/src/MongoDB/Monitoring/CommandStartedEvent.c index 18f7c6896..9a568450a 100644 --- a/src/MongoDB/Monitoring/CommandStartedEvent.c +++ b/src/MongoDB/Monitoring/CommandStartedEvent.c @@ -25,12 +25,16 @@ #include "BSON/ObjectId.h" #include "MongoDB/Server.h" +#include "CommandStartedEvent_arginfo.h" zend_class_entry* php_phongo_commandstartedevent_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_CommandStartedEvent) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Monitoring_CommandStartedEvent) + /* {{{ proto stdClass CommandStartedEvent::getCommand() Returns the command document associated with the event */ -PHP_METHOD(CommandStartedEvent, getCommand) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getCommand) { php_phongo_commandstartedevent_t* intern; php_phongo_bson_state state; @@ -51,7 +55,7 @@ PHP_METHOD(CommandStartedEvent, getCommand) /* {{{ proto string CommandStartedEvent::getCommandName() Returns the command name for this event */ -PHP_METHOD(CommandStartedEvent, getCommandName) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getCommandName) { php_phongo_commandstartedevent_t* intern; @@ -64,7 +68,7 @@ PHP_METHOD(CommandStartedEvent, getCommandName) /* {{{ proto string CommandStartedEvent::getDatabaseName() Returns the database name for this event */ -PHP_METHOD(CommandStartedEvent, getDatabaseName) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getDatabaseName) { php_phongo_commandstartedevent_t* intern; @@ -77,7 +81,7 @@ PHP_METHOD(CommandStartedEvent, getDatabaseName) /* {{{ proto string CommandStartedEvent::getOperationId() Returns the event's operation ID */ -PHP_METHOD(CommandStartedEvent, getOperationId) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getOperationId) { php_phongo_commandstartedevent_t* intern; char int_as_string[20]; @@ -92,7 +96,7 @@ PHP_METHOD(CommandStartedEvent, getOperationId) /* {{{ proto string CommandStartedEvent::getRequestId() Returns the event's request ID */ -PHP_METHOD(CommandStartedEvent, getRequestId) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getRequestId) { php_phongo_commandstartedevent_t* intern; char int_as_string[20]; @@ -107,7 +111,7 @@ PHP_METHOD(CommandStartedEvent, getRequestId) /* {{{ proto MongoDB\Driver\Server CommandStartedEvent::getServer() Returns the Server from which the event originated */ -PHP_METHOD(CommandStartedEvent, getServer) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServer) { php_phongo_commandstartedevent_t* intern; @@ -120,7 +124,7 @@ PHP_METHOD(CommandStartedEvent, getServer) /* {{{ proto MongoDB\BSON\ObjectId|null CommandStartedEvent::getServiceId() Returns the event's service ID */ -PHP_METHOD(CommandStartedEvent, getServiceId) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServiceId) { php_phongo_commandstartedevent_t* intern = Z_COMMANDSTARTEDEVENT_OBJ_P(getThis()); @@ -135,7 +139,7 @@ PHP_METHOD(CommandStartedEvent, getServiceId) /* {{{ proto int|null CommandStartedEvent::getServerConnectionId() Returns the event's server connection ID */ -PHP_METHOD(CommandStartedEvent, getServerConnectionId) +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServerConnectionId) { php_phongo_commandstartedevent_t* intern = Z_COMMANDSTARTEDEVENT_OBJ_P(getThis()); @@ -155,27 +159,6 @@ PHP_METHOD(CommandStartedEvent, getServerConnectionId) * This class is only constructed internally. */ -/* {{{ MongoDB\Driver\Monitoring\CommandStartedEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_CommandStartedEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_commandstartedevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_CommandStartedEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(CommandStartedEvent, getCommand, ai_CommandStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandStartedEvent, getCommandName, ai_CommandStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandStartedEvent, getDatabaseName, ai_CommandStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandStartedEvent, getOperationId, ai_CommandStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandStartedEvent, getRequestId, ai_CommandStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandStartedEvent, getServer, ai_CommandStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandStartedEvent, getServiceId, ai_CommandStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(CommandStartedEvent, getServerConnectionId, ai_CommandStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_CommandStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\CommandStartedEvent object handlers */ static zend_object_handlers php_phongo_handler_commandstartedevent; @@ -273,20 +256,12 @@ static HashTable* php_phongo_commandstartedevent_get_debug_info(phongo_compat_ob void php_phongo_commandstartedevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "CommandStartedEvent", php_phongo_commandstartedevent_me); - php_phongo_commandstartedevent_ce = zend_register_internal_class(&ce); + php_phongo_commandstartedevent_ce = register_class_MongoDB_Driver_Monitoring_CommandStartedEvent(); php_phongo_commandstartedevent_ce->create_object = php_phongo_commandstartedevent_create_object; - PHONGO_CE_FINAL(php_phongo_commandstartedevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_commandstartedevent_ce); memcpy(&php_phongo_handler_commandstartedevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_commandstartedevent.get_debug_info = php_phongo_commandstartedevent_get_debug_info; php_phongo_handler_commandstartedevent.free_obj = php_phongo_commandstartedevent_free_object; php_phongo_handler_commandstartedevent.offset = XtOffsetOf(php_phongo_commandstartedevent_t, std); - - return; } /* }}} */ diff --git a/src/MongoDB/Monitoring/CommandStartedEvent.stub.php b/src/MongoDB/Monitoring/CommandStartedEvent.stub.php new file mode 100644 index 000000000..c0f796eaf --- /dev/null +++ b/src/MongoDB/Monitoring/CommandStartedEvent.stub.php @@ -0,0 +1,31 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/CommandSubscriber.c b/src/MongoDB/Monitoring/CommandSubscriber.c index 34d02eaa4..aaae6b469 100644 --- a/src/MongoDB/Monitoring/CommandSubscriber.c +++ b/src/MongoDB/Monitoring/CommandSubscriber.c @@ -17,41 +17,11 @@ #include #include "php_phongo.h" +#include "CommandSubscriber_arginfo.h" zend_class_entry* php_phongo_commandsubscriber_ce; -/* {{{ MongoDB\Driver\Monitoring\CommandSubscriber function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_CommandSubscriber_commandStarted, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\CommandStartedEvent, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_CommandSubscriber_commandSucceeded, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\CommandSucceededEvent, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_CommandSubscriber_commandFailed, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\CommandFailedEvent, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_commandsubscriber_me[] = { - /* clang-format off */ - ZEND_ABSTRACT_ME(CommandSubscriber, commandStarted, ai_CommandSubscriber_commandStarted) - ZEND_ABSTRACT_ME(CommandSubscriber, commandSucceeded, ai_CommandSubscriber_commandSucceeded) - ZEND_ABSTRACT_ME(CommandSubscriber, commandFailed, ai_CommandSubscriber_commandFailed) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - void php_phongo_commandsubscriber_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "CommandSubscriber", php_phongo_commandsubscriber_me); - php_phongo_commandsubscriber_ce = zend_register_internal_interface(&ce); - zend_class_implements(php_phongo_commandsubscriber_ce, 1, php_phongo_subscriber_ce); - - return; + php_phongo_commandsubscriber_ce = register_class_MongoDB_Driver_Monitoring_CommandSubscriber(php_phongo_subscriber_ce); } /* }}} */ diff --git a/src/MongoDB/Monitoring/CommandSubscriber.stub.php b/src/MongoDB/Monitoring/CommandSubscriber.stub.php new file mode 100644 index 000000000..587783241 --- /dev/null +++ b/src/MongoDB/Monitoring/CommandSubscriber.stub.php @@ -0,0 +1,20 @@ +create_object = php_phongo_commandsucceededevent_create_object; - PHONGO_CE_FINAL(php_phongo_commandsucceededevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_commandsucceededevent_ce); memcpy(&php_phongo_handler_commandsucceededevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_commandsucceededevent.get_debug_info = php_phongo_commandsucceededevent_get_debug_info; php_phongo_handler_commandsucceededevent.free_obj = php_phongo_commandsucceededevent_free_object; php_phongo_handler_commandsucceededevent.offset = XtOffsetOf(php_phongo_commandsucceededevent_t, std); - - return; } /* }}} */ diff --git a/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php b/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php new file mode 100644 index 000000000..a144392c6 --- /dev/null +++ b/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php @@ -0,0 +1,31 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/SDAMSubscriber.c b/src/MongoDB/Monitoring/SDAMSubscriber.c index a2e2cba9f..cccf2d0b7 100644 --- a/src/MongoDB/Monitoring/SDAMSubscriber.c +++ b/src/MongoDB/Monitoring/SDAMSubscriber.c @@ -17,71 +17,11 @@ #include #include "php_phongo.h" +#include "SDAMSubscriber_arginfo.h" zend_class_entry* php_phongo_sdamsubscriber_ce; -/* {{{ MongoDB\Driver\Monitoring\SDAMSubscriber function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_SDAMSubscriber_serverChanged, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\ServerChangedEvent, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_SDAMSubscriber_serverClosed, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\ServerClosedEvent, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_SDAMSubscriber_serverOpening, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\ServerOpeningEvent, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_SDAMSubscriber_serverHeartbeatFailed, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\ServerHeartbeatFailedEvent, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_SDAMSubscriber_serverHeartbeatStarted, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\ServerHeartbeatStartedEvent, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_SDAMSubscriber_serverHeartbeatSucceeded, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\ServerHeartbeatSucceededEvent, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_SDAMSubscriber_topologyChanged, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\TopologyChangedEvent, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_SDAMSubscriber_topologyClosed, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\TopologyClosedEvent, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_SDAMSubscriber_topologyOpening, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, event, MongoDB\\Driver\\Monitoring\\TopologyOpeningEvent, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_sdamsubscriber_me[] = { - /* clang-format off */ - ZEND_ABSTRACT_ME(SDAMSubscriber, serverChanged, ai_SDAMSubscriber_serverChanged) - ZEND_ABSTRACT_ME(SDAMSubscriber, serverClosed, ai_SDAMSubscriber_serverClosed) - ZEND_ABSTRACT_ME(SDAMSubscriber, serverOpening, ai_SDAMSubscriber_serverOpening) - ZEND_ABSTRACT_ME(SDAMSubscriber, serverHeartbeatFailed, ai_SDAMSubscriber_serverHeartbeatFailed) - ZEND_ABSTRACT_ME(SDAMSubscriber, serverHeartbeatStarted, ai_SDAMSubscriber_serverHeartbeatStarted) - ZEND_ABSTRACT_ME(SDAMSubscriber, serverHeartbeatSucceeded, ai_SDAMSubscriber_serverHeartbeatSucceeded) - ZEND_ABSTRACT_ME(SDAMSubscriber, topologyChanged, ai_SDAMSubscriber_topologyChanged) - ZEND_ABSTRACT_ME(SDAMSubscriber, topologyClosed, ai_SDAMSubscriber_topologyClosed) - ZEND_ABSTRACT_ME(SDAMSubscriber, topologyOpening, ai_SDAMSubscriber_topologyOpening) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - void php_phongo_sdamsubscriber_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "SDAMSubscriber", php_phongo_sdamsubscriber_me); - php_phongo_sdamsubscriber_ce = zend_register_internal_interface(&ce); - zend_class_implements(php_phongo_sdamsubscriber_ce, 1, php_phongo_subscriber_ce); - - return; + php_phongo_sdamsubscriber_ce = register_class_MongoDB_Driver_Monitoring_SDAMSubscriber(php_phongo_subscriber_ce); } /* }}} */ diff --git a/src/MongoDB/Monitoring/SDAMSubscriber.stub.php b/src/MongoDB/Monitoring/SDAMSubscriber.stub.php new file mode 100644 index 000000000..ab4dfa492 --- /dev/null +++ b/src/MongoDB/Monitoring/SDAMSubscriber.stub.php @@ -0,0 +1,38 @@ +topology_id); } /* }}} */ -/* {{{ MongoDB\Driver\Monitoring\ServerChangedEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_ServerChangedEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_serverchangedevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_ServerChangedEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(ServerChangedEvent, getHost, ai_ServerChangedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerChangedEvent, getPort, ai_ServerChangedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerChangedEvent, getNewDescription, ai_ServerChangedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerChangedEvent, getPreviousDescription, ai_ServerChangedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerChangedEvent, getTopologyId, ai_ServerChangedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_ServerChangedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\ServerChangedEvent object handlers */ static zend_object_handlers php_phongo_handler_serverchangedevent; @@ -167,20 +153,12 @@ static HashTable* php_phongo_serverchangedevent_get_debug_info(phongo_compat_obj void php_phongo_serverchangedevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "ServerChangedEvent", php_phongo_serverchangedevent_me); - php_phongo_serverchangedevent_ce = zend_register_internal_class(&ce); + php_phongo_serverchangedevent_ce = register_class_MongoDB_Driver_Monitoring_ServerChangedEvent(); php_phongo_serverchangedevent_ce->create_object = php_phongo_serverchangedevent_create_object; - PHONGO_CE_FINAL(php_phongo_serverchangedevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_serverchangedevent_ce); memcpy(&php_phongo_handler_serverchangedevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_serverchangedevent.get_debug_info = php_phongo_serverchangedevent_get_debug_info; php_phongo_handler_serverchangedevent.free_obj = php_phongo_serverchangedevent_free_object; php_phongo_handler_serverchangedevent.offset = XtOffsetOf(php_phongo_serverchangedevent_t, std); - - return; } /* }}} */ diff --git a/src/MongoDB/Monitoring/ServerChangedEvent.stub.php b/src/MongoDB/Monitoring/ServerChangedEvent.stub.php new file mode 100644 index 000000000..681db7e94 --- /dev/null +++ b/src/MongoDB/Monitoring/ServerChangedEvent.stub.php @@ -0,0 +1,25 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/ServerClosedEvent.c b/src/MongoDB/Monitoring/ServerClosedEvent.c index 132660c57..f391108c5 100644 --- a/src/MongoDB/Monitoring/ServerClosedEvent.c +++ b/src/MongoDB/Monitoring/ServerClosedEvent.c @@ -21,12 +21,16 @@ #include "phongo_error.h" #include "BSON/ObjectId.h" +#include "ServerClosedEvent_arginfo.h" zend_class_entry* php_phongo_serverclosedevent_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_ServerClosedEvent) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Monitoring_ServerClosedEvent) + /* {{{ proto string ServerClosedEvent::getHost() Returns this event's host */ -static PHP_METHOD(ServerClosedEvent, getHost) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerClosedEvent, getHost) { php_phongo_serverclosedevent_t* intern = Z_SERVERCLOSEDEVENT_OBJ_P(getThis()); @@ -37,7 +41,7 @@ static PHP_METHOD(ServerClosedEvent, getHost) /* {{{ proto integer ServerClosedEvent::getPort() Returns this event's port */ -static PHP_METHOD(ServerClosedEvent, getPort) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerClosedEvent, getPort) { php_phongo_serverclosedevent_t* intern = Z_SERVERCLOSEDEVENT_OBJ_P(getThis()); @@ -48,7 +52,7 @@ static PHP_METHOD(ServerClosedEvent, getPort) /* {{{ proto MongoDB\BSON\ObjectId ServerClosedEvent::getTopologyId() Returns this event's topology id */ -static PHP_METHOD(ServerClosedEvent, getTopologyId) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerClosedEvent, getTopologyId) { php_phongo_serverclosedevent_t* intern = Z_SERVERCLOSEDEVENT_OBJ_P(getThis()); @@ -57,22 +61,6 @@ static PHP_METHOD(ServerClosedEvent, getTopologyId) phongo_objectid_init(return_value, &intern->topology_id); } /* }}} */ -/* {{{ MongoDB\Driver\Monitoring\ServerClosedEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_ServerClosedEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_serverclosedevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_ServerClosedEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(ServerClosedEvent, getHost, ai_ServerClosedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerClosedEvent, getPort, ai_ServerClosedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerClosedEvent, getTopologyId, ai_ServerClosedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_ServerClosedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\ServerClosedEvent object handlers */ static zend_object_handlers php_phongo_handler_serverclosedevent; @@ -119,20 +107,12 @@ static HashTable* php_phongo_serverclosedevent_get_debug_info(phongo_compat_obje void php_phongo_serverclosedevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "ServerClosedEvent", php_phongo_serverclosedevent_me); - php_phongo_serverclosedevent_ce = zend_register_internal_class(&ce); + php_phongo_serverclosedevent_ce = register_class_MongoDB_Driver_Monitoring_ServerClosedEvent(); php_phongo_serverclosedevent_ce->create_object = php_phongo_serverclosedevent_create_object; - PHONGO_CE_FINAL(php_phongo_serverclosedevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_serverclosedevent_ce); memcpy(&php_phongo_handler_serverclosedevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_serverclosedevent.get_debug_info = php_phongo_serverclosedevent_get_debug_info; php_phongo_handler_serverclosedevent.free_obj = php_phongo_serverclosedevent_free_object; php_phongo_handler_serverclosedevent.offset = XtOffsetOf(php_phongo_serverclosedevent_t, std); - - return; } /* }}} */ diff --git a/src/MongoDB/Monitoring/ServerClosedEvent.stub.php b/src/MongoDB/Monitoring/ServerClosedEvent.stub.php new file mode 100644 index 000000000..7065b21cc --- /dev/null +++ b/src/MongoDB/Monitoring/ServerClosedEvent.stub.php @@ -0,0 +1,21 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/ServerHeartbeatFailedEvent.c b/src/MongoDB/Monitoring/ServerHeartbeatFailedEvent.c index 7339839a1..ebacff2be 100644 --- a/src/MongoDB/Monitoring/ServerHeartbeatFailedEvent.c +++ b/src/MongoDB/Monitoring/ServerHeartbeatFailedEvent.c @@ -19,12 +19,16 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "ServerHeartbeatFailedEvent_arginfo.h" zend_class_entry* php_phongo_serverheartbeatfailedevent_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_ServerHeartbeatFailedEvent) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Monitoring_ServerHeartbeatFailedEvent) + /* {{{ proto integer ServerHeartbeatFailedEvent::getDurationMicros() Returns this event's duration in microseconds */ -static PHP_METHOD(ServerHeartbeatFailedEvent, getDurationMicros) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatFailedEvent, getDurationMicros) { php_phongo_serverheartbeatfailedevent_t* intern = Z_SERVERHEARTBEATFAILEDEVENT_OBJ_P(getThis()); @@ -35,7 +39,7 @@ static PHP_METHOD(ServerHeartbeatFailedEvent, getDurationMicros) /* {{{ proto Exception ServerHeartbeatFailedEvent::getError() Returns the error associated with the event */ -PHP_METHOD(ServerHeartbeatFailedEvent, getError) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatFailedEvent, getError) { php_phongo_serverheartbeatfailedevent_t* intern = Z_SERVERHEARTBEATFAILEDEVENT_OBJ_P(getThis()); @@ -46,7 +50,7 @@ PHP_METHOD(ServerHeartbeatFailedEvent, getError) /* {{{ proto string ServerHeartbeatFailedEvent::getHost() Returns this event's host */ -static PHP_METHOD(ServerHeartbeatFailedEvent, getHost) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatFailedEvent, getHost) { php_phongo_serverheartbeatfailedevent_t* intern = Z_SERVERHEARTBEATFAILEDEVENT_OBJ_P(getThis()); @@ -57,7 +61,7 @@ static PHP_METHOD(ServerHeartbeatFailedEvent, getHost) /* {{{ proto integer ServerHeartbeatFailedEvent::getPort() Returns this event's port */ -static PHP_METHOD(ServerHeartbeatFailedEvent, getPort) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatFailedEvent, getPort) { php_phongo_serverheartbeatfailedevent_t* intern = Z_SERVERHEARTBEATFAILEDEVENT_OBJ_P(getThis()); @@ -68,7 +72,7 @@ static PHP_METHOD(ServerHeartbeatFailedEvent, getPort) /* {{{ proto boolean ServerHeartbeatFailedEvent::isAwaited() Returns whether this event came from an awaitable hello */ -static PHP_METHOD(ServerHeartbeatFailedEvent, isAwaited) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatFailedEvent, isAwaited) { php_phongo_serverheartbeatfailedevent_t* intern = Z_SERVERHEARTBEATFAILEDEVENT_OBJ_P(getThis()); @@ -77,24 +81,6 @@ static PHP_METHOD(ServerHeartbeatFailedEvent, isAwaited) RETVAL_BOOL(intern->awaited); } /* }}} */ -/* {{{ MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_ServerHeartbeatFailedEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_serverheartbeatfailedevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_ServerHeartbeatFailedEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatFailedEvent, getDurationMicros, ai_ServerHeartbeatFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatFailedEvent, getError, ai_ServerHeartbeatFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatFailedEvent, getHost, ai_ServerHeartbeatFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatFailedEvent, getPort, ai_ServerHeartbeatFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatFailedEvent, isAwaited, ai_ServerHeartbeatFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_ServerHeartbeatFailedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent object handlers */ static zend_object_handlers php_phongo_handler_serverheartbeatfailedevent; @@ -144,20 +130,12 @@ static HashTable* php_phongo_serverheartbeatfailedevent_get_debug_info(phongo_co void php_phongo_serverheartbeatfailedevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "ServerHeartbeatFailedEvent", php_phongo_serverheartbeatfailedevent_me); - php_phongo_serverheartbeatfailedevent_ce = zend_register_internal_class(&ce); + php_phongo_serverheartbeatfailedevent_ce = register_class_MongoDB_Driver_Monitoring_ServerHeartbeatFailedEvent(); php_phongo_serverheartbeatfailedevent_ce->create_object = php_phongo_serverheartbeatfailedevent_create_object; - PHONGO_CE_FINAL(php_phongo_serverheartbeatfailedevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_serverheartbeatfailedevent_ce); memcpy(&php_phongo_handler_serverheartbeatfailedevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_serverheartbeatfailedevent.get_debug_info = php_phongo_serverheartbeatfailedevent_get_debug_info; php_phongo_handler_serverheartbeatfailedevent.free_obj = php_phongo_serverheartbeatfailedevent_free_object; php_phongo_handler_serverheartbeatfailedevent.offset = XtOffsetOf(php_phongo_serverheartbeatfailedevent_t, std); - - return; } /* }}} */ diff --git a/src/MongoDB/Monitoring/ServerHeartbeatFailedEvent.stub.php b/src/MongoDB/Monitoring/ServerHeartbeatFailedEvent.stub.php new file mode 100644 index 000000000..ddda55609 --- /dev/null +++ b/src/MongoDB/Monitoring/ServerHeartbeatFailedEvent.stub.php @@ -0,0 +1,25 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/ServerHeartbeatStartedEvent.c b/src/MongoDB/Monitoring/ServerHeartbeatStartedEvent.c index b2de5c86b..488c9a959 100644 --- a/src/MongoDB/Monitoring/ServerHeartbeatStartedEvent.c +++ b/src/MongoDB/Monitoring/ServerHeartbeatStartedEvent.c @@ -19,12 +19,16 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "ServerHeartbeatStartedEvent_arginfo.h" zend_class_entry* php_phongo_serverheartbeatstartedevent_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_ServerHeartbeatStartedEvent) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Monitoring_ServerHeartbeatStartedEvent) + /* {{{ proto string ServerHeartbeatStartedEvent::getHost() Returns this event's host */ -static PHP_METHOD(ServerHeartbeatStartedEvent, getHost) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatStartedEvent, getHost) { php_phongo_serverheartbeatstartedevent_t* intern = Z_SERVERHEARTBEATSTARTEDEVENT_OBJ_P(getThis()); @@ -35,7 +39,7 @@ static PHP_METHOD(ServerHeartbeatStartedEvent, getHost) /* {{{ proto integer ServerHeartbeatStartedEvent::getPort() Returns this event's port */ -static PHP_METHOD(ServerHeartbeatStartedEvent, getPort) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatStartedEvent, getPort) { php_phongo_serverheartbeatstartedevent_t* intern = Z_SERVERHEARTBEATSTARTEDEVENT_OBJ_P(getThis()); @@ -46,7 +50,7 @@ static PHP_METHOD(ServerHeartbeatStartedEvent, getPort) /* {{{ proto boolean ServerHeartbeatStartedEvent::isAwaited() Returns whether this event came from an awaitable hello */ -static PHP_METHOD(ServerHeartbeatStartedEvent, isAwaited) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatStartedEvent, isAwaited) { php_phongo_serverheartbeatstartedevent_t* intern = Z_SERVERHEARTBEATSTARTEDEVENT_OBJ_P(getThis()); @@ -55,22 +59,6 @@ static PHP_METHOD(ServerHeartbeatStartedEvent, isAwaited) RETVAL_BOOL(intern->awaited); } /* }}} */ -/* {{{ MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_ServerHeartbeatStartedEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_serverheartbeatstartedevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_ServerHeartbeatStartedEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatStartedEvent, getHost, ai_ServerHeartbeatStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatStartedEvent, getPort, ai_ServerHeartbeatStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatStartedEvent, isAwaited, ai_ServerHeartbeatStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_ServerHeartbeatStartedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent object handlers */ static zend_object_handlers php_phongo_handler_serverheartbeatstartedevent; @@ -112,14 +100,8 @@ static HashTable* php_phongo_serverheartbeatstartedevent_get_debug_info(phongo_c void php_phongo_serverheartbeatstartedevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "ServerHeartbeatStartedEvent", php_phongo_serverheartbeatstartedevent_me); - php_phongo_serverheartbeatstartedevent_ce = zend_register_internal_class(&ce); + php_phongo_serverheartbeatstartedevent_ce = register_class_MongoDB_Driver_Monitoring_ServerHeartbeatStartedEvent(); php_phongo_serverheartbeatstartedevent_ce->create_object = php_phongo_serverheartbeatstartedevent_create_object; - PHONGO_CE_FINAL(php_phongo_serverheartbeatstartedevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_serverheartbeatstartedevent_ce); memcpy(&php_phongo_handler_serverheartbeatstartedevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/Monitoring/ServerHeartbeatStartedEvent.stub.php b/src/MongoDB/Monitoring/ServerHeartbeatStartedEvent.stub.php new file mode 100644 index 000000000..0ab363b91 --- /dev/null +++ b/src/MongoDB/Monitoring/ServerHeartbeatStartedEvent.stub.php @@ -0,0 +1,21 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/ServerHeartbeatSucceededEvent.c b/src/MongoDB/Monitoring/ServerHeartbeatSucceededEvent.c index 405392a58..182d82085 100644 --- a/src/MongoDB/Monitoring/ServerHeartbeatSucceededEvent.c +++ b/src/MongoDB/Monitoring/ServerHeartbeatSucceededEvent.c @@ -19,12 +19,16 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "ServerHeartbeatSucceededEvent_arginfo.h" zend_class_entry* php_phongo_serverheartbeatsucceededevent_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_ServerHeartbeatSucceededEvent) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Monitoring_ServerHeartbeatSucceededEvent) + /* {{{ proto integer ServerHeartbeatSucceededEvent::getDurationMicros() Returns this event's duration in microseconds */ -static PHP_METHOD(ServerHeartbeatSucceededEvent, getDurationMicros) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatSucceededEvent, getDurationMicros) { php_phongo_serverheartbeatsucceededevent_t* intern = Z_SERVERHEARTBEATSUCCEEDEDEVENT_OBJ_P(getThis()); @@ -35,7 +39,7 @@ static PHP_METHOD(ServerHeartbeatSucceededEvent, getDurationMicros) /* {{{ proto string ServerHeartbeatSucceededEvent::getHost() Returns this event's host */ -static PHP_METHOD(ServerHeartbeatSucceededEvent, getHost) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatSucceededEvent, getHost) { php_phongo_serverheartbeatsucceededevent_t* intern = Z_SERVERHEARTBEATSUCCEEDEDEVENT_OBJ_P(getThis()); @@ -46,7 +50,7 @@ static PHP_METHOD(ServerHeartbeatSucceededEvent, getHost) /* {{{ proto integer ServerHeartbeatSucceededEvent::getPort() Returns this event's port */ -static PHP_METHOD(ServerHeartbeatSucceededEvent, getPort) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatSucceededEvent, getPort) { php_phongo_serverheartbeatsucceededevent_t* intern = Z_SERVERHEARTBEATSUCCEEDEDEVENT_OBJ_P(getThis()); @@ -57,7 +61,7 @@ static PHP_METHOD(ServerHeartbeatSucceededEvent, getPort) /* {{{ proto stdClass ServerHeartbeatSucceededEvent::getReply() Returns this event's reply */ -static PHP_METHOD(ServerHeartbeatSucceededEvent, getReply) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatSucceededEvent, getReply) { php_phongo_serverheartbeatsucceededevent_t* intern = Z_SERVERHEARTBEATSUCCEEDEDEVENT_OBJ_P(getThis()); php_phongo_bson_state state; @@ -76,7 +80,7 @@ static PHP_METHOD(ServerHeartbeatSucceededEvent, getReply) /* {{{ proto boolean ServerHeartbeatSucceededEvent::isAwaited() Returns whether this event came from an awaitable hello */ -static PHP_METHOD(ServerHeartbeatSucceededEvent, isAwaited) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerHeartbeatSucceededEvent, isAwaited) { php_phongo_serverheartbeatsucceededevent_t* intern = Z_SERVERHEARTBEATSUCCEEDEDEVENT_OBJ_P(getThis()); @@ -85,24 +89,6 @@ static PHP_METHOD(ServerHeartbeatSucceededEvent, isAwaited) RETVAL_BOOL(intern->awaited); } /* }}} */ -/* {{{ MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_ServerHeartbeatSucceededEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_serverheartbeatsucceededevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_ServerHeartbeatSucceededEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatSucceededEvent, getDurationMicros, ai_ServerHeartbeatSucceededEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatSucceededEvent, getHost, ai_ServerHeartbeatSucceededEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatSucceededEvent, getPort, ai_ServerHeartbeatSucceededEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatSucceededEvent, getReply, ai_ServerHeartbeatSucceededEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerHeartbeatSucceededEvent, isAwaited, ai_ServerHeartbeatSucceededEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_ServerHeartbeatSucceededEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent object handlers */ static zend_object_handlers php_phongo_handler_serverheartbeatsucceededevent; @@ -159,14 +145,8 @@ static HashTable* php_phongo_serverheartbeatsucceededevent_get_debug_info(phongo void php_phongo_serverheartbeatsucceededevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "ServerHeartbeatSucceededEvent", php_phongo_serverheartbeatsucceededevent_me); - php_phongo_serverheartbeatsucceededevent_ce = zend_register_internal_class(&ce); + php_phongo_serverheartbeatsucceededevent_ce = register_class_MongoDB_Driver_Monitoring_ServerHeartbeatSucceededEvent(); php_phongo_serverheartbeatsucceededevent_ce->create_object = php_phongo_serverheartbeatsucceededevent_create_object; - PHONGO_CE_FINAL(php_phongo_serverheartbeatsucceededevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_serverheartbeatsucceededevent_ce); memcpy(&php_phongo_handler_serverheartbeatsucceededevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/Monitoring/ServerHeartbeatSucceededEvent.stub.php b/src/MongoDB/Monitoring/ServerHeartbeatSucceededEvent.stub.php new file mode 100644 index 000000000..98ba6b24b --- /dev/null +++ b/src/MongoDB/Monitoring/ServerHeartbeatSucceededEvent.stub.php @@ -0,0 +1,25 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/ServerOpeningEvent.c b/src/MongoDB/Monitoring/ServerOpeningEvent.c index c378c7223..e4c1a17ea 100644 --- a/src/MongoDB/Monitoring/ServerOpeningEvent.c +++ b/src/MongoDB/Monitoring/ServerOpeningEvent.c @@ -21,12 +21,16 @@ #include "phongo_error.h" #include "BSON/ObjectId.h" +#include "ServerOpeningEvent_arginfo.h" zend_class_entry* php_phongo_serveropeningevent_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_ServerOpeningEvent) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Monitoring_ServerOpeningEvent) + /* {{{ proto string ServerOpeningEvent::getHost() Returns this event's host */ -static PHP_METHOD(ServerOpeningEvent, getHost) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerOpeningEvent, getHost) { php_phongo_serveropeningevent_t* intern = Z_SERVEROPENINGEVENT_OBJ_P(getThis()); @@ -37,7 +41,7 @@ static PHP_METHOD(ServerOpeningEvent, getHost) /* {{{ proto integer ServerOpeningEvent::getPort() Returns this event's port */ -static PHP_METHOD(ServerOpeningEvent, getPort) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerOpeningEvent, getPort) { php_phongo_serveropeningevent_t* intern = Z_SERVEROPENINGEVENT_OBJ_P(getThis()); @@ -48,7 +52,7 @@ static PHP_METHOD(ServerOpeningEvent, getPort) /* {{{ proto MongoDB\BSON\ObjectId ServerOpeningEvent::getTopologyId() Returns this event's topology id */ -static PHP_METHOD(ServerOpeningEvent, getTopologyId) +static PHP_METHOD(MongoDB_Driver_Monitoring_ServerOpeningEvent, getTopologyId) { php_phongo_serveropeningevent_t* intern = Z_SERVEROPENINGEVENT_OBJ_P(getThis()); @@ -57,22 +61,6 @@ static PHP_METHOD(ServerOpeningEvent, getTopologyId) phongo_objectid_init(return_value, &intern->topology_id); } /* }}} */ -/* {{{ MongoDB\Driver\Monitoring\ServerOpeningEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_ServerOpeningEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_serveropeningevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_ServerOpeningEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(ServerOpeningEvent, getHost, ai_ServerOpeningEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerOpeningEvent, getPort, ai_ServerOpeningEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerOpeningEvent, getTopologyId, ai_ServerOpeningEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_ServerOpeningEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\ServerOpeningEvent object handlers */ static zend_object_handlers php_phongo_handler_serveropeningevent; @@ -119,20 +107,12 @@ static HashTable* php_phongo_serveropeningevent_get_debug_info(phongo_compat_obj void php_phongo_serveropeningevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "ServerOpeningEvent", php_phongo_serveropeningevent_me); - php_phongo_serveropeningevent_ce = zend_register_internal_class(&ce); + php_phongo_serveropeningevent_ce = register_class_MongoDB_Driver_Monitoring_ServerOpeningEvent(); php_phongo_serveropeningevent_ce->create_object = php_phongo_serveropeningevent_create_object; - PHONGO_CE_FINAL(php_phongo_serveropeningevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_serveropeningevent_ce); memcpy(&php_phongo_handler_serveropeningevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_serveropeningevent.get_debug_info = php_phongo_serveropeningevent_get_debug_info; php_phongo_handler_serveropeningevent.free_obj = php_phongo_serveropeningevent_free_object; php_phongo_handler_serveropeningevent.offset = XtOffsetOf(php_phongo_serveropeningevent_t, std); - - return; } /* }}} */ diff --git a/src/MongoDB/Monitoring/ServerOpeningEvent.stub.php b/src/MongoDB/Monitoring/ServerOpeningEvent.stub.php new file mode 100644 index 000000000..bafa68ca8 --- /dev/null +++ b/src/MongoDB/Monitoring/ServerOpeningEvent.stub.php @@ -0,0 +1,21 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/Subscriber.c b/src/MongoDB/Monitoring/Subscriber.c index 54005f798..89b659c0b 100644 --- a/src/MongoDB/Monitoring/Subscriber.c +++ b/src/MongoDB/Monitoring/Subscriber.c @@ -17,23 +17,11 @@ #include #include "php_phongo.h" +#include "Subscriber_arginfo.h" zend_class_entry* php_phongo_subscriber_ce; -/* {{{ MongoDB\Driver\Monitoring\Subscriber function entries */ -static zend_function_entry php_phongo_subscriber_me[] = { - PHP_FE_END -}; -/* }}} */ - void php_phongo_subscriber_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - (void) type; - (void) module_number; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "Subscriber", php_phongo_subscriber_me); - php_phongo_subscriber_ce = zend_register_internal_interface(&ce); - - return; + php_phongo_subscriber_ce = register_class_MongoDB_Driver_Monitoring_Subscriber(); } /* }}} */ diff --git a/src/MongoDB/Monitoring/Subscriber.stub.php b/src/MongoDB/Monitoring/Subscriber.stub.php new file mode 100644 index 000000000..658b182e1 --- /dev/null +++ b/src/MongoDB/Monitoring/Subscriber.stub.php @@ -0,0 +1,12 @@ +topology_id); } /* }}} */ -/* {{{ MongoDB\Driver\Monitoring\TopologyChangedEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_TopologyChangedEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_topologychangedevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_TopologyChangedEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(TopologyChangedEvent, getNewDescription, ai_TopologyChangedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(TopologyChangedEvent, getPreviousDescription, ai_TopologyChangedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(TopologyChangedEvent, getTopologyId, ai_TopologyChangedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_TopologyChangedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\TopologyChangedEvent object handlers */ static zend_object_handlers php_phongo_handler_topologychangedevent; @@ -139,12 +127,8 @@ static HashTable* php_phongo_topologychangedevent_get_debug_info(phongo_compat_o void php_phongo_topologychangedevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "TopologyChangedEvent", php_phongo_topologychangedevent_me); - php_phongo_topologychangedevent_ce = zend_register_internal_class(&ce); + php_phongo_topologychangedevent_ce = register_class_MongoDB_Driver_Monitoring_TopologyChangedEvent(); php_phongo_topologychangedevent_ce->create_object = php_phongo_topologychangedevent_create_object; - PHONGO_CE_FINAL(php_phongo_topologychangedevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_topologychangedevent_ce); memcpy(&php_phongo_handler_topologychangedevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/Monitoring/TopologyChangedEvent.stub.php b/src/MongoDB/Monitoring/TopologyChangedEvent.stub.php new file mode 100644 index 000000000..ed55a48a8 --- /dev/null +++ b/src/MongoDB/Monitoring/TopologyChangedEvent.stub.php @@ -0,0 +1,21 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/TopologyClosedEvent.c b/src/MongoDB/Monitoring/TopologyClosedEvent.c index dd4f18bb2..716e70a7a 100644 --- a/src/MongoDB/Monitoring/TopologyClosedEvent.c +++ b/src/MongoDB/Monitoring/TopologyClosedEvent.c @@ -21,12 +21,16 @@ #include "phongo_error.h" #include "BSON/ObjectId.h" +#include "TopologyClosedEvent_arginfo.h" zend_class_entry* php_phongo_topologyclosedevent_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_TopologyClosedEvent) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Monitoring_TopologyClosedEvent) + /* {{{ proto MongoDB\BSON\ObjectId TopologyClosedEvent::getTopologyId() Returns this event's topology id */ -static PHP_METHOD(TopologyClosedEvent, getTopologyId) +static PHP_METHOD(MongoDB_Driver_Monitoring_TopologyClosedEvent, getTopologyId) { php_phongo_topologyclosedevent_t* intern = Z_TOPOLOGYCLOSEDEVENT_OBJ_P(getThis()); @@ -35,20 +39,6 @@ static PHP_METHOD(TopologyClosedEvent, getTopologyId) phongo_objectid_init(return_value, &intern->topology_id); } /* }}} */ -/* {{{ MongoDB\Driver\Monitoring\TopologyClosedEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_TopologyClosedEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_topologyclosedevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_TopologyClosedEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(TopologyClosedEvent, getTopologyId, ai_TopologyClosedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_TopologyClosedEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\TopologyClosedEvent object handlers */ static zend_object_handlers php_phongo_handler_topologyclosedevent; @@ -92,12 +82,8 @@ static HashTable* php_phongo_topologyclosedevent_get_debug_info(phongo_compat_ob void php_phongo_topologyclosedevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "TopologyClosedEvent", php_phongo_topologyclosedevent_me); - php_phongo_topologyclosedevent_ce = zend_register_internal_class(&ce); + php_phongo_topologyclosedevent_ce = register_class_MongoDB_Driver_Monitoring_TopologyClosedEvent(); php_phongo_topologyclosedevent_ce->create_object = php_phongo_topologyclosedevent_create_object; - PHONGO_CE_FINAL(php_phongo_topologyclosedevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_topologyclosedevent_ce); memcpy(&php_phongo_handler_topologyclosedevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/Monitoring/TopologyClosedEvent.stub.php b/src/MongoDB/Monitoring/TopologyClosedEvent.stub.php new file mode 100644 index 000000000..039168b42 --- /dev/null +++ b/src/MongoDB/Monitoring/TopologyClosedEvent.stub.php @@ -0,0 +1,17 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Monitoring/TopologyOpeningEvent.c b/src/MongoDB/Monitoring/TopologyOpeningEvent.c index db1315b56..22f345027 100644 --- a/src/MongoDB/Monitoring/TopologyOpeningEvent.c +++ b/src/MongoDB/Monitoring/TopologyOpeningEvent.c @@ -21,12 +21,16 @@ #include "phongo_error.h" #include "BSON/ObjectId.h" +#include "TopologyOpeningEvent_arginfo.h" zend_class_entry* php_phongo_topologyopeningevent_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_TopologyOpeningEvent) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Monitoring_TopologyOpeningEvent) + /* {{{ proto MongoDB\BSON\ObjectId TopologyOpeningEvent::getTopologyId() Returns this event's topology id */ -static PHP_METHOD(TopologyOpeningEvent, getTopologyId) +static PHP_METHOD(MongoDB_Driver_Monitoring_TopologyOpeningEvent, getTopologyId) { php_phongo_topologyopeningevent_t* intern = Z_TOPOLOGYOPENINGEVENT_OBJ_P(getThis()); @@ -35,20 +39,6 @@ static PHP_METHOD(TopologyOpeningEvent, getTopologyId) phongo_objectid_init(return_value, &intern->topology_id); } /* }}} */ -/* {{{ MongoDB\Driver\Monitoring\TopologyOpeningEvent function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_TopologyOpeningEvent_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_topologyopeningevent_me[] = { - /* clang-format off */ - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_TopologyOpeningEvent_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_ME(TopologyOpeningEvent, getTopologyId, ai_TopologyOpeningEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_TopologyOpeningEvent_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Monitoring\TopologyOpeningEvent object handlers */ static zend_object_handlers php_phongo_handler_topologyopeningevent; @@ -92,12 +82,8 @@ static HashTable* php_phongo_topologyopeningevent_get_debug_info(phongo_compat_o void php_phongo_topologyopeningevent_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Monitoring", "TopologyOpeningEvent", php_phongo_topologyopeningevent_me); - php_phongo_topologyopeningevent_ce = zend_register_internal_class(&ce); + php_phongo_topologyopeningevent_ce = register_class_MongoDB_Driver_Monitoring_TopologyOpeningEvent(); php_phongo_topologyopeningevent_ce->create_object = php_phongo_topologyopeningevent_create_object; - PHONGO_CE_FINAL(php_phongo_topologyopeningevent_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_topologyopeningevent_ce); memcpy(&php_phongo_handler_topologyopeningevent, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/Monitoring/TopologyOpeningEvent.stub.php b/src/MongoDB/Monitoring/TopologyOpeningEvent.stub.php new file mode 100644 index 000000000..2070ad11e --- /dev/null +++ b/src/MongoDB/Monitoring/TopologyOpeningEvent.stub.php @@ -0,0 +1,17 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/Query.c b/src/MongoDB/Query.c index 338b90158..ca611ecf8 100644 --- a/src/MongoDB/Query.c +++ b/src/MongoDB/Query.c @@ -27,6 +27,7 @@ #include "phongo_error.h" #include "MongoDB/ReadConcern.h" +#include "Query_arginfo.h" zend_class_entry* php_phongo_query_ce; @@ -387,9 +388,11 @@ static bool php_phongo_query_init(php_phongo_query_t* intern, zval* filter, zval #undef PHONGO_QUERY_OPT_INT64_DEPRECATED #undef PHONGO_QUERY_OPT_STRING +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Query) + /* {{{ proto void MongoDB\Driver\Query::__construct(array|object $filter[, array $options = array()]) Constructs a new Query */ -static PHP_METHOD(Query, __construct) +static PHP_METHOD(MongoDB_Driver_Query, __construct) { php_phongo_query_t* intern; zval* filter; @@ -406,24 +409,6 @@ static PHP_METHOD(Query, __construct) php_phongo_query_init(intern, filter, options); } /* }}} */ -/* {{{ MongoDB\Driver\Query function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_Query___construct, 0, 0, 1) - ZEND_ARG_INFO(0, filter) - ZEND_ARG_ARRAY_INFO(0, options, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Query_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_query_me[] = { - /* clang-format off */ - PHP_ME(Query, __construct, ai_Query___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_Query_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Query object handlers */ static zend_object_handlers php_phongo_handler_query; @@ -513,12 +498,8 @@ static HashTable* php_phongo_query_get_debug_info(phongo_compat_object_handler_t void php_phongo_query_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Query", php_phongo_query_me); - php_phongo_query_ce = zend_register_internal_class(&ce); + php_phongo_query_ce = register_class_MongoDB_Driver_Query(); php_phongo_query_ce->create_object = php_phongo_query_create_object; - PHONGO_CE_FINAL(php_phongo_query_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_query_ce); memcpy(&php_phongo_handler_query, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/Query.stub.php b/src/MongoDB/Query.stub.php new file mode 100644 index 000000000..de08e6616 --- /dev/null +++ b/src/MongoDB/Query.stub.php @@ -0,0 +1,20 @@ += 80000 + final public function __construct(array|object $filter, array $queryOptions = []) {} +#else + /** @param array|object $filter */ + final public function __construct($filter, array $queryOptions = []) {} +#endif + + final public function __wakeup(): void {} +} diff --git a/src/MongoDB/Query_arginfo.h b/src/MongoDB/Query_arginfo.h new file mode 100644 index 000000000..ab5951444 --- /dev/null +++ b/src/MongoDB/Query_arginfo.h @@ -0,0 +1,51 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: eac6cad75d3e8db014b69888b0d139d09cc5c51e */ + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Query___construct, 0, 0, 1) + ZEND_ARG_TYPE_MASK(0, filter, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, queryOptions, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Query___construct, 0, 0, 1) + ZEND_ARG_INFO(0, filter) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, queryOptions, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Query___wakeup, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() + + +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Query, __construct); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Query, __construct); +#endif +static ZEND_METHOD(MongoDB_Driver_Query, __wakeup); + + +static const zend_function_entry class_MongoDB_Driver_Query_methods[] = { +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Query, __construct, arginfo_class_MongoDB_Driver_Query___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Query, __construct, arginfo_class_MongoDB_Driver_Query___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_Query, __wakeup, arginfo_class_MongoDB_Driver_Query___wakeup, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_Query(void) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Query", class_MongoDB_Driver_Query_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/ReadConcern.c b/src/MongoDB/ReadConcern.c index 087ebee86..dbecc2afb 100644 --- a/src/MongoDB/ReadConcern.c +++ b/src/MongoDB/ReadConcern.c @@ -23,6 +23,7 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "ReadConcern_arginfo.h" zend_class_entry* php_phongo_readconcern_ce; @@ -54,7 +55,7 @@ static bool php_phongo_readconcern_init_from_hash(php_phongo_readconcern_t* inte /* {{{ proto void MongoDB\Driver\ReadConcern::__construct([string $level]) Constructs a new ReadConcern */ -static PHP_METHOD(ReadConcern, __construct) +static PHP_METHOD(MongoDB_Driver_ReadConcern, __construct) { php_phongo_readconcern_t* intern; char* level = NULL; @@ -76,7 +77,7 @@ static PHP_METHOD(ReadConcern, __construct) /* {{{ proto MongoDB\Driver\ReadConcern MongoDB\Driver\ReadConcern::__set_state(array $properties) */ -static PHP_METHOD(ReadConcern, __set_state) +static PHP_METHOD(MongoDB_Driver_ReadConcern, __set_state) { php_phongo_readconcern_t* intern; HashTable* props; @@ -96,7 +97,7 @@ static PHP_METHOD(ReadConcern, __set_state) /* {{{ proto string|null MongoDB\Driver\ReadConcern::getLevel() Returns the ReadConcern "level" option */ -static PHP_METHOD(ReadConcern, getLevel) +static PHP_METHOD(MongoDB_Driver_ReadConcern, getLevel) { php_phongo_readconcern_t* intern; const char* level; @@ -117,7 +118,7 @@ static PHP_METHOD(ReadConcern, getLevel) /* {{{ proto boolean MongoDB\Driver\ReadConcern::isDefault() Returns whether the read concern has not been modified (i.e. constructed without a level or from a Manager with no read concern URI options). */ -static PHP_METHOD(ReadConcern, isDefault) +static PHP_METHOD(MongoDB_Driver_ReadConcern, isDefault) { php_phongo_readconcern_t* intern; @@ -156,7 +157,7 @@ static HashTable* php_phongo_readconcern_get_properties_hash(phongo_compat_objec /* {{{ proto array MongoDB\Driver\ReadConcern::bsonSerialize() */ -static PHP_METHOD(ReadConcern, bsonSerialize) +static PHP_METHOD(MongoDB_Driver_ReadConcern, bsonSerialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -166,7 +167,7 @@ static PHP_METHOD(ReadConcern, bsonSerialize) /* {{{ proto string MongoDB\Driver\ReadConcern::serialize() */ -static PHP_METHOD(ReadConcern, serialize) +static PHP_METHOD(MongoDB_Driver_ReadConcern, serialize) { php_phongo_readconcern_t* intern; zval retval; @@ -204,7 +205,7 @@ static PHP_METHOD(ReadConcern, serialize) /* {{{ proto void MongoDB\Driver\ReadConcern::unserialize(string $serialized) */ -static PHP_METHOD(ReadConcern, unserialize) +static PHP_METHOD(MongoDB_Driver_ReadConcern, unserialize) { php_phongo_readconcern_t* intern; char* serialized; @@ -238,7 +239,7 @@ static PHP_METHOD(ReadConcern, unserialize) /* {{{ proto array MongoDB\Driver\ReadConcern::__serialize() */ -static PHP_METHOD(ReadConcern, __serialize) +static PHP_METHOD(MongoDB_Driver_ReadConcern, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -247,7 +248,7 @@ static PHP_METHOD(ReadConcern, __serialize) /* {{{ proto void MongoDB\Driver\ReadConcern::__unserialize(array $data) */ -static PHP_METHOD(ReadConcern, __unserialize) +static PHP_METHOD(MongoDB_Driver_ReadConcern, __unserialize) { zval* data; @@ -258,42 +259,6 @@ static PHP_METHOD(ReadConcern, __unserialize) php_phongo_readconcern_init_from_hash(Z_READCONCERN_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\Driver\ReadConcern function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_ReadConcern___construct, 0, 0, 0) - ZEND_ARG_INFO(0, level) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ReadConcern___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ReadConcern___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ReadConcern_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ReadConcern_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_readconcern_me[] = { - /* clang-format off */ - PHP_ME(ReadConcern, __construct, ai_ReadConcern___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadConcern, __serialize, ai_ReadConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadConcern, __set_state, ai_ReadConcern___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(ReadConcern, __unserialize, ai_ReadConcern___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadConcern, getLevel, ai_ReadConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadConcern, isDefault, ai_ReadConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadConcern, bsonSerialize, ai_ReadConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadConcern, serialize, ai_ReadConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadConcern, unserialize, ai_ReadConcern_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\ReadConcern object handlers */ static zend_object_handlers php_phongo_handler_readconcern; @@ -338,27 +303,14 @@ static HashTable* php_phongo_readconcern_get_properties(phongo_compat_object_han void php_phongo_readconcern_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ReadConcern", php_phongo_readconcern_me); - php_phongo_readconcern_ce = zend_register_internal_class(&ce); + php_phongo_readconcern_ce = register_class_MongoDB_Driver_ReadConcern(php_phongo_serializable_ce, zend_ce_serializable); php_phongo_readconcern_ce->create_object = php_phongo_readconcern_create_object; - PHONGO_CE_FINAL(php_phongo_readconcern_ce); - - zend_class_implements(php_phongo_readconcern_ce, 1, php_phongo_serializable_ce); - zend_class_implements(php_phongo_readconcern_ce, 1, zend_ce_serializable); memcpy(&php_phongo_handler_readconcern, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_readconcern.get_debug_info = php_phongo_readconcern_get_debug_info; php_phongo_handler_readconcern.get_properties = php_phongo_readconcern_get_properties; php_phongo_handler_readconcern.free_obj = php_phongo_readconcern_free_object; php_phongo_handler_readconcern.offset = XtOffsetOf(php_phongo_readconcern_t, std); - - zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("LOCAL"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_LOCAL)); - zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("MAJORITY"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_MAJORITY)); - zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("LINEARIZABLE"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_LINEARIZABLE)); - zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("AVAILABLE"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_AVAILABLE)); - zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("SNAPSHOT"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_SNAPSHOT)); } /* }}} */ void phongo_readconcern_init(zval* return_value, const mongoc_read_concern_t* read_concern) /* {{{ */ diff --git a/src/MongoDB/ReadConcern.stub.php b/src/MongoDB/ReadConcern.stub.php new file mode 100644 index 000000000..310488ec7 --- /dev/null +++ b/src/MongoDB/ReadConcern.stub.php @@ -0,0 +1,66 @@ += 80000 + final public function bsonSerialize(): array|object {} +#else + /** @return array|object */ + final public function bsonSerialize() {} +#endif + + final public function serialize(): string {} + + /** @param string $serialized */ + final public function unserialize($serialized): void {} + + final public function __unserialize(array $data): void {} + + final public function __serialize(): array {} + +} diff --git a/src/MongoDB/ReadConcern_arginfo.h b/src/MongoDB/ReadConcern_arginfo.h new file mode 100644 index 000000000..40563ad4a --- /dev/null +++ b/src/MongoDB/ReadConcern_arginfo.h @@ -0,0 +1,122 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 6b585fffb9a004ecfafc46c9e1fb60a73f8536a9 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern___construct, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, level, IS_STRING, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern_getLevel, 0, 0, IS_STRING, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern_isDefault, 0, 0, _IS_BOOL, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern___set_state, 0, 1, MongoDB\\Driver\\ReadConcern, 0) + ZEND_ARG_TYPE_INFO(0, properties, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_Driver_ReadConcern_bsonSerialize, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern_bsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern_serialize, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern___serialize, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + + +static ZEND_METHOD(MongoDB_Driver_ReadConcern, __construct); +static ZEND_METHOD(MongoDB_Driver_ReadConcern, getLevel); +static ZEND_METHOD(MongoDB_Driver_ReadConcern, isDefault); +static ZEND_METHOD(MongoDB_Driver_ReadConcern, __set_state); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_ReadConcern, bsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_ReadConcern, bsonSerialize); +#endif +static ZEND_METHOD(MongoDB_Driver_ReadConcern, serialize); +static ZEND_METHOD(MongoDB_Driver_ReadConcern, unserialize); +static ZEND_METHOD(MongoDB_Driver_ReadConcern, __unserialize); +static ZEND_METHOD(MongoDB_Driver_ReadConcern, __serialize); + + +static const zend_function_entry class_MongoDB_Driver_ReadConcern_methods[] = { + ZEND_ME(MongoDB_Driver_ReadConcern, __construct, arginfo_class_MongoDB_Driver_ReadConcern___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadConcern, getLevel, arginfo_class_MongoDB_Driver_ReadConcern_getLevel, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadConcern, isDefault, arginfo_class_MongoDB_Driver_ReadConcern_isDefault, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadConcern, __set_state, arginfo_class_MongoDB_Driver_ReadConcern___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_ReadConcern, bsonSerialize, arginfo_class_MongoDB_Driver_ReadConcern_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_ReadConcern, bsonSerialize, arginfo_class_MongoDB_Driver_ReadConcern_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_ReadConcern, serialize, arginfo_class_MongoDB_Driver_ReadConcern_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadConcern, unserialize, arginfo_class_MongoDB_Driver_ReadConcern_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadConcern, __unserialize, arginfo_class_MongoDB_Driver_ReadConcern___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadConcern, __serialize, arginfo_class_MongoDB_Driver_ReadConcern___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_ReadConcern(zend_class_entry *class_entry_MongoDB_BSON_Serializable, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ReadConcern", class_MongoDB_Driver_ReadConcern_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 2, class_entry_MongoDB_BSON_Serializable, class_entry_Serializable); + + zval const_LINEARIZABLE_value; + zend_string *const_LINEARIZABLE_value_str = zend_string_init(MONGOC_READ_CONCERN_LEVEL_LINEARIZABLE, sizeof(MONGOC_READ_CONCERN_LEVEL_LINEARIZABLE) - 1, 1); + ZVAL_STR(&const_LINEARIZABLE_value, const_LINEARIZABLE_value_str); + zend_string *const_LINEARIZABLE_name = zend_string_init_interned("LINEARIZABLE", sizeof("LINEARIZABLE") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_LINEARIZABLE_name, &const_LINEARIZABLE_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_LINEARIZABLE_name); + + zval const_LOCAL_value; + zend_string *const_LOCAL_value_str = zend_string_init(MONGOC_READ_CONCERN_LEVEL_LOCAL, sizeof(MONGOC_READ_CONCERN_LEVEL_LOCAL) - 1, 1); + ZVAL_STR(&const_LOCAL_value, const_LOCAL_value_str); + zend_string *const_LOCAL_name = zend_string_init_interned("LOCAL", sizeof("LOCAL") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_LOCAL_name, &const_LOCAL_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_LOCAL_name); + + zval const_MAJORITY_value; + zend_string *const_MAJORITY_value_str = zend_string_init(MONGOC_READ_CONCERN_LEVEL_MAJORITY, sizeof(MONGOC_READ_CONCERN_LEVEL_MAJORITY) - 1, 1); + ZVAL_STR(&const_MAJORITY_value, const_MAJORITY_value_str); + zend_string *const_MAJORITY_name = zend_string_init_interned("MAJORITY", sizeof("MAJORITY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_MAJORITY_name, &const_MAJORITY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_MAJORITY_name); + + zval const_AVAILABLE_value; + zend_string *const_AVAILABLE_value_str = zend_string_init(MONGOC_READ_CONCERN_LEVEL_AVAILABLE, sizeof(MONGOC_READ_CONCERN_LEVEL_AVAILABLE) - 1, 1); + ZVAL_STR(&const_AVAILABLE_value, const_AVAILABLE_value_str); + zend_string *const_AVAILABLE_name = zend_string_init_interned("AVAILABLE", sizeof("AVAILABLE") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_AVAILABLE_name, &const_AVAILABLE_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_AVAILABLE_name); + + zval const_SNAPSHOT_value; + zend_string *const_SNAPSHOT_value_str = zend_string_init(MONGOC_READ_CONCERN_LEVEL_SNAPSHOT, sizeof(MONGOC_READ_CONCERN_LEVEL_SNAPSHOT) - 1, 1); + ZVAL_STR(&const_SNAPSHOT_value, const_SNAPSHOT_value_str); + zend_string *const_SNAPSHOT_name = zend_string_init_interned("SNAPSHOT", sizeof("SNAPSHOT") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_SNAPSHOT_name, &const_SNAPSHOT_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_SNAPSHOT_name); + + return class_entry; +} diff --git a/src/MongoDB/ReadPreference.c b/src/MongoDB/ReadPreference.c index 6b3a216e5..73d614c77 100644 --- a/src/MongoDB/ReadPreference.c +++ b/src/MongoDB/ReadPreference.c @@ -29,15 +29,10 @@ #include "phongo_error.h" #include "MongoDB/ReadPreference.h" +#include "ReadPreference_arginfo.h" zend_class_entry* php_phongo_readpreference_ce; -#define PHONGO_READ_PRIMARY "primary" -#define PHONGO_READ_PRIMARY_PREFERRED "primaryPreferred" -#define PHONGO_READ_SECONDARY "secondary" -#define PHONGO_READ_SECONDARY_PREFERRED "secondaryPreferred" -#define PHONGO_READ_NEAREST "nearest" - /* Initialize the object from a HashTable and return whether it was successful. * An exception will be thrown on error. */ static bool php_phongo_readpreference_init_from_hash(php_phongo_readpreference_t* intern, HashTable* props) /* {{{ */ @@ -182,7 +177,7 @@ static const char* php_phongo_readpreference_get_mode_string(mongoc_read_mode_t /* {{{ proto void MongoDB\Driver\ReadPreference::__construct(int|string $mode[, array $tagSets = array()[, array $options = array()]]) Constructs a new ReadPreference */ -static PHP_METHOD(ReadPreference, __construct) +static PHP_METHOD(MongoDB_Driver_ReadPreference, __construct) { php_phongo_readpreference_t* intern; zval* mode; @@ -311,7 +306,7 @@ static PHP_METHOD(ReadPreference, __construct) /* {{{ proto MongoDB\Driver\ReadPreference MongoDB\Driver\ReadPreference::__set_state(array $properties) */ -static PHP_METHOD(ReadPreference, __set_state) +static PHP_METHOD(MongoDB_Driver_ReadPreference, __set_state) { php_phongo_readpreference_t* intern; HashTable* props; @@ -334,7 +329,7 @@ static PHP_METHOD(ReadPreference, __set_state) /* {{{ proto array|null MongoDB\Driver\ReadPreference::getHedge() Returns the ReadPreference hedge document */ -static PHP_METHOD(ReadPreference, getHedge) +static PHP_METHOD(MongoDB_Driver_ReadPreference, getHedge) { php_phongo_readpreference_t* intern; const bson_t* hedge; @@ -363,7 +358,7 @@ static PHP_METHOD(ReadPreference, getHedge) /* {{{ proto integer MongoDB\Driver\ReadPreference::getMaxStalenessSeconds() Returns the ReadPreference maxStalenessSeconds value */ -static PHP_METHOD(ReadPreference, getMaxStalenessSeconds) +static PHP_METHOD(MongoDB_Driver_ReadPreference, getMaxStalenessSeconds) { php_phongo_readpreference_t* intern; @@ -376,7 +371,7 @@ static PHP_METHOD(ReadPreference, getMaxStalenessSeconds) /* {{{ proto integer MongoDB\Driver\ReadPreference::getMode() Returns the ReadPreference mode */ -static PHP_METHOD(ReadPreference, getMode) +static PHP_METHOD(MongoDB_Driver_ReadPreference, getMode) { php_phongo_readpreference_t* intern; @@ -389,7 +384,7 @@ static PHP_METHOD(ReadPreference, getMode) /* {{{ proto string MongoDB\Driver\ReadPreference::getModeString() Returns the ReadPreference mode as string */ -static PHP_METHOD(ReadPreference, getModeString) +static PHP_METHOD(MongoDB_Driver_ReadPreference, getModeString) { php_phongo_readpreference_t* intern; const char* mode_string; @@ -409,7 +404,7 @@ static PHP_METHOD(ReadPreference, getModeString) /* {{{ proto array MongoDB\Driver\ReadPreference::getTagSets() Returns the ReadPreference tag sets */ -static PHP_METHOD(ReadPreference, getTagSets) +static PHP_METHOD(MongoDB_Driver_ReadPreference, getTagSets) { php_phongo_readpreference_t* intern; const bson_t* tags; @@ -510,7 +505,7 @@ static HashTable* php_phongo_readpreference_get_properties_hash(phongo_compat_ob /* {{{ proto array MongoDB\Driver\ReadPreference::bsonSerialize() */ -static PHP_METHOD(ReadPreference, bsonSerialize) +static PHP_METHOD(MongoDB_Driver_ReadPreference, bsonSerialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -520,7 +515,7 @@ static PHP_METHOD(ReadPreference, bsonSerialize) /* {{{ proto string MongoDB\Driver\ReadPreference::serialize() */ -static PHP_METHOD(ReadPreference, serialize) +static PHP_METHOD(MongoDB_Driver_ReadPreference, serialize) { php_phongo_readpreference_t* intern; zval retval; @@ -595,7 +590,7 @@ static PHP_METHOD(ReadPreference, serialize) /* {{{ proto void MongoDB\Driver\ReadPreference::unserialize(string $serialized) */ -static PHP_METHOD(ReadPreference, unserialize) +static PHP_METHOD(MongoDB_Driver_ReadPreference, unserialize) { php_phongo_readpreference_t* intern; char* serialized; @@ -629,7 +624,7 @@ static PHP_METHOD(ReadPreference, unserialize) /* {{{ proto array MongoDB\Driver\ReadPreference::__serialize() */ -static PHP_METHOD(ReadPreference, __serialize) +static PHP_METHOD(MongoDB_Driver_ReadPreference, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -638,7 +633,7 @@ static PHP_METHOD(ReadPreference, __serialize) /* {{{ proto void MongoDB\Driver\ReadPreference::__unserialize(array $data) */ -static PHP_METHOD(ReadPreference, __unserialize) +static PHP_METHOD(MongoDB_Driver_ReadPreference, __unserialize) { zval* data; @@ -649,47 +644,6 @@ static PHP_METHOD(ReadPreference, __unserialize) php_phongo_readpreference_init_from_hash(Z_READPREFERENCE_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\Driver\ReadPreference function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_ReadPreference___construct, 0, 0, 1) - ZEND_ARG_INFO(0, mode) - ZEND_ARG_ARRAY_INFO(0, tagSets, 1) - ZEND_ARG_ARRAY_INFO(0, options, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ReadPreference___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ReadPreference___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ReadPreference_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ReadPreference_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_readpreference_me[] = { - /* clang-format off */ - PHP_ME(ReadPreference, __construct, ai_ReadPreference___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadPreference, __serialize, ai_ReadPreference_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadPreference, __set_state, ai_ReadPreference___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(ReadPreference, __unserialize, ai_ReadPreference___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadPreference, getHedge, ai_ReadPreference_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadPreference, getMaxStalenessSeconds, ai_ReadPreference_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadPreference, getMode, ai_ReadPreference_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadPreference, getModeString, ai_ReadPreference_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadPreference, getTagSets, ai_ReadPreference_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadPreference, bsonSerialize, ai_ReadPreference_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadPreference, serialize, ai_ReadPreference_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ReadPreference, unserialize, ai_ReadPreference_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\ReadPreference object handlers */ static zend_object_handlers php_phongo_handler_readpreference; @@ -735,35 +689,14 @@ static HashTable* php_phongo_readpreference_get_properties(phongo_compat_object_ void php_phongo_readpreference_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ReadPreference", php_phongo_readpreference_me); - php_phongo_readpreference_ce = zend_register_internal_class(&ce); + php_phongo_readpreference_ce = register_class_MongoDB_Driver_ReadPreference(php_phongo_serializable_ce, zend_ce_serializable); php_phongo_readpreference_ce->create_object = php_phongo_readpreference_create_object; - PHONGO_CE_FINAL(php_phongo_readpreference_ce); - - zend_class_implements(php_phongo_readpreference_ce, 1, php_phongo_serializable_ce); - zend_class_implements(php_phongo_readpreference_ce, 1, zend_ce_serializable); memcpy(&php_phongo_handler_readpreference, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_readpreference.get_debug_info = php_phongo_readpreference_get_debug_info; php_phongo_handler_readpreference.get_properties = php_phongo_readpreference_get_properties; php_phongo_handler_readpreference.free_obj = php_phongo_readpreference_free_object; php_phongo_handler_readpreference.offset = XtOffsetOf(php_phongo_readpreference_t, std); - - zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_PRIMARY"), MONGOC_READ_PRIMARY); - zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_PRIMARY_PREFERRED"), MONGOC_READ_PRIMARY_PREFERRED); - zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_SECONDARY"), MONGOC_READ_SECONDARY); - zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_SECONDARY_PREFERRED"), MONGOC_READ_SECONDARY_PREFERRED); - zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_NEAREST"), MONGOC_READ_NEAREST); - zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("NO_MAX_STALENESS"), MONGOC_NO_MAX_STALENESS); - zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("SMALLEST_MAX_STALENESS_SECONDS"), MONGOC_SMALLEST_MAX_STALENESS_SECONDS); - - zend_declare_class_constant_string(php_phongo_readpreference_ce, ZEND_STRL("PRIMARY"), PHONGO_READ_PRIMARY); - zend_declare_class_constant_string(php_phongo_readpreference_ce, ZEND_STRL("PRIMARY_PREFERRED"), PHONGO_READ_PRIMARY_PREFERRED); - zend_declare_class_constant_string(php_phongo_readpreference_ce, ZEND_STRL("SECONDARY"), PHONGO_READ_SECONDARY); - zend_declare_class_constant_string(php_phongo_readpreference_ce, ZEND_STRL("SECONDARY_PREFERRED"), PHONGO_READ_SECONDARY_PREFERRED); - zend_declare_class_constant_string(php_phongo_readpreference_ce, ZEND_STRL("NEAREST"), PHONGO_READ_NEAREST); } /* }}} */ void phongo_readpreference_init(zval* return_value, const mongoc_read_prefs_t* read_prefs) /* {{{ */ diff --git a/src/MongoDB/ReadPreference.h b/src/MongoDB/ReadPreference.h index 9ede1819e..0a078b0e5 100644 --- a/src/MongoDB/ReadPreference.h +++ b/src/MongoDB/ReadPreference.h @@ -22,6 +22,12 @@ #include +#define PHONGO_READ_PRIMARY "primary" +#define PHONGO_READ_PRIMARY_PREFERRED "primaryPreferred" +#define PHONGO_READ_SECONDARY "secondary" +#define PHONGO_READ_SECONDARY_PREFERRED "secondaryPreferred" +#define PHONGO_READ_NEAREST "nearest" + void phongo_readpreference_init(zval* return_value, const mongoc_read_prefs_t* read_prefs); const mongoc_read_prefs_t* phongo_read_preference_from_zval(zval* zread_preference); diff --git a/src/MongoDB/ReadPreference.stub.php b/src/MongoDB/ReadPreference.stub.php new file mode 100644 index 000000000..2ef7d4ee4 --- /dev/null +++ b/src/MongoDB/ReadPreference.stub.php @@ -0,0 +1,118 @@ += 80000 + final public function __construct(string|int $mode, ?array $tagSets = null, ?array $options = null) {} +#else + /** @param string|int $mode */ + final public function __construct($mode, ?array $tagSets = null, ?array $options = null) {} +#endif + + final public function getHedge(): ?object {} + + final public function getMaxStalenessSeconds(): int {} + + final public function getMode(): int {} + + final public function getModeString(): string {} + + final public function getTagSets(): array {} + + public static function __set_state(array $properties): ReadPreference {} + +#if PHP_VERSION_ID >= 80000 + final public function bsonSerialize(): array|object {} +#else + /** @return array|object */ + final public function bsonSerialize() {} +#endif + + final public function serialize(): string {} + + /** @param string $serialized */ + final public function unserialize($serialized): void {} + + final public function __unserialize(array $data): void {} + + final public function __serialize(): array {} +} diff --git a/src/MongoDB/ReadPreference_arginfo.h b/src/MongoDB/ReadPreference_arginfo.h new file mode 100644 index 000000000..47cc7c413 --- /dev/null +++ b/src/MongoDB/ReadPreference_arginfo.h @@ -0,0 +1,198 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: ed8a570b0c805aec5562830088257ff92068a721 */ + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference___construct, 0, 0, 1) + ZEND_ARG_TYPE_MASK(0, mode, MAY_BE_STRING|MAY_BE_LONG, NULL) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, tagSets, IS_ARRAY, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference___construct, 0, 0, 1) + ZEND_ARG_INFO(0, mode) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, tagSets, IS_ARRAY, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference_getHedge, 0, 0, IS_OBJECT, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference_getMaxStalenessSeconds, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_ReadPreference_getMode arginfo_class_MongoDB_Driver_ReadPreference_getMaxStalenessSeconds + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference_getModeString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference_getTagSets, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference___set_state, 0, 1, MongoDB\\Driver\\ReadPreference, 0) + ZEND_ARG_TYPE_INFO(0, properties, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_Driver_ReadPreference_bsonSerialize, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference_bsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + +#define arginfo_class_MongoDB_Driver_ReadPreference_serialize arginfo_class_MongoDB_Driver_ReadPreference_getModeString + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_ReadPreference___serialize arginfo_class_MongoDB_Driver_ReadPreference_getTagSets + + +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_ReadPreference, __construct); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_ReadPreference, __construct); +#endif +static ZEND_METHOD(MongoDB_Driver_ReadPreference, getHedge); +static ZEND_METHOD(MongoDB_Driver_ReadPreference, getMaxStalenessSeconds); +static ZEND_METHOD(MongoDB_Driver_ReadPreference, getMode); +static ZEND_METHOD(MongoDB_Driver_ReadPreference, getModeString); +static ZEND_METHOD(MongoDB_Driver_ReadPreference, getTagSets); +static ZEND_METHOD(MongoDB_Driver_ReadPreference, __set_state); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_ReadPreference, bsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_ReadPreference, bsonSerialize); +#endif +static ZEND_METHOD(MongoDB_Driver_ReadPreference, serialize); +static ZEND_METHOD(MongoDB_Driver_ReadPreference, unserialize); +static ZEND_METHOD(MongoDB_Driver_ReadPreference, __unserialize); +static ZEND_METHOD(MongoDB_Driver_ReadPreference, __serialize); + + +static const zend_function_entry class_MongoDB_Driver_ReadPreference_methods[] = { +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_ReadPreference, __construct, arginfo_class_MongoDB_Driver_ReadPreference___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_ReadPreference, __construct, arginfo_class_MongoDB_Driver_ReadPreference___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_ReadPreference, getHedge, arginfo_class_MongoDB_Driver_ReadPreference_getHedge, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadPreference, getMaxStalenessSeconds, arginfo_class_MongoDB_Driver_ReadPreference_getMaxStalenessSeconds, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadPreference, getMode, arginfo_class_MongoDB_Driver_ReadPreference_getMode, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadPreference, getModeString, arginfo_class_MongoDB_Driver_ReadPreference_getModeString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadPreference, getTagSets, arginfo_class_MongoDB_Driver_ReadPreference_getTagSets, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadPreference, __set_state, arginfo_class_MongoDB_Driver_ReadPreference___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_ReadPreference, bsonSerialize, arginfo_class_MongoDB_Driver_ReadPreference_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_ReadPreference, bsonSerialize, arginfo_class_MongoDB_Driver_ReadPreference_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_ReadPreference, serialize, arginfo_class_MongoDB_Driver_ReadPreference_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadPreference, unserialize, arginfo_class_MongoDB_Driver_ReadPreference_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadPreference, __unserialize, arginfo_class_MongoDB_Driver_ReadPreference___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ReadPreference, __serialize, arginfo_class_MongoDB_Driver_ReadPreference___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_ReadPreference(zend_class_entry *class_entry_MongoDB_BSON_Serializable, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ReadPreference", class_MongoDB_Driver_ReadPreference_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 2, class_entry_MongoDB_BSON_Serializable, class_entry_Serializable); + + zval const_RP_PRIMARY_value; + ZVAL_LONG(&const_RP_PRIMARY_value, MONGOC_READ_PRIMARY); + zend_string *const_RP_PRIMARY_name = zend_string_init_interned("RP_PRIMARY", sizeof("RP_PRIMARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_RP_PRIMARY_name, &const_RP_PRIMARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_RP_PRIMARY_name); + + zval const_RP_PRIMARY_PREFERRED_value; + ZVAL_LONG(&const_RP_PRIMARY_PREFERRED_value, MONGOC_READ_PRIMARY_PREFERRED); + zend_string *const_RP_PRIMARY_PREFERRED_name = zend_string_init_interned("RP_PRIMARY_PREFERRED", sizeof("RP_PRIMARY_PREFERRED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_RP_PRIMARY_PREFERRED_name, &const_RP_PRIMARY_PREFERRED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_RP_PRIMARY_PREFERRED_name); + + zval const_RP_SECONDARY_value; + ZVAL_LONG(&const_RP_SECONDARY_value, MONGOC_READ_SECONDARY); + zend_string *const_RP_SECONDARY_name = zend_string_init_interned("RP_SECONDARY", sizeof("RP_SECONDARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_RP_SECONDARY_name, &const_RP_SECONDARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_RP_SECONDARY_name); + + zval const_RP_SECONDARY_PREFERRED_value; + ZVAL_LONG(&const_RP_SECONDARY_PREFERRED_value, MONGOC_READ_SECONDARY_PREFERRED); + zend_string *const_RP_SECONDARY_PREFERRED_name = zend_string_init_interned("RP_SECONDARY_PREFERRED", sizeof("RP_SECONDARY_PREFERRED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_RP_SECONDARY_PREFERRED_name, &const_RP_SECONDARY_PREFERRED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_RP_SECONDARY_PREFERRED_name); + + zval const_RP_NEAREST_value; + ZVAL_LONG(&const_RP_NEAREST_value, MONGOC_READ_NEAREST); + zend_string *const_RP_NEAREST_name = zend_string_init_interned("RP_NEAREST", sizeof("RP_NEAREST") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_RP_NEAREST_name, &const_RP_NEAREST_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_RP_NEAREST_name); + + zval const_PRIMARY_value; + zend_string *const_PRIMARY_value_str = zend_string_init(PHONGO_READ_PRIMARY, sizeof(PHONGO_READ_PRIMARY) - 1, 1); + ZVAL_STR(&const_PRIMARY_value, const_PRIMARY_value_str); + zend_string *const_PRIMARY_name = zend_string_init_interned("PRIMARY", sizeof("PRIMARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_PRIMARY_name, &const_PRIMARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_PRIMARY_name); + + zval const_PRIMARY_PREFERRED_value; + zend_string *const_PRIMARY_PREFERRED_value_str = zend_string_init(PHONGO_READ_PRIMARY_PREFERRED, sizeof(PHONGO_READ_PRIMARY_PREFERRED) - 1, 1); + ZVAL_STR(&const_PRIMARY_PREFERRED_value, const_PRIMARY_PREFERRED_value_str); + zend_string *const_PRIMARY_PREFERRED_name = zend_string_init_interned("PRIMARY_PREFERRED", sizeof("PRIMARY_PREFERRED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_PRIMARY_PREFERRED_name, &const_PRIMARY_PREFERRED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_PRIMARY_PREFERRED_name); + + zval const_SECONDARY_value; + zend_string *const_SECONDARY_value_str = zend_string_init(PHONGO_READ_SECONDARY, sizeof(PHONGO_READ_SECONDARY) - 1, 1); + ZVAL_STR(&const_SECONDARY_value, const_SECONDARY_value_str); + zend_string *const_SECONDARY_name = zend_string_init_interned("SECONDARY", sizeof("SECONDARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_SECONDARY_name, &const_SECONDARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_SECONDARY_name); + + zval const_SECONDARY_PREFERRED_value; + zend_string *const_SECONDARY_PREFERRED_value_str = zend_string_init(PHONGO_READ_SECONDARY_PREFERRED, sizeof(PHONGO_READ_SECONDARY_PREFERRED) - 1, 1); + ZVAL_STR(&const_SECONDARY_PREFERRED_value, const_SECONDARY_PREFERRED_value_str); + zend_string *const_SECONDARY_PREFERRED_name = zend_string_init_interned("SECONDARY_PREFERRED", sizeof("SECONDARY_PREFERRED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_SECONDARY_PREFERRED_name, &const_SECONDARY_PREFERRED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_SECONDARY_PREFERRED_name); + + zval const_NEAREST_value; + zend_string *const_NEAREST_value_str = zend_string_init(PHONGO_READ_NEAREST, sizeof(PHONGO_READ_NEAREST) - 1, 1); + ZVAL_STR(&const_NEAREST_value, const_NEAREST_value_str); + zend_string *const_NEAREST_name = zend_string_init_interned("NEAREST", sizeof("NEAREST") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_NEAREST_name, &const_NEAREST_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_NEAREST_name); + + zval const_NO_MAX_STALENESS_value; + ZVAL_LONG(&const_NO_MAX_STALENESS_value, MONGOC_NO_MAX_STALENESS); + zend_string *const_NO_MAX_STALENESS_name = zend_string_init_interned("NO_MAX_STALENESS", sizeof("NO_MAX_STALENESS") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_NO_MAX_STALENESS_name, &const_NO_MAX_STALENESS_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_NO_MAX_STALENESS_name); + + zval const_SMALLEST_MAX_STALENESS_SECONDS_value; + ZVAL_LONG(&const_SMALLEST_MAX_STALENESS_SECONDS_value, MONGOC_SMALLEST_MAX_STALENESS_SECONDS); + zend_string *const_SMALLEST_MAX_STALENESS_SECONDS_name = zend_string_init_interned("SMALLEST_MAX_STALENESS_SECONDS", sizeof("SMALLEST_MAX_STALENESS_SECONDS") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_SMALLEST_MAX_STALENESS_SECONDS_name, &const_SMALLEST_MAX_STALENESS_SECONDS_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_SMALLEST_MAX_STALENESS_SECONDS_name); + + return class_entry; +} diff --git a/src/MongoDB/Server.c b/src/MongoDB/Server.c index 9b4476982..9adbcc40f 100644 --- a/src/MongoDB/Server.c +++ b/src/MongoDB/Server.c @@ -29,12 +29,16 @@ #include "MongoDB/Server.h" #include "MongoDB/ServerDescription.h" +#include "Server_arginfo.h" zend_class_entry* php_phongo_server_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Server) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Server) + /* {{{ proto MongoDB\Driver\Cursor MongoDB\Driver\Server::executeCommand(string $db, MongoDB\Driver\Command $command[, array $options = null])) Executes a Command on this Server */ -static PHP_METHOD(Server, executeCommand) +static PHP_METHOD(MongoDB_Driver_Server, executeCommand) { php_phongo_server_t* intern; char* db; @@ -68,7 +72,7 @@ static PHP_METHOD(Server, executeCommand) /* {{{ proto MongoDB\Driver\Cursor MongoDB\Driver\Server::executeReadCommand(string $db, MongoDB\Driver\Command $command[, array $options = null])) Executes a ReadCommand on this Server */ -static PHP_METHOD(Server, executeReadCommand) +static PHP_METHOD(MongoDB_Driver_Server, executeReadCommand) { php_phongo_server_t* intern; char* db; @@ -95,7 +99,7 @@ static PHP_METHOD(Server, executeReadCommand) /* {{{ proto MongoDB\Driver\Cursor MongoDB\Driver\Server::executeWriteCommand(string $db, MongoDB\Driver\Command $command[, array $options = null])) Executes a WriteCommand on this Server */ -static PHP_METHOD(Server, executeWriteCommand) +static PHP_METHOD(MongoDB_Driver_Server, executeWriteCommand) { php_phongo_server_t* intern; char* db; @@ -122,7 +126,7 @@ static PHP_METHOD(Server, executeWriteCommand) /* {{{ proto MongoDB\Driver\Cursor MongoDB\Driver\Server::executeReadWriteCommand(string $db, MongoDB\Driver\Command $command[, array $options = null])) Executes a ReadWriteCommand on this Server */ -static PHP_METHOD(Server, executeReadWriteCommand) +static PHP_METHOD(MongoDB_Driver_Server, executeReadWriteCommand) { php_phongo_server_t* intern; char* db; @@ -149,7 +153,7 @@ static PHP_METHOD(Server, executeReadWriteCommand) /* {{{ proto MongoDB\Driver\Cursor MongoDB\Driver\Server::executeQuery(string $namespace, MongoDB\Driver\Query $query[, array $options = null])) Executes a Query on this Server */ -static PHP_METHOD(Server, executeQuery) +static PHP_METHOD(MongoDB_Driver_Server, executeQuery) { php_phongo_server_t* intern; char* namespace; @@ -184,7 +188,7 @@ static PHP_METHOD(Server, executeQuery) /* {{{ proto MongoDB\Driver\WriteResult MongoDB\Driver\Server::executeBulkWrite(string $namespace, MongoDB\Driver\BulkWrite $zbulk[, array $options = null]) Executes a BulkWrite (i.e. any number of insert, update, and delete ops) on this Server */ -static PHP_METHOD(Server, executeBulkWrite) +static PHP_METHOD(MongoDB_Driver_Server, executeBulkWrite) { php_phongo_server_t* intern; char* namespace; @@ -220,7 +224,7 @@ static PHP_METHOD(Server, executeBulkWrite) /* {{{ proto string MongoDB\Driver\Server::getHost() Returns the hostname for this Server */ -static PHP_METHOD(Server, getHost) +static PHP_METHOD(MongoDB_Driver_Server, getHost) { php_phongo_server_t* intern; mongoc_server_description_t* sd; @@ -240,7 +244,7 @@ static PHP_METHOD(Server, getHost) /* {{{ proto array MongoDB\Driver\Server::getTags() Returns the currently configured tags for this Server */ -static PHP_METHOD(Server, getTags) +static PHP_METHOD(MongoDB_Driver_Server, getTags) { php_phongo_server_t* intern; mongoc_server_description_t* sd; @@ -284,7 +288,7 @@ static PHP_METHOD(Server, getTags) /* {{{ proto array MongoDB\Driver\Server::getInfo() Returns the last hello response for this Server or, in the case of a load balancer, the initial handshake response. */ -static PHP_METHOD(Server, getInfo) +static PHP_METHOD(MongoDB_Driver_Server, getInfo) { php_phongo_server_t* intern; mongoc_client_t* client; @@ -340,7 +344,7 @@ static PHP_METHOD(Server, getInfo) /* {{{ proto integer|null MongoDB\Driver\Server::getLatency() Returns the measured latency (i.e. round trip time in milliseconds) for this Server, or null if unset. */ -static PHP_METHOD(Server, getLatency) +static PHP_METHOD(MongoDB_Driver_Server, getLatency) { php_phongo_server_t* intern; mongoc_server_description_t* sd; @@ -366,7 +370,7 @@ static PHP_METHOD(Server, getLatency) /* {{{ proto integer MongoDB\Driver\Server::getPort() Returns the port for this Server */ -static PHP_METHOD(Server, getPort) +static PHP_METHOD(MongoDB_Driver_Server, getPort) { php_phongo_server_t* intern; mongoc_server_description_t* sd; @@ -386,7 +390,7 @@ static PHP_METHOD(Server, getPort) /* {{{ proto MongoDB\Driver\ServerDescription MongoDB\Driver\Server::getServerDescription() Returns the server description for this Server */ -static PHP_METHOD(Server, getServerDescription) +static PHP_METHOD(MongoDB_Driver_Server, getServerDescription) { mongoc_server_description_t* server_description; php_phongo_server_t* intern = Z_SERVER_OBJ_P(getThis()); @@ -401,7 +405,7 @@ static PHP_METHOD(Server, getServerDescription) /* {{{ proto integer MongoDB\Driver\Server::getType() Returns the node type of this Server */ -static PHP_METHOD(Server, getType) +static PHP_METHOD(MongoDB_Driver_Server, getType) { php_phongo_server_t* intern; mongoc_server_description_t* sd; @@ -421,7 +425,7 @@ static PHP_METHOD(Server, getType) /* {{{ proto boolean MongoDB\Driver\Server::isPrimary() Returns whether this Server is a primary member of a replica set */ -static PHP_METHOD(Server, isPrimary) +static PHP_METHOD(MongoDB_Driver_Server, isPrimary) { php_phongo_server_t* intern; mongoc_server_description_t* sd; @@ -441,7 +445,7 @@ static PHP_METHOD(Server, isPrimary) /* {{{ proto boolean MongoDB\Driver\Server::isSecondary() Returns whether this Server is a secondary member of a replica set */ -static PHP_METHOD(Server, isSecondary) +static PHP_METHOD(MongoDB_Driver_Server, isSecondary) { php_phongo_server_t* intern; mongoc_server_description_t* sd; @@ -461,7 +465,7 @@ static PHP_METHOD(Server, isSecondary) /* {{{ proto boolean MongoDB\Driver\Server::isArbiter() Returns whether this Server is an arbiter member of a replica set */ -static PHP_METHOD(Server, isArbiter) +static PHP_METHOD(MongoDB_Driver_Server, isArbiter) { php_phongo_server_t* intern; mongoc_server_description_t* sd; @@ -481,7 +485,7 @@ static PHP_METHOD(Server, isArbiter) /* {{{ proto boolean MongoDB\Driver\Server::isHidden() Returns whether this Server is a hidden member of a replica set */ -static PHP_METHOD(Server, isHidden) +static PHP_METHOD(MongoDB_Driver_Server, isHidden) { php_phongo_server_t* intern; mongoc_server_description_t* sd; @@ -503,7 +507,7 @@ static PHP_METHOD(Server, isHidden) /* {{{ proto boolean MongoDB\Driver\Server::isPassive() Returns whether this Server is a passive member of a replica set */ -static PHP_METHOD(Server, isPassive) +static PHP_METHOD(MongoDB_Driver_Server, isPassive) { php_phongo_server_t* intern; mongoc_server_description_t* sd; @@ -523,61 +527,6 @@ static PHP_METHOD(Server, isPassive) phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Failed to get server description"); } /* }}} */ -/* {{{ MongoDB\Driver\Server function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_Server_executeCommand, 0, 0, 2) - ZEND_ARG_INFO(0, db) - ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Server_executeRWCommand, 0, 0, 2) - ZEND_ARG_INFO(0, db) - ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) - ZEND_ARG_ARRAY_INFO(0, options, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Server_executeQuery, 0, 0, 2) - ZEND_ARG_INFO(0, namespace) - ZEND_ARG_OBJ_INFO(0, zquery, MongoDB\\Driver\\Query, 0) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Server_executeBulkWrite, 0, 0, 2) - ZEND_ARG_INFO(0, namespace) - ZEND_ARG_OBJ_INFO(0, zbulk, MongoDB\\Driver\\BulkWrite, 0) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Server_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_server_me[] = { - /* clang-format off */ - PHP_ME(Server, executeCommand, ai_Server_executeCommand, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, executeReadCommand, ai_Server_executeRWCommand, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, executeWriteCommand, ai_Server_executeRWCommand, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, executeReadWriteCommand, ai_Server_executeRWCommand, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, executeQuery, ai_Server_executeQuery, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, executeBulkWrite, ai_Server_executeBulkWrite, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, getHost, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, getTags, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, getInfo, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, getLatency, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, getPort, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, getServerDescription, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, getType, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, isPrimary, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, isSecondary, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, isArbiter, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, isHidden, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Server, isPassive, ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_Server_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_Server_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Server object handlers */ static zend_object_handlers php_phongo_handler_server; @@ -663,12 +612,8 @@ static HashTable* php_phongo_server_get_debug_info(phongo_compat_object_handler_ void php_phongo_server_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Server", php_phongo_server_me); - php_phongo_server_ce = zend_register_internal_class(&ce); + php_phongo_server_ce = register_class_MongoDB_Driver_Server(); php_phongo_server_ce->create_object = php_phongo_server_create_object; - PHONGO_CE_FINAL(php_phongo_server_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_server_ce); memcpy(&php_phongo_handler_server, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); @@ -676,17 +621,6 @@ void php_phongo_server_init_ce(INIT_FUNC_ARGS) /* {{{ */ php_phongo_handler_server.get_debug_info = php_phongo_server_get_debug_info; php_phongo_handler_server.free_obj = php_phongo_server_free_object; php_phongo_handler_server.offset = XtOffsetOf(php_phongo_server_t, std); - - zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_UNKNOWN"), PHONGO_SERVER_UNKNOWN); - zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_STANDALONE"), PHONGO_SERVER_STANDALONE); - zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_MONGOS"), PHONGO_SERVER_MONGOS); - zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_POSSIBLE_PRIMARY"), PHONGO_SERVER_POSSIBLE_PRIMARY); - zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_RS_PRIMARY"), PHONGO_SERVER_RS_PRIMARY); - zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_RS_SECONDARY"), PHONGO_SERVER_RS_SECONDARY); - zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_RS_ARBITER"), PHONGO_SERVER_RS_ARBITER); - zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_RS_OTHER"), PHONGO_SERVER_RS_OTHER); - zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_RS_GHOST"), PHONGO_SERVER_RS_GHOST); - zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_LOAD_BALANCER"), PHONGO_SERVER_LOAD_BALANCER); } /* }}} */ void phongo_server_init(zval* return_value, zval* manager, uint32_t server_id) /* {{{ */ diff --git a/src/MongoDB/Server.stub.php b/src/MongoDB/Server.stub.php new file mode 100644 index 000000000..0cc6898c9 --- /dev/null +++ b/src/MongoDB/Server.stub.php @@ -0,0 +1,126 @@ += 80000 + final public function executeBulkWrite(string $namespace, BulkWrite $bulkWrite, array|WriteConcern|null $options = null): WriteResult {} +#else + /** @param array|WriteConcern|null $options */ + final public function executeBulkWrite(string $namespace, BulkWrite $bulkWrite, $options = null): WriteResult {} +#endif + +#if PHP_VERSION_ID >= 80000 + final public function executeCommand(string $db, Command $command, array|ReadPreference|null $options = null): Cursor {} +#else + /** @param array|ReadPreference|null $options */ + final public function executeCommand(string $db, Command $command, $options = null): Cursor {} +#endif + +#if PHP_VERSION_ID >= 80000 + final public function executeQuery(string $namespace, Query $query, array|ReadPreference|null $options = null): Cursor {} +#else + /** @param array|ReadPreference|null $options */ + final public function executeQuery(string $namespace, Query $query, $options = null): Cursor {} +#endif + + final public function executeReadCommand(string $db, Command $command, array $options = []): Cursor {} + + final public function executeReadWriteCommand(string $db, Command $command, array $options = []): Cursor {} + + final public function executeWriteCommand(string $db, Command $command, array $options = []): Cursor {} + + final public function getHost(): string {} + + final public function getInfo(): array {} + + final public function getLatency(): ?int {} + + final public function getPort(): int {} + + final public function getServerDescription(): ServerDescription {} + + final public function getTags(): array {} + + final public function getType(): int {} + + final public function isArbiter(): bool {} + + final public function isHidden(): bool {} + + final public function isPassive(): bool {} + + final public function isPrimary(): bool {} + + final public function isSecondary(): bool {} + + final public function __wakeup(): void {} +} diff --git a/src/MongoDB/ServerApi.c b/src/MongoDB/ServerApi.c index 94ea2da51..2c77484c2 100644 --- a/src/MongoDB/ServerApi.c +++ b/src/MongoDB/ServerApi.c @@ -23,6 +23,7 @@ #include "php_phongo.h" #include "phongo_error.h" +#include "ServerApi_arginfo.h" zend_class_entry* php_phongo_serverapi_ce; @@ -93,7 +94,7 @@ static bool php_phongo_serverapi_init_from_hash(php_phongo_serverapi_t* intern, /* {{{ proto void MongoDB\Driver\ServerApi::__construct(string $version, [?bool $strict], [?bool $deprecationErrors]) Constructs a new ServerApi object */ -static PHP_METHOD(ServerApi, __construct) +static PHP_METHOD(MongoDB_Driver_ServerApi, __construct) { php_phongo_serverapi_t* intern; zend_string* version; @@ -123,7 +124,7 @@ static PHP_METHOD(ServerApi, __construct) /* {{{ proto MongoDB\Driver\ServerApi MongoDB\Driver\ServerApi::__set_state(array $properties) */ -static PHP_METHOD(ServerApi, __set_state) +static PHP_METHOD(MongoDB_Driver_ServerApi, __set_state) { php_phongo_serverapi_t* intern; HashTable* props; @@ -182,7 +183,7 @@ static HashTable* php_phongo_serverapi_get_properties_hash(phongo_compat_object_ /* {{{ proto array MongoDB\Driver\ServerApi::bsonSerialize() */ -static PHP_METHOD(ServerApi, bsonSerialize) +static PHP_METHOD(MongoDB_Driver_ServerApi, bsonSerialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -192,7 +193,7 @@ static PHP_METHOD(ServerApi, bsonSerialize) /* {{{ proto string MongoDB\Driver\ServerApi::serialize() */ -static PHP_METHOD(ServerApi, serialize) +static PHP_METHOD(MongoDB_Driver_ServerApi, serialize) { php_phongo_serverapi_t* intern; zval retval; @@ -232,7 +233,7 @@ static PHP_METHOD(ServerApi, serialize) /* {{{ proto void MongoDB\Driver\ServerApi::unserialize(string $serialized) */ -static PHP_METHOD(ServerApi, unserialize) +static PHP_METHOD(MongoDB_Driver_ServerApi, unserialize) { php_phongo_serverapi_t* intern; char* serialized; @@ -266,7 +267,7 @@ static PHP_METHOD(ServerApi, unserialize) /* {{{ proto array MongoDB\Driver\ServerApi::__serialize() */ -static PHP_METHOD(ServerApi, __serialize) +static PHP_METHOD(MongoDB_Driver_ServerApi, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -275,7 +276,7 @@ static PHP_METHOD(ServerApi, __serialize) /* {{{ proto void MongoDB\Driver\ServerApi::__unserialize(array $data) */ -static PHP_METHOD(ServerApi, __unserialize) +static PHP_METHOD(MongoDB_Driver_ServerApi, __unserialize) { zval* data; @@ -286,46 +287,6 @@ static PHP_METHOD(ServerApi, __unserialize) php_phongo_serverapi_init_from_hash(Z_SERVERAPI_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\Driver\ServerApi function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_ServerApi___construct, 0, 0, 1) - ZEND_ARG_TYPE_INFO(0, version, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, strict, _IS_BOOL, 1) - ZEND_ARG_TYPE_INFO(0, deprecationErrors, _IS_BOOL, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ServerApi___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ServerApi___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ServerApi_unserialize, 0, 0, 1) -#if PHP_VERSION_ID >= 80000 - ZEND_ARG_TYPE_INFO(0, serialized, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, serialized) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_ServerApi_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_serverapi_me[] = { - /* clang-format off */ - PHP_ME(ServerApi, __construct, ai_ServerApi___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerApi, __serialize, ai_ServerApi_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerApi, __set_state, ai_ServerApi___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(ServerApi, __unserialize, ai_ServerApi___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerApi, bsonSerialize, ai_ServerApi_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerApi, serialize, ai_ServerApi_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerApi, unserialize, ai_ServerApi_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\ServerApi object handlers */ static zend_object_handlers php_phongo_handler_serverapi; @@ -370,21 +331,12 @@ static HashTable* php_phongo_serverapi_get_properties(phongo_compat_object_handl void php_phongo_serverapi_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ServerApi", php_phongo_serverapi_me); - php_phongo_serverapi_ce = zend_register_internal_class(&ce); + php_phongo_serverapi_ce = register_class_MongoDB_Driver_ServerApi(php_phongo_serializable_ce, zend_ce_serializable); php_phongo_serverapi_ce->create_object = php_phongo_serverapi_create_object; - PHONGO_CE_FINAL(php_phongo_serverapi_ce); - - zend_class_implements(php_phongo_serverapi_ce, 1, php_phongo_serializable_ce); - zend_class_implements(php_phongo_serverapi_ce, 1, zend_ce_serializable); memcpy(&php_phongo_handler_serverapi, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_serverapi.get_debug_info = php_phongo_serverapi_get_debug_info; php_phongo_handler_serverapi.get_properties = php_phongo_serverapi_get_properties; php_phongo_handler_serverapi.free_obj = php_phongo_serverapi_free_object; php_phongo_handler_serverapi.offset = XtOffsetOf(php_phongo_serverapi_t, std); - - zend_declare_class_constant_stringl(php_phongo_serverapi_ce, ZEND_STRL("V1"), ZEND_STRL("1")); } /* }}} */ diff --git a/src/MongoDB/ServerApi.stub.php b/src/MongoDB/ServerApi.stub.php new file mode 100644 index 000000000..166d41598 --- /dev/null +++ b/src/MongoDB/ServerApi.stub.php @@ -0,0 +1,34 @@ += 80000 + final public function bsonSerialize(): array|object {} +#else + /** @return array|object */ + final public function bsonSerialize() {} +#endif + + final public function serialize(): string {} + + /** @param string $serialized */ + final public function unserialize($serialized): void {} + + final public function __unserialize(array $data): void {} + + final public function __serialize(): array {} +} diff --git a/src/MongoDB/ServerApi_arginfo.h b/src/MongoDB/ServerApi_arginfo.h new file mode 100644 index 000000000..779eed1b2 --- /dev/null +++ b/src/MongoDB/ServerApi_arginfo.h @@ -0,0 +1,86 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 561937975ec62eaa627924f744d3e4426a903851 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi___construct, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, version, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, strict, _IS_BOOL, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, deprecationErrors, _IS_BOOL, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi___set_state, 0, 1, MongoDB\\Driver\\ServerApi, 0) + ZEND_ARG_TYPE_INFO(0, properties, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_Driver_ServerApi_bsonSerialize, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi_bsonSerialize, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi_serialize, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi___serialize, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + + +static ZEND_METHOD(MongoDB_Driver_ServerApi, __construct); +static ZEND_METHOD(MongoDB_Driver_ServerApi, __set_state); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_ServerApi, bsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_ServerApi, bsonSerialize); +#endif +static ZEND_METHOD(MongoDB_Driver_ServerApi, serialize); +static ZEND_METHOD(MongoDB_Driver_ServerApi, unserialize); +static ZEND_METHOD(MongoDB_Driver_ServerApi, __unserialize); +static ZEND_METHOD(MongoDB_Driver_ServerApi, __serialize); + + +static const zend_function_entry class_MongoDB_Driver_ServerApi_methods[] = { + ZEND_ME(MongoDB_Driver_ServerApi, __construct, arginfo_class_MongoDB_Driver_ServerApi___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ServerApi, __set_state, arginfo_class_MongoDB_Driver_ServerApi___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_ServerApi, bsonSerialize, arginfo_class_MongoDB_Driver_ServerApi_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_ServerApi, bsonSerialize, arginfo_class_MongoDB_Driver_ServerApi_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_ServerApi, serialize, arginfo_class_MongoDB_Driver_ServerApi_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ServerApi, unserialize, arginfo_class_MongoDB_Driver_ServerApi_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ServerApi, __unserialize, arginfo_class_MongoDB_Driver_ServerApi___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_ServerApi, __serialize, arginfo_class_MongoDB_Driver_ServerApi___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_ServerApi(zend_class_entry *class_entry_MongoDB_BSON_Serializable, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ServerApi", class_MongoDB_Driver_ServerApi_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 2, class_entry_MongoDB_BSON_Serializable, class_entry_Serializable); + + zval const_V1_value; + zend_string *const_V1_value_str = zend_string_init("1", sizeof("1") - 1, 1); + ZVAL_STR(&const_V1_value, const_V1_value_str); + zend_string *const_V1_name = zend_string_init_interned("V1", sizeof("V1") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_V1_name, &const_V1_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_V1_name); + + return class_entry; +} diff --git a/src/MongoDB/ServerDescription.c b/src/MongoDB/ServerDescription.c index d9ff1fd51..5cf93868e 100644 --- a/src/MongoDB/ServerDescription.c +++ b/src/MongoDB/ServerDescription.c @@ -26,22 +26,10 @@ #include "phongo_error.h" #include "MongoDB/ServerDescription.h" +#include "ServerDescription_arginfo.h" zend_class_entry* php_phongo_serverdescription_ce; -/* Note: these constants are derived from mongoc_server_description_type, since - * since mongoc_server_description_type_t is private. */ -#define PHONGO_SERVER_TYPE_UNKNOWN "Unknown" -#define PHONGO_SERVER_TYPE_STANDALONE "Standalone" -#define PHONGO_SERVER_TYPE_MONGOS "Mongos" -#define PHONGO_SERVER_TYPE_POSSIBLE_PRIMARY "PossiblePrimary" -#define PHONGO_SERVER_TYPE_RS_PRIMARY "RSPrimary" -#define PHONGO_SERVER_TYPE_RS_SECONDARY "RSSecondary" -#define PHONGO_SERVER_TYPE_RS_ARBITER "RSArbiter" -#define PHONGO_SERVER_TYPE_RS_OTHER "RSOther" -#define PHONGO_SERVER_TYPE_RS_GHOST "RSGhost" -#define PHONGO_SERVER_TYPE_LOAD_BALANCER "LoadBalancer" - php_phongo_server_description_type_map_t php_phongo_server_description_type_map[PHONGO_SERVER_DESCRIPTION_TYPES] = { { PHONGO_SERVER_UNKNOWN, PHONGO_SERVER_TYPE_UNKNOWN }, @@ -56,9 +44,12 @@ php_phongo_server_description_type_map_t { PHONGO_SERVER_LOAD_BALANCER, PHONGO_SERVER_TYPE_LOAD_BALANCER }, }; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_ServerDescription) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_ServerDescription) + /* {{{ proto array MongoDB\Driver\ServerDescription::getHelloResponse() Returns the most recent "hello" response */ -static PHP_METHOD(ServerDescription, getHelloResponse) +static PHP_METHOD(MongoDB_Driver_ServerDescription, getHelloResponse) { php_phongo_serverdescription_t* intern; const bson_t* helloResponse; @@ -88,7 +79,7 @@ static PHP_METHOD(ServerDescription, getHelloResponse) /* {{{ proto string MongoDB\Driver\ServerDescription::getHost() Returns the server's hostname */ -static PHP_METHOD(ServerDescription, getHost) +static PHP_METHOD(MongoDB_Driver_ServerDescription, getHost) { php_phongo_serverdescription_t* intern; @@ -101,7 +92,7 @@ static PHP_METHOD(ServerDescription, getHost) /* {{{ proto integer MongoDB\Driver\ServerDescription::getLastUpdateTime() Returns the server's last update time, in microseconds */ -static PHP_METHOD(ServerDescription, getLastUpdateTime) +static PHP_METHOD(MongoDB_Driver_ServerDescription, getLastUpdateTime) { php_phongo_serverdescription_t* intern; int64_t last_update_time; @@ -123,7 +114,7 @@ static PHP_METHOD(ServerDescription, getLastUpdateTime) /* {{{ proto integer MongoDB\Driver\ServerDescription::getPort() Returns the server's port */ -static PHP_METHOD(ServerDescription, getPort) +static PHP_METHOD(MongoDB_Driver_ServerDescription, getPort) { php_phongo_serverdescription_t* intern; @@ -136,7 +127,7 @@ static PHP_METHOD(ServerDescription, getPort) /* {{{ proto integer MongoDB\Driver\ServerDescription::getRoundTripTime() Returns the server's round trip time, in milliseconds */ -static PHP_METHOD(ServerDescription, getRoundTripTime) +static PHP_METHOD(MongoDB_Driver_ServerDescription, getRoundTripTime) { php_phongo_serverdescription_t* intern; @@ -154,7 +145,7 @@ static PHP_METHOD(ServerDescription, getRoundTripTime) /* {{{ proto string MongoDB\Driver\ServerDescription::getType() Returns the server's node type */ -static PHP_METHOD(ServerDescription, getType) +static PHP_METHOD(MongoDB_Driver_ServerDescription, getType) { php_phongo_serverdescription_t* intern; @@ -165,24 +156,6 @@ static PHP_METHOD(ServerDescription, getType) RETVAL_STRING(mongoc_server_description_type(intern->server_description)); } /* }}} */ -/* {{{ MongoDB\Driver\ServerDescription function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_ServerDescription_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_serverdescription_me[] = { - /* clang-format off */ - PHP_ME(ServerDescription, getHelloResponse, ai_ServerDescription_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerDescription, getHost, ai_ServerDescription_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerDescription, getLastUpdateTime, ai_ServerDescription_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerDescription, getPort, ai_ServerDescription_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerDescription, getRoundTripTime, ai_ServerDescription_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(ServerDescription, getType, ai_ServerDescription_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_ServerDescription_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\ServerDescription object handlers */ static zend_object_handlers php_phongo_handler_serverdescription; @@ -304,12 +277,8 @@ static HashTable* php_phongo_serverdescription_get_properties(phongo_compat_obje void php_phongo_serverdescription_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ServerDescription", php_phongo_serverdescription_me); - php_phongo_serverdescription_ce = zend_register_internal_class(&ce); + php_phongo_serverdescription_ce = register_class_MongoDB_Driver_ServerDescription(); php_phongo_serverdescription_ce->create_object = php_phongo_serverdescription_create_object; - PHONGO_CE_FINAL(php_phongo_serverdescription_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_serverdescription_ce); memcpy(&php_phongo_handler_serverdescription, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); @@ -317,17 +286,6 @@ void php_phongo_serverdescription_init_ce(INIT_FUNC_ARGS) /* {{{ */ php_phongo_handler_serverdescription.get_properties = php_phongo_serverdescription_get_properties; php_phongo_handler_serverdescription.free_obj = php_phongo_serverdescription_free_object; php_phongo_handler_serverdescription.offset = XtOffsetOf(php_phongo_serverdescription_t, std); - - zend_declare_class_constant_string(php_phongo_serverdescription_ce, ZEND_STRL("TYPE_UNKNOWN"), PHONGO_SERVER_TYPE_UNKNOWN); - zend_declare_class_constant_string(php_phongo_serverdescription_ce, ZEND_STRL("TYPE_STANDALONE"), PHONGO_SERVER_TYPE_STANDALONE); - zend_declare_class_constant_string(php_phongo_serverdescription_ce, ZEND_STRL("TYPE_MONGOS"), PHONGO_SERVER_TYPE_MONGOS); - zend_declare_class_constant_string(php_phongo_serverdescription_ce, ZEND_STRL("TYPE_POSSIBLE_PRIMARY"), PHONGO_SERVER_TYPE_POSSIBLE_PRIMARY); - zend_declare_class_constant_string(php_phongo_serverdescription_ce, ZEND_STRL("TYPE_RS_PRIMARY"), PHONGO_SERVER_TYPE_RS_PRIMARY); - zend_declare_class_constant_string(php_phongo_serverdescription_ce, ZEND_STRL("TYPE_RS_SECONDARY"), PHONGO_SERVER_TYPE_RS_SECONDARY); - zend_declare_class_constant_string(php_phongo_serverdescription_ce, ZEND_STRL("TYPE_RS_ARBITER"), PHONGO_SERVER_TYPE_RS_ARBITER); - zend_declare_class_constant_string(php_phongo_serverdescription_ce, ZEND_STRL("TYPE_RS_OTHER"), PHONGO_SERVER_TYPE_RS_OTHER); - zend_declare_class_constant_string(php_phongo_serverdescription_ce, ZEND_STRL("TYPE_RS_GHOST"), PHONGO_SERVER_TYPE_RS_GHOST); - zend_declare_class_constant_string(php_phongo_serverdescription_ce, ZEND_STRL("TYPE_LOAD_BALANCER"), PHONGO_SERVER_TYPE_LOAD_BALANCER); } /* }}} */ void phongo_serverdescription_init_ex(zval* return_value, mongoc_server_description_t* server_description, bool copy) /* {{{ */ diff --git a/src/MongoDB/ServerDescription.h b/src/MongoDB/ServerDescription.h index a23679ed9..d3fa55f40 100644 --- a/src/MongoDB/ServerDescription.h +++ b/src/MongoDB/ServerDescription.h @@ -21,6 +21,19 @@ #include +/* Note: these constants are derived from mongoc_server_description_type, since + * since mongoc_server_description_type_t is private. */ +#define PHONGO_SERVER_TYPE_UNKNOWN "Unknown" +#define PHONGO_SERVER_TYPE_STANDALONE "Standalone" +#define PHONGO_SERVER_TYPE_MONGOS "Mongos" +#define PHONGO_SERVER_TYPE_POSSIBLE_PRIMARY "PossiblePrimary" +#define PHONGO_SERVER_TYPE_RS_PRIMARY "RSPrimary" +#define PHONGO_SERVER_TYPE_RS_SECONDARY "RSSecondary" +#define PHONGO_SERVER_TYPE_RS_ARBITER "RSArbiter" +#define PHONGO_SERVER_TYPE_RS_OTHER "RSOther" +#define PHONGO_SERVER_TYPE_RS_GHOST "RSGhost" +#define PHONGO_SERVER_TYPE_LOAD_BALANCER "LoadBalancer" + /* This enum is necessary since mongoc_server_description_type_t is private and * we need to translate strings returned by mongoc_server_description_type() to * Server integer constants. */ diff --git a/src/MongoDB/ServerDescription.stub.php b/src/MongoDB/ServerDescription.stub.php new file mode 100644 index 000000000..c10f30ff3 --- /dev/null +++ b/src/MongoDB/ServerDescription.stub.php @@ -0,0 +1,87 @@ +ce_flags |= ZEND_ACC_FINAL; + + zval const_TYPE_UNKNOWN_value; + zend_string *const_TYPE_UNKNOWN_value_str = zend_string_init(PHONGO_SERVER_TYPE_UNKNOWN, sizeof(PHONGO_SERVER_TYPE_UNKNOWN) - 1, 1); + ZVAL_STR(&const_TYPE_UNKNOWN_value, const_TYPE_UNKNOWN_value_str); + zend_string *const_TYPE_UNKNOWN_name = zend_string_init_interned("TYPE_UNKNOWN", sizeof("TYPE_UNKNOWN") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_UNKNOWN_name, &const_TYPE_UNKNOWN_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_UNKNOWN_name); + + zval const_TYPE_STANDALONE_value; + zend_string *const_TYPE_STANDALONE_value_str = zend_string_init(PHONGO_SERVER_TYPE_STANDALONE, sizeof(PHONGO_SERVER_TYPE_STANDALONE) - 1, 1); + ZVAL_STR(&const_TYPE_STANDALONE_value, const_TYPE_STANDALONE_value_str); + zend_string *const_TYPE_STANDALONE_name = zend_string_init_interned("TYPE_STANDALONE", sizeof("TYPE_STANDALONE") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_STANDALONE_name, &const_TYPE_STANDALONE_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_STANDALONE_name); + + zval const_TYPE_MONGOS_value; + zend_string *const_TYPE_MONGOS_value_str = zend_string_init(PHONGO_SERVER_TYPE_MONGOS, sizeof(PHONGO_SERVER_TYPE_MONGOS) - 1, 1); + ZVAL_STR(&const_TYPE_MONGOS_value, const_TYPE_MONGOS_value_str); + zend_string *const_TYPE_MONGOS_name = zend_string_init_interned("TYPE_MONGOS", sizeof("TYPE_MONGOS") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_MONGOS_name, &const_TYPE_MONGOS_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_MONGOS_name); + + zval const_TYPE_POSSIBLE_PRIMARY_value; + zend_string *const_TYPE_POSSIBLE_PRIMARY_value_str = zend_string_init(PHONGO_SERVER_TYPE_POSSIBLE_PRIMARY, sizeof(PHONGO_SERVER_TYPE_POSSIBLE_PRIMARY) - 1, 1); + ZVAL_STR(&const_TYPE_POSSIBLE_PRIMARY_value, const_TYPE_POSSIBLE_PRIMARY_value_str); + zend_string *const_TYPE_POSSIBLE_PRIMARY_name = zend_string_init_interned("TYPE_POSSIBLE_PRIMARY", sizeof("TYPE_POSSIBLE_PRIMARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_POSSIBLE_PRIMARY_name, &const_TYPE_POSSIBLE_PRIMARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_POSSIBLE_PRIMARY_name); + + zval const_TYPE_RS_PRIMARY_value; + zend_string *const_TYPE_RS_PRIMARY_value_str = zend_string_init(PHONGO_SERVER_TYPE_RS_PRIMARY, sizeof(PHONGO_SERVER_TYPE_RS_PRIMARY) - 1, 1); + ZVAL_STR(&const_TYPE_RS_PRIMARY_value, const_TYPE_RS_PRIMARY_value_str); + zend_string *const_TYPE_RS_PRIMARY_name = zend_string_init_interned("TYPE_RS_PRIMARY", sizeof("TYPE_RS_PRIMARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_RS_PRIMARY_name, &const_TYPE_RS_PRIMARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_RS_PRIMARY_name); + + zval const_TYPE_RS_SECONDARY_value; + zend_string *const_TYPE_RS_SECONDARY_value_str = zend_string_init(PHONGO_SERVER_TYPE_RS_SECONDARY, sizeof(PHONGO_SERVER_TYPE_RS_SECONDARY) - 1, 1); + ZVAL_STR(&const_TYPE_RS_SECONDARY_value, const_TYPE_RS_SECONDARY_value_str); + zend_string *const_TYPE_RS_SECONDARY_name = zend_string_init_interned("TYPE_RS_SECONDARY", sizeof("TYPE_RS_SECONDARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_RS_SECONDARY_name, &const_TYPE_RS_SECONDARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_RS_SECONDARY_name); + + zval const_TYPE_RS_ARBITER_value; + zend_string *const_TYPE_RS_ARBITER_value_str = zend_string_init(PHONGO_SERVER_TYPE_RS_ARBITER, sizeof(PHONGO_SERVER_TYPE_RS_ARBITER) - 1, 1); + ZVAL_STR(&const_TYPE_RS_ARBITER_value, const_TYPE_RS_ARBITER_value_str); + zend_string *const_TYPE_RS_ARBITER_name = zend_string_init_interned("TYPE_RS_ARBITER", sizeof("TYPE_RS_ARBITER") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_RS_ARBITER_name, &const_TYPE_RS_ARBITER_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_RS_ARBITER_name); + + zval const_TYPE_RS_OTHER_value; + zend_string *const_TYPE_RS_OTHER_value_str = zend_string_init(PHONGO_SERVER_TYPE_RS_OTHER, sizeof(PHONGO_SERVER_TYPE_RS_OTHER) - 1, 1); + ZVAL_STR(&const_TYPE_RS_OTHER_value, const_TYPE_RS_OTHER_value_str); + zend_string *const_TYPE_RS_OTHER_name = zend_string_init_interned("TYPE_RS_OTHER", sizeof("TYPE_RS_OTHER") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_RS_OTHER_name, &const_TYPE_RS_OTHER_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_RS_OTHER_name); + + zval const_TYPE_RS_GHOST_value; + zend_string *const_TYPE_RS_GHOST_value_str = zend_string_init(PHONGO_SERVER_TYPE_RS_GHOST, sizeof(PHONGO_SERVER_TYPE_RS_GHOST) - 1, 1); + ZVAL_STR(&const_TYPE_RS_GHOST_value, const_TYPE_RS_GHOST_value_str); + zend_string *const_TYPE_RS_GHOST_name = zend_string_init_interned("TYPE_RS_GHOST", sizeof("TYPE_RS_GHOST") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_RS_GHOST_name, &const_TYPE_RS_GHOST_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_RS_GHOST_name); + + zval const_TYPE_LOAD_BALANCER_value; + zend_string *const_TYPE_LOAD_BALANCER_value_str = zend_string_init(PHONGO_SERVER_TYPE_LOAD_BALANCER, sizeof(PHONGO_SERVER_TYPE_LOAD_BALANCER) - 1, 1); + ZVAL_STR(&const_TYPE_LOAD_BALANCER_value, const_TYPE_LOAD_BALANCER_value_str); + zend_string *const_TYPE_LOAD_BALANCER_name = zend_string_init_interned("TYPE_LOAD_BALANCER", sizeof("TYPE_LOAD_BALANCER") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_LOAD_BALANCER_name, &const_TYPE_LOAD_BALANCER_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_LOAD_BALANCER_name); + + return class_entry; +} diff --git a/src/MongoDB/Server_arginfo.h b/src/MongoDB/Server_arginfo.h new file mode 100644 index 000000000..31c71e42a --- /dev/null +++ b/src/MongoDB/Server_arginfo.h @@ -0,0 +1,244 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 8c4e8b2bd6a1a5b0047a69ea3cd79399aa474a05 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Server___construct, 0, 0, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Server_executeBulkWrite, 0, 2, MongoDB\\Driver\\WriteResult, 0) + ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, bulkWrite, MongoDB\\Driver\\BulkWrite, 0) + ZEND_ARG_OBJ_TYPE_MASK(0, options, MongoDB\\Driver\\WriteConcern, MAY_BE_ARRAY|MAY_BE_NULL, "null") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Server_executeBulkWrite, 0, 2, MongoDB\\Driver\\WriteResult, 0) + ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, bulkWrite, MongoDB\\Driver\\BulkWrite, 0) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, options, "null") +ZEND_END_ARG_INFO() +#endif + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Server_executeCommand, 0, 2, MongoDB\\Driver\\Cursor, 0) + ZEND_ARG_TYPE_INFO(0, db, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) + ZEND_ARG_OBJ_TYPE_MASK(0, options, MongoDB\\Driver\\ReadPreference, MAY_BE_ARRAY|MAY_BE_NULL, "null") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Server_executeCommand, 0, 2, MongoDB\\Driver\\Cursor, 0) + ZEND_ARG_TYPE_INFO(0, db, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, options, "null") +ZEND_END_ARG_INFO() +#endif + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Server_executeQuery, 0, 2, MongoDB\\Driver\\Cursor, 0) + ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, query, MongoDB\\Driver\\Query, 0) + ZEND_ARG_OBJ_TYPE_MASK(0, options, MongoDB\\Driver\\ReadPreference, MAY_BE_ARRAY|MAY_BE_NULL, "null") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Server_executeQuery, 0, 2, MongoDB\\Driver\\Cursor, 0) + ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, query, MongoDB\\Driver\\Query, 0) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, options, "null") +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Server_executeReadCommand, 0, 2, MongoDB\\Driver\\Cursor, 0) + ZEND_ARG_TYPE_INFO(0, db, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_Server_executeReadWriteCommand arginfo_class_MongoDB_Driver_Server_executeReadCommand + +#define arginfo_class_MongoDB_Driver_Server_executeWriteCommand arginfo_class_MongoDB_Driver_Server_executeReadCommand + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Server_getHost, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Server_getInfo, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Server_getLatency, 0, 0, IS_LONG, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Server_getPort, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Server_getServerDescription, 0, 0, MongoDB\\Driver\\ServerDescription, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_Server_getTags arginfo_class_MongoDB_Driver_Server_getInfo + +#define arginfo_class_MongoDB_Driver_Server_getType arginfo_class_MongoDB_Driver_Server_getPort + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Server_isArbiter, 0, 0, _IS_BOOL, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_Server_isHidden arginfo_class_MongoDB_Driver_Server_isArbiter + +#define arginfo_class_MongoDB_Driver_Server_isPassive arginfo_class_MongoDB_Driver_Server_isArbiter + +#define arginfo_class_MongoDB_Driver_Server_isPrimary arginfo_class_MongoDB_Driver_Server_isArbiter + +#define arginfo_class_MongoDB_Driver_Server_isSecondary arginfo_class_MongoDB_Driver_Server_isArbiter + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Server___wakeup, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() + + +static ZEND_METHOD(MongoDB_Driver_Server, __construct); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Server, executeBulkWrite); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Server, executeBulkWrite); +#endif +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Server, executeCommand); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Server, executeCommand); +#endif +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Server, executeQuery); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Server, executeQuery); +#endif +static ZEND_METHOD(MongoDB_Driver_Server, executeReadCommand); +static ZEND_METHOD(MongoDB_Driver_Server, executeReadWriteCommand); +static ZEND_METHOD(MongoDB_Driver_Server, executeWriteCommand); +static ZEND_METHOD(MongoDB_Driver_Server, getHost); +static ZEND_METHOD(MongoDB_Driver_Server, getInfo); +static ZEND_METHOD(MongoDB_Driver_Server, getLatency); +static ZEND_METHOD(MongoDB_Driver_Server, getPort); +static ZEND_METHOD(MongoDB_Driver_Server, getServerDescription); +static ZEND_METHOD(MongoDB_Driver_Server, getTags); +static ZEND_METHOD(MongoDB_Driver_Server, getType); +static ZEND_METHOD(MongoDB_Driver_Server, isArbiter); +static ZEND_METHOD(MongoDB_Driver_Server, isHidden); +static ZEND_METHOD(MongoDB_Driver_Server, isPassive); +static ZEND_METHOD(MongoDB_Driver_Server, isPrimary); +static ZEND_METHOD(MongoDB_Driver_Server, isSecondary); +static ZEND_METHOD(MongoDB_Driver_Server, __wakeup); + + +static const zend_function_entry class_MongoDB_Driver_Server_methods[] = { + ZEND_ME(MongoDB_Driver_Server, __construct, arginfo_class_MongoDB_Driver_Server___construct, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Server, executeBulkWrite, arginfo_class_MongoDB_Driver_Server_executeBulkWrite, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Server, executeBulkWrite, arginfo_class_MongoDB_Driver_Server_executeBulkWrite, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Server, executeCommand, arginfo_class_MongoDB_Driver_Server_executeCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Server, executeCommand, arginfo_class_MongoDB_Driver_Server_executeCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Server, executeQuery, arginfo_class_MongoDB_Driver_Server_executeQuery, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Server, executeQuery, arginfo_class_MongoDB_Driver_Server_executeQuery, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_Server, executeReadCommand, arginfo_class_MongoDB_Driver_Server_executeReadCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, executeReadWriteCommand, arginfo_class_MongoDB_Driver_Server_executeReadWriteCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, executeWriteCommand, arginfo_class_MongoDB_Driver_Server_executeWriteCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, getHost, arginfo_class_MongoDB_Driver_Server_getHost, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, getInfo, arginfo_class_MongoDB_Driver_Server_getInfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, getLatency, arginfo_class_MongoDB_Driver_Server_getLatency, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, getPort, arginfo_class_MongoDB_Driver_Server_getPort, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, getServerDescription, arginfo_class_MongoDB_Driver_Server_getServerDescription, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, getTags, arginfo_class_MongoDB_Driver_Server_getTags, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, getType, arginfo_class_MongoDB_Driver_Server_getType, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, isArbiter, arginfo_class_MongoDB_Driver_Server_isArbiter, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, isHidden, arginfo_class_MongoDB_Driver_Server_isHidden, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, isPassive, arginfo_class_MongoDB_Driver_Server_isPassive, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, isPrimary, arginfo_class_MongoDB_Driver_Server_isPrimary, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, isSecondary, arginfo_class_MongoDB_Driver_Server_isSecondary, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Server, __wakeup, arginfo_class_MongoDB_Driver_Server___wakeup, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_Server(void) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Server", class_MongoDB_Driver_Server_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + + zval const_TYPE_UNKNOWN_value; + ZVAL_LONG(&const_TYPE_UNKNOWN_value, PHONGO_SERVER_UNKNOWN); + zend_string *const_TYPE_UNKNOWN_name = zend_string_init_interned("TYPE_UNKNOWN", sizeof("TYPE_UNKNOWN") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_UNKNOWN_name, &const_TYPE_UNKNOWN_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_UNKNOWN_name); + + zval const_TYPE_STANDALONE_value; + ZVAL_LONG(&const_TYPE_STANDALONE_value, PHONGO_SERVER_STANDALONE); + zend_string *const_TYPE_STANDALONE_name = zend_string_init_interned("TYPE_STANDALONE", sizeof("TYPE_STANDALONE") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_STANDALONE_name, &const_TYPE_STANDALONE_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_STANDALONE_name); + + zval const_TYPE_MONGOS_value; + ZVAL_LONG(&const_TYPE_MONGOS_value, PHONGO_SERVER_MONGOS); + zend_string *const_TYPE_MONGOS_name = zend_string_init_interned("TYPE_MONGOS", sizeof("TYPE_MONGOS") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_MONGOS_name, &const_TYPE_MONGOS_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_MONGOS_name); + + zval const_TYPE_POSSIBLE_PRIMARY_value; + ZVAL_LONG(&const_TYPE_POSSIBLE_PRIMARY_value, PHONGO_SERVER_POSSIBLE_PRIMARY); + zend_string *const_TYPE_POSSIBLE_PRIMARY_name = zend_string_init_interned("TYPE_POSSIBLE_PRIMARY", sizeof("TYPE_POSSIBLE_PRIMARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_POSSIBLE_PRIMARY_name, &const_TYPE_POSSIBLE_PRIMARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_POSSIBLE_PRIMARY_name); + + zval const_TYPE_RS_PRIMARY_value; + ZVAL_LONG(&const_TYPE_RS_PRIMARY_value, PHONGO_SERVER_RS_PRIMARY); + zend_string *const_TYPE_RS_PRIMARY_name = zend_string_init_interned("TYPE_RS_PRIMARY", sizeof("TYPE_RS_PRIMARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_RS_PRIMARY_name, &const_TYPE_RS_PRIMARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_RS_PRIMARY_name); + + zval const_TYPE_RS_SECONDARY_value; + ZVAL_LONG(&const_TYPE_RS_SECONDARY_value, PHONGO_SERVER_RS_SECONDARY); + zend_string *const_TYPE_RS_SECONDARY_name = zend_string_init_interned("TYPE_RS_SECONDARY", sizeof("TYPE_RS_SECONDARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_RS_SECONDARY_name, &const_TYPE_RS_SECONDARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_RS_SECONDARY_name); + + zval const_TYPE_RS_ARBITER_value; + ZVAL_LONG(&const_TYPE_RS_ARBITER_value, PHONGO_SERVER_RS_ARBITER); + zend_string *const_TYPE_RS_ARBITER_name = zend_string_init_interned("TYPE_RS_ARBITER", sizeof("TYPE_RS_ARBITER") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_RS_ARBITER_name, &const_TYPE_RS_ARBITER_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_RS_ARBITER_name); + + zval const_TYPE_RS_OTHER_value; + ZVAL_LONG(&const_TYPE_RS_OTHER_value, PHONGO_SERVER_RS_OTHER); + zend_string *const_TYPE_RS_OTHER_name = zend_string_init_interned("TYPE_RS_OTHER", sizeof("TYPE_RS_OTHER") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_RS_OTHER_name, &const_TYPE_RS_OTHER_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_RS_OTHER_name); + + zval const_TYPE_RS_GHOST_value; + ZVAL_LONG(&const_TYPE_RS_GHOST_value, PHONGO_SERVER_RS_GHOST); + zend_string *const_TYPE_RS_GHOST_name = zend_string_init_interned("TYPE_RS_GHOST", sizeof("TYPE_RS_GHOST") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_RS_GHOST_name, &const_TYPE_RS_GHOST_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_RS_GHOST_name); + + zval const_TYPE_LOAD_BALANCER_value; + ZVAL_LONG(&const_TYPE_LOAD_BALANCER_value, PHONGO_SERVER_LOAD_BALANCER); + zend_string *const_TYPE_LOAD_BALANCER_name = zend_string_init_interned("TYPE_LOAD_BALANCER", sizeof("TYPE_LOAD_BALANCER") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_LOAD_BALANCER_name, &const_TYPE_LOAD_BALANCER_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_LOAD_BALANCER_name); + + return class_entry; +} diff --git a/src/MongoDB/Session.c b/src/MongoDB/Session.c index 794beb9fa..12b187a62 100644 --- a/src/MongoDB/Session.c +++ b/src/MongoDB/Session.c @@ -32,15 +32,10 @@ #include "MongoDB/Server.h" #include "MongoDB/Session.h" #include "MongoDB/WriteConcern.h" +#include "Session_arginfo.h" zend_class_entry* php_phongo_session_ce; -#define PHONGO_TRANSACTION_NONE "none" -#define PHONGO_TRANSACTION_STARTING "starting" -#define PHONGO_TRANSACTION_IN_PROGRESS "in_progress" -#define PHONGO_TRANSACTION_COMMITTED "committed" -#define PHONGO_TRANSACTION_ABORTED "aborted" - #define SESSION_CHECK_LIVELINESS(i, m) \ if (!(i)->client_session) { \ phongo_throw_exception( \ @@ -159,9 +154,12 @@ static void php_phongo_transaction_options_to_zval(mongoc_client_session_t* cs, mongoc_transaction_opts_destroy(opts); } +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Session) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Session) + /* {{{ proto void MongoDB\Driver\Session::advanceClusterTime(array|object $clusterTime) Advances the cluster time for this Session */ -static PHP_METHOD(Session, advanceClusterTime) +static PHP_METHOD(MongoDB_Driver_Session, advanceClusterTime) { php_phongo_session_t* intern; zval* zcluster_time; @@ -189,7 +187,7 @@ static PHP_METHOD(Session, advanceClusterTime) /* {{{ proto void MongoDB\Driver\Session::advanceOperationTime(MongoDB\BSON\TimestampInterface $timestamp) Advances the operation time for this Session */ -static PHP_METHOD(Session, advanceOperationTime) +static PHP_METHOD(MongoDB_Driver_Session, advanceOperationTime) { php_phongo_session_t* intern; zval* ztimestamp; @@ -212,7 +210,7 @@ static PHP_METHOD(Session, advanceOperationTime) /* {{{ proto object|null MongoDB\Driver\Session::getClusterTime() Returns the cluster time for this Session */ -static PHP_METHOD(Session, getClusterTime) +static PHP_METHOD(MongoDB_Driver_Session, getClusterTime) { php_phongo_session_t* intern; const bson_t* cluster_time; @@ -242,7 +240,7 @@ static PHP_METHOD(Session, getClusterTime) /* {{{ proto object MongoDB\Driver\Session::getLogicalSessionId() Returns the logical session ID for this Session */ -static PHP_METHOD(Session, getLogicalSessionId) +static PHP_METHOD(MongoDB_Driver_Session, getLogicalSessionId) { php_phongo_session_t* intern; const bson_t* lsid; @@ -268,7 +266,7 @@ static PHP_METHOD(Session, getLogicalSessionId) /* {{{ proto MongoDB\BSON\Timestamp|null MongoDB\Driver\Session::getOperationTime() Returns the operation time for this Session */ -static PHP_METHOD(Session, getOperationTime) +static PHP_METHOD(MongoDB_Driver_Session, getOperationTime) { php_phongo_session_t* intern; uint32_t timestamp, increment; @@ -292,7 +290,7 @@ static PHP_METHOD(Session, getOperationTime) /* {{{ proto MongoDB\Driver\Server|null MongoDB\Driver\Session::getServer() Returns the server this session is pinned to */ -static PHP_METHOD(Session, getServer) +static PHP_METHOD(MongoDB_Driver_Session, getServer) { php_phongo_session_t* intern; uint32_t server_id = 0; @@ -314,7 +312,7 @@ static PHP_METHOD(Session, getServer) /* {{{ proto array|null MongoDB\Driver\Session::getTransactionOptions() Returns options for the currently running transaction */ -static PHP_METHOD(Session, getTransactionOptions) +static PHP_METHOD(MongoDB_Driver_Session, getTransactionOptions) { php_phongo_session_t* intern; @@ -328,7 +326,7 @@ static PHP_METHOD(Session, getTransactionOptions) /* {{{ proto string MongoDB\Driver\Session::getTransactionState() Returns the current transaction state for this session */ -static PHP_METHOD(Session, getTransactionState) +static PHP_METHOD(MongoDB_Driver_Session, getTransactionState) { php_phongo_session_t* intern; const char* state; @@ -446,7 +444,7 @@ mongoc_transaction_opt_t* php_mongodb_session_parse_transaction_options(zval* op /* {{{ proto void MongoDB\Driver\Session::startTransaction([array $options = null]) Starts a new transaction */ -static PHP_METHOD(Session, startTransaction) +static PHP_METHOD(MongoDB_Driver_Session, startTransaction) { php_phongo_session_t* intern; zval* options = NULL; @@ -479,7 +477,7 @@ static PHP_METHOD(Session, startTransaction) /* {{{ proto void MongoDB\Driver\Session::commitTransaction(void) Commits an existing transaction */ -static PHP_METHOD(Session, commitTransaction) +static PHP_METHOD(MongoDB_Driver_Session, commitTransaction) { php_phongo_session_t* intern; bson_error_t error; @@ -499,7 +497,7 @@ static PHP_METHOD(Session, commitTransaction) /* {{{ proto void MongoDB\Driver\Session::abortTransaction(void) Aborts (rolls back) an existing transaction */ -static PHP_METHOD(Session, abortTransaction) +static PHP_METHOD(MongoDB_Driver_Session, abortTransaction) { php_phongo_session_t* intern; bson_error_t error; @@ -516,7 +514,7 @@ static PHP_METHOD(Session, abortTransaction) /* {{{ proto void MongoDB\Driver\Session::endSession(void) Ends the session, and a running transaction if active */ -static PHP_METHOD(Session, endSession) +static PHP_METHOD(MongoDB_Driver_Session, endSession) { php_phongo_session_t* intern; @@ -532,7 +530,7 @@ static PHP_METHOD(Session, endSession) Returns whether the session is dirty (i.e. was used with a command that encountered a network error) and will be discarded when returned to the server session pool. */ -static PHP_METHOD(Session, isDirty) +static PHP_METHOD(MongoDB_Driver_Session, isDirty) { php_phongo_session_t* intern = Z_SESSION_OBJ_P(getThis()); @@ -545,7 +543,7 @@ static PHP_METHOD(Session, isDirty) /* {{{ proto void MongoDB\Driver\Session::isInTransaction(void) Returns whether a multi-document transaction is in progress */ -static PHP_METHOD(Session, isInTransaction) +static PHP_METHOD(MongoDB_Driver_Session, isInTransaction) { php_phongo_session_t* intern; @@ -557,45 +555,6 @@ static PHP_METHOD(Session, isInTransaction) RETURN_BOOL(mongoc_client_session_in_transaction(intern->client_session)); } /* }}} */ -/* {{{ MongoDB\Driver\Session function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_Session_advanceClusterTime, 0, 0, 1) - ZEND_ARG_INFO(0, clusterTime) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Session_advanceOperationTime, 0, 0, 1) - ZEND_ARG_INFO(0, timestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Session_startTransaction, 0, 0, 0) - ZEND_ARG_ARRAY_INFO(0, options, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_Session_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_session_me[] = { - /* clang-format off */ - PHP_ME(Session, abortTransaction, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, advanceClusterTime, ai_Session_advanceClusterTime, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, advanceOperationTime, ai_Session_advanceOperationTime, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, commitTransaction, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, endSession, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, getClusterTime, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, getLogicalSessionId, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, getOperationTime, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, getServer, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, getTransactionOptions, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, getTransactionState, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, isDirty, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, isInTransaction, ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(Session, startTransaction, ai_Session_startTransaction, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_Session_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_Session_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\Session object handlers */ static zend_object_handlers php_phongo_handler_session; @@ -746,24 +705,14 @@ static HashTable* php_phongo_session_get_debug_info(phongo_compat_object_handler void php_phongo_session_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Session", php_phongo_session_me); - php_phongo_session_ce = zend_register_internal_class(&ce); + php_phongo_session_ce = register_class_MongoDB_Driver_Session(); php_phongo_session_ce->create_object = php_phongo_session_create_object; - PHONGO_CE_FINAL(php_phongo_session_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_session_ce); memcpy(&php_phongo_handler_session, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_session.get_debug_info = php_phongo_session_get_debug_info; php_phongo_handler_session.free_obj = php_phongo_session_free_object; php_phongo_handler_session.offset = XtOffsetOf(php_phongo_session_t, std); - - zend_declare_class_constant_string(php_phongo_session_ce, ZEND_STRL("TRANSACTION_NONE"), PHONGO_TRANSACTION_NONE); - zend_declare_class_constant_string(php_phongo_session_ce, ZEND_STRL("TRANSACTION_STARTING"), PHONGO_TRANSACTION_STARTING); - zend_declare_class_constant_string(php_phongo_session_ce, ZEND_STRL("TRANSACTION_IN_PROGRESS"), PHONGO_TRANSACTION_IN_PROGRESS); - zend_declare_class_constant_string(php_phongo_session_ce, ZEND_STRL("TRANSACTION_COMMITTED"), PHONGO_TRANSACTION_COMMITTED); - zend_declare_class_constant_string(php_phongo_session_ce, ZEND_STRL("TRANSACTION_ABORTED"), PHONGO_TRANSACTION_ABORTED); } /* }}} */ void phongo_session_init(zval* return_value, zval* manager, mongoc_client_session_t* client_session) /* {{{ */ diff --git a/src/MongoDB/Session.h b/src/MongoDB/Session.h index 9162ffb79..5e8caaabc 100644 --- a/src/MongoDB/Session.h +++ b/src/MongoDB/Session.h @@ -21,6 +21,12 @@ #include +#define PHONGO_TRANSACTION_NONE "none" +#define PHONGO_TRANSACTION_STARTING "starting" +#define PHONGO_TRANSACTION_IN_PROGRESS "in_progress" +#define PHONGO_TRANSACTION_COMMITTED "committed" +#define PHONGO_TRANSACTION_ABORTED "aborted" + mongoc_transaction_opt_t* php_mongodb_session_parse_transaction_options(zval* txnOptions); void phongo_session_init(zval* return_value, zval* manager, mongoc_client_session_t* client_session); diff --git a/src/MongoDB/Session.stub.php b/src/MongoDB/Session.stub.php new file mode 100644 index 000000000..eea01fcf4 --- /dev/null +++ b/src/MongoDB/Session.stub.php @@ -0,0 +1,78 @@ += 80000 + final public function advanceClusterTime(array|object $clusterTime): void {} +#else + /** @param array|object $clusterTime */ + final public function advanceClusterTime($clusterTime): void {} +#endif + + final public function advanceOperationTime(\MongoDB\BSON\TimestampInterface $operationTime): void {} + + final public function commitTransaction(): void {} + + final public function endSession(): void {} + + final public function getClusterTime(): ?object {} + + final public function getLogicalSessionId(): object {} + + final public function getOperationTime(): ?\MongoDB\BSON\Timestamp {} + + final public function getServer(): ?Server {} + + final public function getTransactionOptions(): ?array {} + + final public function getTransactionState(): string {} + + final public function isDirty(): bool {} + + final public function isInTransaction(): bool {} + + final public function startTransaction(?array $options = []): void {} + + final public function __wakeup(): void {} +} diff --git a/src/MongoDB/Session_arginfo.h b/src/MongoDB/Session_arginfo.h new file mode 100644 index 000000000..aa94f27bd --- /dev/null +++ b/src/MongoDB/Session_arginfo.h @@ -0,0 +1,152 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: fbf742d6b12a1bf6e04201a81b08e3b26b8e261c */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Session___construct, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Session_abortTransaction, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Session_advanceClusterTime, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_MASK(0, clusterTime, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Session_advanceClusterTime, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, clusterTime) +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Session_advanceOperationTime, 0, 1, IS_VOID, 0) + ZEND_ARG_OBJ_INFO(0, operationTime, MongoDB\\BSON\\TimestampInterface, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_Session_commitTransaction arginfo_class_MongoDB_Driver_Session_abortTransaction + +#define arginfo_class_MongoDB_Driver_Session_endSession arginfo_class_MongoDB_Driver_Session_abortTransaction + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Session_getClusterTime, 0, 0, IS_OBJECT, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Session_getLogicalSessionId, 0, 0, IS_OBJECT, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Session_getOperationTime, 0, 0, MongoDB\\BSON\\Timestamp, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Session_getServer, 0, 0, MongoDB\\Driver\\Server, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Session_getTransactionOptions, 0, 0, IS_ARRAY, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Session_getTransactionState, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Session_isDirty, 0, 0, _IS_BOOL, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_Session_isInTransaction arginfo_class_MongoDB_Driver_Session_isDirty + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Session_startTransaction, 0, 0, IS_VOID, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "[]") +ZEND_END_ARG_INFO() + +#define arginfo_class_MongoDB_Driver_Session___wakeup arginfo_class_MongoDB_Driver_Session_abortTransaction + + +static ZEND_METHOD(MongoDB_Driver_Session, __construct); +static ZEND_METHOD(MongoDB_Driver_Session, abortTransaction); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_Session, advanceClusterTime); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_Session, advanceClusterTime); +#endif +static ZEND_METHOD(MongoDB_Driver_Session, advanceOperationTime); +static ZEND_METHOD(MongoDB_Driver_Session, commitTransaction); +static ZEND_METHOD(MongoDB_Driver_Session, endSession); +static ZEND_METHOD(MongoDB_Driver_Session, getClusterTime); +static ZEND_METHOD(MongoDB_Driver_Session, getLogicalSessionId); +static ZEND_METHOD(MongoDB_Driver_Session, getOperationTime); +static ZEND_METHOD(MongoDB_Driver_Session, getServer); +static ZEND_METHOD(MongoDB_Driver_Session, getTransactionOptions); +static ZEND_METHOD(MongoDB_Driver_Session, getTransactionState); +static ZEND_METHOD(MongoDB_Driver_Session, isDirty); +static ZEND_METHOD(MongoDB_Driver_Session, isInTransaction); +static ZEND_METHOD(MongoDB_Driver_Session, startTransaction); +static ZEND_METHOD(MongoDB_Driver_Session, __wakeup); + + +static const zend_function_entry class_MongoDB_Driver_Session_methods[] = { + ZEND_ME(MongoDB_Driver_Session, __construct, arginfo_class_MongoDB_Driver_Session___construct, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, abortTransaction, arginfo_class_MongoDB_Driver_Session_abortTransaction, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_Session, advanceClusterTime, arginfo_class_MongoDB_Driver_Session_advanceClusterTime, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_Session, advanceClusterTime, arginfo_class_MongoDB_Driver_Session_advanceClusterTime, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_Session, advanceOperationTime, arginfo_class_MongoDB_Driver_Session_advanceOperationTime, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, commitTransaction, arginfo_class_MongoDB_Driver_Session_commitTransaction, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, endSession, arginfo_class_MongoDB_Driver_Session_endSession, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, getClusterTime, arginfo_class_MongoDB_Driver_Session_getClusterTime, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, getLogicalSessionId, arginfo_class_MongoDB_Driver_Session_getLogicalSessionId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, getOperationTime, arginfo_class_MongoDB_Driver_Session_getOperationTime, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, getServer, arginfo_class_MongoDB_Driver_Session_getServer, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, getTransactionOptions, arginfo_class_MongoDB_Driver_Session_getTransactionOptions, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, getTransactionState, arginfo_class_MongoDB_Driver_Session_getTransactionState, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, isDirty, arginfo_class_MongoDB_Driver_Session_isDirty, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, isInTransaction, arginfo_class_MongoDB_Driver_Session_isInTransaction, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, startTransaction, arginfo_class_MongoDB_Driver_Session_startTransaction, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Session, __wakeup, arginfo_class_MongoDB_Driver_Session___wakeup, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_Session(void) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Session", class_MongoDB_Driver_Session_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + + zval const_TRANSACTION_NONE_value; + zend_string *const_TRANSACTION_NONE_value_str = zend_string_init(PHONGO_TRANSACTION_NONE, sizeof(PHONGO_TRANSACTION_NONE) - 1, 1); + ZVAL_STR(&const_TRANSACTION_NONE_value, const_TRANSACTION_NONE_value_str); + zend_string *const_TRANSACTION_NONE_name = zend_string_init_interned("TRANSACTION_NONE", sizeof("TRANSACTION_NONE") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TRANSACTION_NONE_name, &const_TRANSACTION_NONE_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TRANSACTION_NONE_name); + + zval const_TRANSACTION_STARTING_value; + zend_string *const_TRANSACTION_STARTING_value_str = zend_string_init(PHONGO_TRANSACTION_STARTING, sizeof(PHONGO_TRANSACTION_STARTING) - 1, 1); + ZVAL_STR(&const_TRANSACTION_STARTING_value, const_TRANSACTION_STARTING_value_str); + zend_string *const_TRANSACTION_STARTING_name = zend_string_init_interned("TRANSACTION_STARTING", sizeof("TRANSACTION_STARTING") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TRANSACTION_STARTING_name, &const_TRANSACTION_STARTING_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TRANSACTION_STARTING_name); + + zval const_TRANSACTION_IN_PROGRESS_value; + zend_string *const_TRANSACTION_IN_PROGRESS_value_str = zend_string_init(PHONGO_TRANSACTION_IN_PROGRESS, sizeof(PHONGO_TRANSACTION_IN_PROGRESS) - 1, 1); + ZVAL_STR(&const_TRANSACTION_IN_PROGRESS_value, const_TRANSACTION_IN_PROGRESS_value_str); + zend_string *const_TRANSACTION_IN_PROGRESS_name = zend_string_init_interned("TRANSACTION_IN_PROGRESS", sizeof("TRANSACTION_IN_PROGRESS") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TRANSACTION_IN_PROGRESS_name, &const_TRANSACTION_IN_PROGRESS_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TRANSACTION_IN_PROGRESS_name); + + zval const_TRANSACTION_COMMITTED_value; + zend_string *const_TRANSACTION_COMMITTED_value_str = zend_string_init(PHONGO_TRANSACTION_COMMITTED, sizeof(PHONGO_TRANSACTION_COMMITTED) - 1, 1); + ZVAL_STR(&const_TRANSACTION_COMMITTED_value, const_TRANSACTION_COMMITTED_value_str); + zend_string *const_TRANSACTION_COMMITTED_name = zend_string_init_interned("TRANSACTION_COMMITTED", sizeof("TRANSACTION_COMMITTED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TRANSACTION_COMMITTED_name, &const_TRANSACTION_COMMITTED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TRANSACTION_COMMITTED_name); + + zval const_TRANSACTION_ABORTED_value; + zend_string *const_TRANSACTION_ABORTED_value_str = zend_string_init(PHONGO_TRANSACTION_ABORTED, sizeof(PHONGO_TRANSACTION_ABORTED) - 1, 1); + ZVAL_STR(&const_TRANSACTION_ABORTED_value, const_TRANSACTION_ABORTED_value_str); + zend_string *const_TRANSACTION_ABORTED_name = zend_string_init_interned("TRANSACTION_ABORTED", sizeof("TRANSACTION_ABORTED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TRANSACTION_ABORTED_name, &const_TRANSACTION_ABORTED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TRANSACTION_ABORTED_name); + + return class_entry; +} diff --git a/src/MongoDB/TopologyDescription.c b/src/MongoDB/TopologyDescription.c index a87c45547..4af120f5b 100644 --- a/src/MongoDB/TopologyDescription.c +++ b/src/MongoDB/TopologyDescription.c @@ -27,21 +27,16 @@ #include "MongoDB/ReadPreference.h" #include "MongoDB/ServerDescription.h" #include "MongoDB/TopologyDescription.h" +#include "TopologyDescription_arginfo.h" zend_class_entry* php_phongo_topologydescription_ce; -/* Note: these constants are derived from _mongoc_topology_description_type, - * since mongoc_topology_description_t is private. */ -#define PHONGO_TOPOLOGY_UNKNOWN "Unknown" -#define PHONGO_TOPOLOGY_SINGLE "Single" -#define PHONGO_TOPOLOGY_SHARDED "Sharded" -#define PHONGO_TOPOLOGY_REPLICA_SET_NO_PRIMARY "ReplicaSetNoPrimary" -#define PHONGO_TOPOLOGY_REPLICA_SET_WITH_PRIMARY "ReplicaSetWithPrimary" -#define PHONGO_TOPOLOGY_LOAD_BALANCED "LoadBalanced" +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_TopologyDescription) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_TopologyDescription) /* {{{ proto array MongoDB\Driver\TopologyDescription::getServers() Returns an array of ServerDescription objects for all known servers in the topology */ -static PHP_METHOD(TopologyDescription, getServers) +static PHP_METHOD(MongoDB_Driver_TopologyDescription, getServers) { php_phongo_topologydescription_t* intern; mongoc_server_description_t** sds; @@ -66,7 +61,7 @@ static PHP_METHOD(TopologyDescription, getServers) /* {{{ proto boolean MongoDB\Driver\TopologyDescription::hasReadableServer([MongoDB\Driver\ReadPreference $readPreference]) Returns whether the topology has a readable server available */ -static PHP_METHOD(TopologyDescription, hasReadableServer) +static PHP_METHOD(MongoDB_Driver_TopologyDescription, hasReadableServer) { php_phongo_topologydescription_t* intern; const mongoc_read_prefs_t* read_preference = NULL; @@ -88,7 +83,7 @@ static PHP_METHOD(TopologyDescription, hasReadableServer) /* {{{ proto boolean MongoDB\Driver\TopologyDescription::hasWritableServer() Returns whether the topology has a writable server available */ -static PHP_METHOD(TopologyDescription, hasWritableServer) +static PHP_METHOD(MongoDB_Driver_TopologyDescription, hasWritableServer) { php_phongo_topologydescription_t* intern = Z_TOPOLOGYDESCRIPTION_OBJ_P(getThis()); @@ -99,7 +94,7 @@ static PHP_METHOD(TopologyDescription, hasWritableServer) /* {{{ proto string MongoDB\Driver\TopologyDescription::getType() Returns the topology type */ -static PHP_METHOD(TopologyDescription, getType) +static PHP_METHOD(MongoDB_Driver_TopologyDescription, getType) { php_phongo_topologydescription_t* intern = Z_TOPOLOGYDESCRIPTION_OBJ_P(getThis()); @@ -108,26 +103,6 @@ static PHP_METHOD(TopologyDescription, getType) RETVAL_STRING(mongoc_topology_description_type(intern->topology_description)); } /* }}} */ -/* {{{ MongoDB\Driver\TopologyDescription function entries */ -/* clang-format off */ -ZEND_BEGIN_ARG_INFO_EX(ai_TopologyDescription_hasReadableServer, 0, 0, 0) - ZEND_ARG_OBJ_INFO(0, readPreference, MongoDB\\Driver\\ReadPreference, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_TopologyDescription_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_topologydescription_me[] = { - PHP_ME(TopologyDescription, getServers, ai_TopologyDescription_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(TopologyDescription, hasReadableServer, ai_TopologyDescription_hasReadableServer, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(TopologyDescription, hasWritableServer, ai_TopologyDescription_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(TopologyDescription, getType, ai_TopologyDescription_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_TopologyDescription_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - PHP_FE_END -}; -/* clang-format on */ -/* }}} */ - /* {{{ MongoDB\Driver\TopologyDescription object handlers */ static zend_object_handlers php_phongo_handler_topologydescription; @@ -213,12 +188,8 @@ static HashTable* php_phongo_topologydescription_get_properties(phongo_compat_ob void php_phongo_topologydescription_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "TopologyDescription", php_phongo_topologydescription_me); - php_phongo_topologydescription_ce = zend_register_internal_class(&ce); + php_phongo_topologydescription_ce = register_class_MongoDB_Driver_TopologyDescription(); php_phongo_topologydescription_ce->create_object = php_phongo_topologydescription_create_object; - PHONGO_CE_FINAL(php_phongo_topologydescription_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_topologydescription_ce); memcpy(&php_phongo_handler_topologydescription, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); @@ -226,13 +197,6 @@ void php_phongo_topologydescription_init_ce(INIT_FUNC_ARGS) /* {{{ */ php_phongo_handler_topologydescription.get_properties = php_phongo_topologydescription_get_properties; php_phongo_handler_topologydescription.free_obj = php_phongo_topologydescription_free_object; php_phongo_handler_topologydescription.offset = XtOffsetOf(php_phongo_topologydescription_t, std); - - zend_declare_class_constant_string(php_phongo_topologydescription_ce, ZEND_STRL("TYPE_UNKNOWN"), PHONGO_TOPOLOGY_UNKNOWN); - zend_declare_class_constant_string(php_phongo_topologydescription_ce, ZEND_STRL("TYPE_SINGLE"), PHONGO_TOPOLOGY_SINGLE); - zend_declare_class_constant_string(php_phongo_topologydescription_ce, ZEND_STRL("TYPE_SHARDED"), PHONGO_TOPOLOGY_SHARDED); - zend_declare_class_constant_string(php_phongo_topologydescription_ce, ZEND_STRL("TYPE_REPLICA_SET_NO_PRIMARY"), PHONGO_TOPOLOGY_REPLICA_SET_NO_PRIMARY); - zend_declare_class_constant_string(php_phongo_topologydescription_ce, ZEND_STRL("TYPE_REPLICA_SET_WITH_PRIMARY"), PHONGO_TOPOLOGY_REPLICA_SET_WITH_PRIMARY); - zend_declare_class_constant_string(php_phongo_topologydescription_ce, ZEND_STRL("TYPE_LOAD_BALANCED"), PHONGO_TOPOLOGY_LOAD_BALANCED); } /* }}} */ void phongo_topologydescription_init(zval* return_value, mongoc_topology_description_t* topology_description) /* {{{ */ diff --git a/src/MongoDB/TopologyDescription.h b/src/MongoDB/TopologyDescription.h index 2e5af3697..66c2631c8 100644 --- a/src/MongoDB/TopologyDescription.h +++ b/src/MongoDB/TopologyDescription.h @@ -21,6 +21,15 @@ #include +/* Note: these constants are derived from _mongoc_topology_description_type, + * since mongoc_topology_description_t is private. */ +#define PHONGO_TOPOLOGY_UNKNOWN "Unknown" +#define PHONGO_TOPOLOGY_SINGLE "Single" +#define PHONGO_TOPOLOGY_SHARDED "Sharded" +#define PHONGO_TOPOLOGY_REPLICA_SET_NO_PRIMARY "ReplicaSetNoPrimary" +#define PHONGO_TOPOLOGY_REPLICA_SET_WITH_PRIMARY "ReplicaSetWithPrimary" +#define PHONGO_TOPOLOGY_LOAD_BALANCED "LoadBalanced" + void phongo_topologydescription_init(zval* return_value, mongoc_topology_description_t* topology_description); #endif /* PHONGO_TOPOLOGYDESCRIPTION_H */ diff --git a/src/MongoDB/TopologyDescription.stub.php b/src/MongoDB/TopologyDescription.stub.php new file mode 100644 index 000000000..5c2c61163 --- /dev/null +++ b/src/MongoDB/TopologyDescription.stub.php @@ -0,0 +1,59 @@ +ce_flags |= ZEND_ACC_FINAL; + + zval const_TYPE_UNKNOWN_value; + zend_string *const_TYPE_UNKNOWN_value_str = zend_string_init(PHONGO_TOPOLOGY_UNKNOWN, sizeof(PHONGO_TOPOLOGY_UNKNOWN) - 1, 1); + ZVAL_STR(&const_TYPE_UNKNOWN_value, const_TYPE_UNKNOWN_value_str); + zend_string *const_TYPE_UNKNOWN_name = zend_string_init_interned("TYPE_UNKNOWN", sizeof("TYPE_UNKNOWN") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_UNKNOWN_name, &const_TYPE_UNKNOWN_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_UNKNOWN_name); + + zval const_TYPE_SINGLE_value; + zend_string *const_TYPE_SINGLE_value_str = zend_string_init(PHONGO_TOPOLOGY_SINGLE, sizeof(PHONGO_TOPOLOGY_SINGLE) - 1, 1); + ZVAL_STR(&const_TYPE_SINGLE_value, const_TYPE_SINGLE_value_str); + zend_string *const_TYPE_SINGLE_name = zend_string_init_interned("TYPE_SINGLE", sizeof("TYPE_SINGLE") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_SINGLE_name, &const_TYPE_SINGLE_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_SINGLE_name); + + zval const_TYPE_SHARDED_value; + zend_string *const_TYPE_SHARDED_value_str = zend_string_init(PHONGO_TOPOLOGY_SHARDED, sizeof(PHONGO_TOPOLOGY_SHARDED) - 1, 1); + ZVAL_STR(&const_TYPE_SHARDED_value, const_TYPE_SHARDED_value_str); + zend_string *const_TYPE_SHARDED_name = zend_string_init_interned("TYPE_SHARDED", sizeof("TYPE_SHARDED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_SHARDED_name, &const_TYPE_SHARDED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_SHARDED_name); + + zval const_TYPE_REPLICA_SET_NO_PRIMARY_value; + zend_string *const_TYPE_REPLICA_SET_NO_PRIMARY_value_str = zend_string_init(PHONGO_TOPOLOGY_REPLICA_SET_NO_PRIMARY, sizeof(PHONGO_TOPOLOGY_REPLICA_SET_NO_PRIMARY) - 1, 1); + ZVAL_STR(&const_TYPE_REPLICA_SET_NO_PRIMARY_value, const_TYPE_REPLICA_SET_NO_PRIMARY_value_str); + zend_string *const_TYPE_REPLICA_SET_NO_PRIMARY_name = zend_string_init_interned("TYPE_REPLICA_SET_NO_PRIMARY", sizeof("TYPE_REPLICA_SET_NO_PRIMARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_REPLICA_SET_NO_PRIMARY_name, &const_TYPE_REPLICA_SET_NO_PRIMARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_REPLICA_SET_NO_PRIMARY_name); + + zval const_TYPE_REPLICA_SET_WITH_PRIMARY_value; + zend_string *const_TYPE_REPLICA_SET_WITH_PRIMARY_value_str = zend_string_init(PHONGO_TOPOLOGY_REPLICA_SET_WITH_PRIMARY, sizeof(PHONGO_TOPOLOGY_REPLICA_SET_WITH_PRIMARY) - 1, 1); + ZVAL_STR(&const_TYPE_REPLICA_SET_WITH_PRIMARY_value, const_TYPE_REPLICA_SET_WITH_PRIMARY_value_str); + zend_string *const_TYPE_REPLICA_SET_WITH_PRIMARY_name = zend_string_init_interned("TYPE_REPLICA_SET_WITH_PRIMARY", sizeof("TYPE_REPLICA_SET_WITH_PRIMARY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_REPLICA_SET_WITH_PRIMARY_name, &const_TYPE_REPLICA_SET_WITH_PRIMARY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_REPLICA_SET_WITH_PRIMARY_name); + + zval const_TYPE_LOAD_BALANCED_value; + zend_string *const_TYPE_LOAD_BALANCED_value_str = zend_string_init(PHONGO_TOPOLOGY_LOAD_BALANCED, sizeof(PHONGO_TOPOLOGY_LOAD_BALANCED) - 1, 1); + ZVAL_STR(&const_TYPE_LOAD_BALANCED_value, const_TYPE_LOAD_BALANCED_value_str); + zend_string *const_TYPE_LOAD_BALANCED_name = zend_string_init_interned("TYPE_LOAD_BALANCED", sizeof("TYPE_LOAD_BALANCED") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TYPE_LOAD_BALANCED_name, &const_TYPE_LOAD_BALANCED_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TYPE_LOAD_BALANCED_name); + + return class_entry; +} diff --git a/src/MongoDB/WriteConcern.c b/src/MongoDB/WriteConcern.c index 8d31b9f76..ba31bdac1 100644 --- a/src/MongoDB/WriteConcern.c +++ b/src/MongoDB/WriteConcern.c @@ -26,6 +26,7 @@ #include "phongo_util.h" #include "MongoDB/WriteConcern.h" +#include "WriteConcern_arginfo.h" zend_class_entry* php_phongo_writeconcern_ce; @@ -108,7 +109,7 @@ static bool php_phongo_writeconcern_init_from_hash(php_phongo_writeconcern_t* in /* {{{ proto void MongoDB\Driver\WriteConcern::__construct(integer|string $w[, integer $wtimeout[, boolean $journal]]) Constructs a new WriteConcern */ -static PHP_METHOD(WriteConcern, __construct) +static PHP_METHOD(MongoDB_Driver_WriteConcern, __construct) { php_phongo_writeconcern_t* intern; zval * w, *journal = NULL; @@ -171,7 +172,7 @@ static PHP_METHOD(WriteConcern, __construct) /* {{{ proto MongoDB\Driver\WriteConcern MongoDB\Driver\WriteConcern::__set_state(array $properties) */ -static PHP_METHOD(WriteConcern, __set_state) +static PHP_METHOD(MongoDB_Driver_WriteConcern, __set_state) { php_phongo_writeconcern_t* intern; HashTable* props; @@ -191,7 +192,7 @@ static PHP_METHOD(WriteConcern, __set_state) /* {{{ proto string|integer|null MongoDB\Driver\WriteConcern::getW() Returns the WriteConcern "w" option */ -static PHP_METHOD(WriteConcern, getW) +static PHP_METHOD(MongoDB_Driver_WriteConcern, getW) { php_phongo_writeconcern_t* intern; const char* wtag; @@ -219,7 +220,7 @@ static PHP_METHOD(WriteConcern, getW) /* {{{ proto integer MongoDB\Driver\WriteConcern::getWtimeout() Returns the WriteConcern "wtimeout" option */ -static PHP_METHOD(WriteConcern, getWtimeout) +static PHP_METHOD(MongoDB_Driver_WriteConcern, getWtimeout) { php_phongo_writeconcern_t* intern; int64_t wtimeout; @@ -241,7 +242,7 @@ static PHP_METHOD(WriteConcern, getWtimeout) /* {{{ proto null|boolean MongoDB\Driver\WriteConcern::getJournal() Returns the WriteConcern "journal" option */ -static PHP_METHOD(WriteConcern, getJournal) +static PHP_METHOD(MongoDB_Driver_WriteConcern, getJournal) { php_phongo_writeconcern_t* intern; @@ -259,7 +260,7 @@ static PHP_METHOD(WriteConcern, getJournal) /* {{{ proto boolean MongoDB\Driver\WriteConcern::isDefault() Returns whether the write concern has not been modified (i.e. from a Manager with no write concern URI options). */ -static PHP_METHOD(WriteConcern, isDefault) +static PHP_METHOD(MongoDB_Driver_WriteConcern, isDefault) { php_phongo_writeconcern_t* intern; @@ -343,7 +344,7 @@ static HashTable* php_phongo_writeconcern_get_properties_hash(phongo_compat_obje /* {{{ proto array MongoDB\Driver\WriteConcern::bsonSerialize() */ -static PHP_METHOD(WriteConcern, bsonSerialize) +static PHP_METHOD(MongoDB_Driver_WriteConcern, bsonSerialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -353,7 +354,7 @@ static PHP_METHOD(WriteConcern, bsonSerialize) /* {{{ proto string MongoDB\Driver\WriteConcern::serialize() */ -static PHP_METHOD(WriteConcern, serialize) +static PHP_METHOD(MongoDB_Driver_WriteConcern, serialize) { php_phongo_writeconcern_t* intern; zval retval; @@ -410,7 +411,7 @@ static PHP_METHOD(WriteConcern, serialize) /* {{{ proto void MongoDB\Driver\WriteConcern::unserialize(string $serialized) */ -static PHP_METHOD(WriteConcern, unserialize) +static PHP_METHOD(MongoDB_Driver_WriteConcern, unserialize) { php_phongo_writeconcern_t* intern; char* serialized; @@ -444,7 +445,7 @@ static PHP_METHOD(WriteConcern, unserialize) /* {{{ proto array MongoDB\Driver\WriteConcern::__serialize() */ -static PHP_METHOD(WriteConcern, __serialize) +static PHP_METHOD(MongoDB_Driver_WriteConcern, __serialize) { PHONGO_PARSE_PARAMETERS_NONE(); @@ -453,7 +454,7 @@ static PHP_METHOD(WriteConcern, __serialize) /* {{{ proto void MongoDB\Driver\WriteConcern::__unserialize(array $data) */ -static PHP_METHOD(WriteConcern, __unserialize) +static PHP_METHOD(MongoDB_Driver_WriteConcern, __unserialize) { zval* data; @@ -464,46 +465,6 @@ static PHP_METHOD(WriteConcern, __unserialize) php_phongo_writeconcern_init_from_hash(Z_WRITECONCERN_OBJ_P(getThis()), Z_ARRVAL_P(data)); } /* }}} */ -/* {{{ MongoDB\Driver\WriteConcern function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern___construct, 0, 0, 1) - ZEND_ARG_INFO(0, w) - ZEND_ARG_INFO(0, wtimeout) - ZEND_ARG_INFO(0, journal) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern___set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, properties, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern___unserialize, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, data, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, serialized) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_writeconcern_me[] = { - /* clang-format off */ - PHP_ME(WriteConcern, __construct, ai_WriteConcern___construct, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcern, __serialize, ai_WriteConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcern, __set_state, ai_WriteConcern___set_state, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(WriteConcern, __unserialize, ai_WriteConcern___unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcern, getW, ai_WriteConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcern, getWtimeout, ai_WriteConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcern, getJournal, ai_WriteConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcern, isDefault, ai_WriteConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcern, bsonSerialize, ai_WriteConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcern, serialize, ai_WriteConcern_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcern, unserialize, ai_WriteConcern_unserialize, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\WriteConcern object handlers */ static zend_object_handlers php_phongo_handler_writeconcern; @@ -548,23 +509,14 @@ static HashTable* php_phongo_writeconcern_get_properties(phongo_compat_object_ha void php_phongo_writeconcern_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "WriteConcern", php_phongo_writeconcern_me); - php_phongo_writeconcern_ce = zend_register_internal_class(&ce); + php_phongo_writeconcern_ce = register_class_MongoDB_Driver_WriteConcern(php_phongo_serializable_ce, zend_ce_serializable); php_phongo_writeconcern_ce->create_object = php_phongo_writeconcern_create_object; - PHONGO_CE_FINAL(php_phongo_writeconcern_ce); - - zend_class_implements(php_phongo_writeconcern_ce, 1, php_phongo_serializable_ce); - zend_class_implements(php_phongo_writeconcern_ce, 1, zend_ce_serializable); memcpy(&php_phongo_handler_writeconcern, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); php_phongo_handler_writeconcern.get_debug_info = php_phongo_writeconcern_get_debug_info; php_phongo_handler_writeconcern.get_properties = php_phongo_writeconcern_get_properties; php_phongo_handler_writeconcern.free_obj = php_phongo_writeconcern_free_object; php_phongo_handler_writeconcern.offset = XtOffsetOf(php_phongo_writeconcern_t, std); - - zend_declare_class_constant_stringl(php_phongo_writeconcern_ce, ZEND_STRL("MAJORITY"), ZEND_STRL(PHONGO_WRITE_CONCERN_W_MAJORITY)); } /* }}} */ void phongo_writeconcern_init(zval* return_value, const mongoc_write_concern_t* write_concern) /* {{{ */ diff --git a/src/MongoDB/WriteConcern.stub.php b/src/MongoDB/WriteConcern.stub.php new file mode 100644 index 000000000..ffa00cc02 --- /dev/null +++ b/src/MongoDB/WriteConcern.stub.php @@ -0,0 +1,56 @@ += 80000 + final public function __construct(string|int $w, ?int $wtimeout = null, ?bool $journal = null) {} +#else + /** @param string|int $w */ + final public function __construct($w, ?int $wtimeout = null, ?bool $journal = null) {} +#endif + + final public function getJournal(): ?bool {} + +#if PHP_VERSION_ID >= 80000 + final public function getW(): string|int|null {} +#else + /** @return string|int|null */ + final public function getW() {} +#endif + + final public function getWtimeout(): ?int {} + + final public function isDefault(): bool {} + + public static function __set_state(array $properties): WriteConcern {} + +#if PHP_VERSION_ID >= 80000 + final public function bsonSerialize(): array|object {} +#else + /** @return array|object */ + final public function bsonSerialize() {} +#endif + + final public function serialize(): string {} + + /** @param string $serialized */ + final public function unserialize($serialized): void {} + + final public function __unserialize(array $data): void {} + + final public function __serialize(): array {} + +} diff --git a/src/MongoDB/WriteConcernError.c b/src/MongoDB/WriteConcernError.c index bbe2b7765..2338c9fff 100644 --- a/src/MongoDB/WriteConcernError.c +++ b/src/MongoDB/WriteConcernError.c @@ -23,12 +23,16 @@ #include "phongo_error.h" #include "MongoDB/WriteConcernError.h" +#include "WriteConcernError_arginfo.h" zend_class_entry* php_phongo_writeconcernerror_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_WriteConcernError) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_WriteConcernError) + /* {{{ proto integer MongoDB\Driver\WriteConcernError::getCode() Returns the MongoDB error code */ -static PHP_METHOD(WriteConcernError, getCode) +static PHP_METHOD(MongoDB_Driver_WriteConcernError, getCode) { php_phongo_writeconcernerror_t* intern; @@ -41,7 +45,7 @@ static PHP_METHOD(WriteConcernError, getCode) /* {{{ proto object|null MongoDB\Driver\WriteConcernError::getInfo() Returns additional metadata for the error */ -static PHP_METHOD(WriteConcernError, getInfo) +static PHP_METHOD(MongoDB_Driver_WriteConcernError, getInfo) { php_phongo_writeconcernerror_t* intern; @@ -56,7 +60,7 @@ static PHP_METHOD(WriteConcernError, getInfo) /* {{{ proto string MongoDB\Driver\WriteConcernError::getMessage() Returns the actual error message from the server */ -static PHP_METHOD(WriteConcernError, getMessage) +static PHP_METHOD(MongoDB_Driver_WriteConcernError, getMessage) { php_phongo_writeconcernerror_t* intern; @@ -67,22 +71,6 @@ static PHP_METHOD(WriteConcernError, getMessage) RETURN_STRING(intern->message); } /* }}} */ -/* {{{ MongoDB\Driver\WriteConcernError function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcernError_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_writeconcernerror_me[] = { - /* clang-format off */ - PHP_ME(WriteConcernError, getCode, ai_WriteConcernError_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcernError, getInfo, ai_WriteConcernError_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteConcernError, getMessage, ai_WriteConcernError_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_WriteConcernError_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_WriteConcernError_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\WriteConcernError object handlers */ static zend_object_handlers php_phongo_handler_writeconcernerror; @@ -137,12 +125,8 @@ static HashTable* php_phongo_writeconcernerror_get_debug_info(phongo_compat_obje void php_phongo_writeconcernerror_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "WriteConcernError", php_phongo_writeconcernerror_me); - php_phongo_writeconcernerror_ce = zend_register_internal_class(&ce); + php_phongo_writeconcernerror_ce = register_class_MongoDB_Driver_WriteConcernError(); php_phongo_writeconcernerror_ce->create_object = php_phongo_writeconcernerror_create_object; - PHONGO_CE_FINAL(php_phongo_writeconcernerror_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_writeconcernerror_ce); memcpy(&php_phongo_handler_writeconcernerror, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/WriteConcernError.stub.php b/src/MongoDB/WriteConcernError.stub.php new file mode 100644 index 000000000..08480aebf --- /dev/null +++ b/src/MongoDB/WriteConcernError.stub.php @@ -0,0 +1,21 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/WriteConcern_arginfo.h b/src/MongoDB/WriteConcern_arginfo.h new file mode 100644 index 000000000..6e7a369ac --- /dev/null +++ b/src/MongoDB/WriteConcern_arginfo.h @@ -0,0 +1,142 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: ef3b593831b2de652f8bcac0a72eab5b75eeb073 */ + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern___construct, 0, 0, 1) + ZEND_ARG_TYPE_MASK(0, w, MAY_BE_STRING|MAY_BE_LONG, NULL) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, wtimeout, IS_LONG, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, journal, _IS_BOOL, 1, "null") +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern___construct, 0, 0, 1) + ZEND_ARG_INFO(0, w) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, wtimeout, IS_LONG, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, journal, _IS_BOOL, 1, "null") +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern_getJournal, 0, 0, _IS_BOOL, 1) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_Driver_WriteConcern_getW, 0, 0, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_NULL) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern_getW, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern_getWtimeout, 0, 0, IS_LONG, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern_isDefault, 0, 0, _IS_BOOL, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern___set_state, 0, 1, MongoDB\\Driver\\WriteConcern, 0) + ZEND_ARG_TYPE_INFO(0, properties, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_Driver_WriteConcern_bsonSerialize, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT) +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID >= 80000) +#define arginfo_class_MongoDB_Driver_WriteConcern_bsonSerialize arginfo_class_MongoDB_Driver_WriteConcern_getW +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern_serialize, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern_unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, serialized) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern___unserialize, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_WriteConcern___serialize, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + + +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_WriteConcern, __construct); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_WriteConcern, __construct); +#endif +static ZEND_METHOD(MongoDB_Driver_WriteConcern, getJournal); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_WriteConcern, getW); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_WriteConcern, getW); +#endif +static ZEND_METHOD(MongoDB_Driver_WriteConcern, getWtimeout); +static ZEND_METHOD(MongoDB_Driver_WriteConcern, isDefault); +static ZEND_METHOD(MongoDB_Driver_WriteConcern, __set_state); +#if PHP_VERSION_ID >= 80000 +static ZEND_METHOD(MongoDB_Driver_WriteConcern, bsonSerialize); +#endif +#if !(PHP_VERSION_ID >= 80000) +static ZEND_METHOD(MongoDB_Driver_WriteConcern, bsonSerialize); +#endif +static ZEND_METHOD(MongoDB_Driver_WriteConcern, serialize); +static ZEND_METHOD(MongoDB_Driver_WriteConcern, unserialize); +static ZEND_METHOD(MongoDB_Driver_WriteConcern, __unserialize); +static ZEND_METHOD(MongoDB_Driver_WriteConcern, __serialize); + + +static const zend_function_entry class_MongoDB_Driver_WriteConcern_methods[] = { +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_WriteConcern, __construct, arginfo_class_MongoDB_Driver_WriteConcern___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_WriteConcern, __construct, arginfo_class_MongoDB_Driver_WriteConcern___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_WriteConcern, getJournal, arginfo_class_MongoDB_Driver_WriteConcern_getJournal, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_WriteConcern, getW, arginfo_class_MongoDB_Driver_WriteConcern_getW, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_WriteConcern, getW, arginfo_class_MongoDB_Driver_WriteConcern_getW, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_WriteConcern, getWtimeout, arginfo_class_MongoDB_Driver_WriteConcern_getWtimeout, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_WriteConcern, isDefault, arginfo_class_MongoDB_Driver_WriteConcern_isDefault, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_WriteConcern, __set_state, arginfo_class_MongoDB_Driver_WriteConcern___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) +#if PHP_VERSION_ID >= 80000 + ZEND_ME(MongoDB_Driver_WriteConcern, bsonSerialize, arginfo_class_MongoDB_Driver_WriteConcern_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif +#if !(PHP_VERSION_ID >= 80000) + ZEND_ME(MongoDB_Driver_WriteConcern, bsonSerialize, arginfo_class_MongoDB_Driver_WriteConcern_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) +#endif + ZEND_ME(MongoDB_Driver_WriteConcern, serialize, arginfo_class_MongoDB_Driver_WriteConcern_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_WriteConcern, unserialize, arginfo_class_MongoDB_Driver_WriteConcern_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_WriteConcern, __unserialize, arginfo_class_MongoDB_Driver_WriteConcern___unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_WriteConcern, __serialize, arginfo_class_MongoDB_Driver_WriteConcern___serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_FE_END +}; + +static zend_class_entry *register_class_MongoDB_Driver_WriteConcern(zend_class_entry *class_entry_MongoDB_BSON_Serializable, zend_class_entry *class_entry_Serializable) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "WriteConcern", class_MongoDB_Driver_WriteConcern_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + zend_class_implements(class_entry, 2, class_entry_MongoDB_BSON_Serializable, class_entry_Serializable); + + zval const_MAJORITY_value; + zend_string *const_MAJORITY_value_str = zend_string_init(PHONGO_WRITE_CONCERN_W_MAJORITY, sizeof(PHONGO_WRITE_CONCERN_W_MAJORITY) - 1, 1); + ZVAL_STR(&const_MAJORITY_value, const_MAJORITY_value_str); + zend_string *const_MAJORITY_name = zend_string_init_interned("MAJORITY", sizeof("MAJORITY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_MAJORITY_name, &const_MAJORITY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_MAJORITY_name); + + return class_entry; +} diff --git a/src/MongoDB/WriteError.c b/src/MongoDB/WriteError.c index 9015b2f06..31c601576 100644 --- a/src/MongoDB/WriteError.c +++ b/src/MongoDB/WriteError.c @@ -23,12 +23,16 @@ #include "phongo_error.h" #include "MongoDB/WriteError.h" +#include "WriteError_arginfo.h" zend_class_entry* php_phongo_writeerror_ce; +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_WriteError) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_WriteError) + /* {{{ proto integer MongoDB\Driver\WriteError::getCode() Returns the MongoDB error code */ -static PHP_METHOD(WriteError, getCode) +static PHP_METHOD(MongoDB_Driver_WriteError, getCode) { php_phongo_writeerror_t* intern; @@ -42,7 +46,7 @@ static PHP_METHOD(WriteError, getCode) /* {{{ proto integer MongoDB\Driver\WriteError::getIndex() Returns the index of the operation in the BulkWrite to which this WriteError corresponds. */ -static PHP_METHOD(WriteError, getIndex) +static PHP_METHOD(MongoDB_Driver_WriteError, getIndex) { php_phongo_writeerror_t* intern; @@ -55,7 +59,7 @@ static PHP_METHOD(WriteError, getIndex) /* {{{ proto string MongoDB\Driver\WriteError::getMessage() Returns the actual error message from the server */ -static PHP_METHOD(WriteError, getMessage) +static PHP_METHOD(MongoDB_Driver_WriteError, getMessage) { php_phongo_writeerror_t* intern; @@ -68,7 +72,7 @@ static PHP_METHOD(WriteError, getMessage) /* {{{ proto object|null MongoDB\Driver\WriteError::getInfo() Returns additional metadata for the error */ -static PHP_METHOD(WriteError, getInfo) +static PHP_METHOD(MongoDB_Driver_WriteError, getInfo) { php_phongo_writeerror_t* intern; @@ -81,23 +85,6 @@ static PHP_METHOD(WriteError, getInfo) } } /* }}} */ -/* {{{ MongoDB\Driver\WriteError function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_WriteError_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_writeerror_me[] = { - /* clang-format off */ - PHP_ME(WriteError, getCode, ai_WriteError_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteError, getIndex, ai_WriteError_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteError, getMessage, ai_WriteError_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteError, getInfo, ai_WriteError_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_WriteError_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_WriteError_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\WriteError object handlers */ static zend_object_handlers php_phongo_handler_writeerror; @@ -153,12 +140,8 @@ static HashTable* php_phongo_writeerror_get_debug_info(phongo_compat_object_hand void php_phongo_writeerror_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "WriteError", php_phongo_writeerror_me); - php_phongo_writeerror_ce = zend_register_internal_class(&ce); + php_phongo_writeerror_ce = register_class_MongoDB_Driver_WriteError(); php_phongo_writeerror_ce->create_object = php_phongo_writeerror_create_object; - PHONGO_CE_FINAL(php_phongo_writeerror_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_writeerror_ce); memcpy(&php_phongo_handler_writeerror, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/WriteError.stub.php b/src/MongoDB/WriteError.stub.php new file mode 100644 index 000000000..f9abaa710 --- /dev/null +++ b/src/MongoDB/WriteError.stub.php @@ -0,0 +1,23 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/MongoDB/WriteResult.c b/src/MongoDB/WriteResult.c index 1e29c5bcc..e5163487f 100644 --- a/src/MongoDB/WriteResult.c +++ b/src/MongoDB/WriteResult.c @@ -29,6 +29,7 @@ #include "MongoDB/WriteConcern.h" #include "MongoDB/WriteConcernError.h" #include "MongoDB/WriteError.h" +#include "WriteResult_arginfo.h" #define PHONGO_WRITERESULT_RETURN_LONG_FROM_BSON_INT32(iter, bson, key) \ if (bson_iter_init_find((iter), (bson), (key)) && BSON_ITER_HOLDS_INT32((iter))) { \ @@ -109,9 +110,12 @@ static bool php_phongo_writeresult_get_writeerrors(php_phongo_writeresult_t* int return true; } /* }}} */ +PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_WriteResult) +PHONGO_DISABLED_WAKEUP(MongoDB_Driver_WriteResult) + /* {{{ proto integer|null MongoDB\Driver\WriteResult::getInsertedCount() Returns the number of documents that were inserted */ -static PHP_METHOD(WriteResult, getInsertedCount) +static PHP_METHOD(MongoDB_Driver_WriteResult, getInsertedCount) { bson_iter_t iter; php_phongo_writeresult_t* intern; @@ -125,7 +129,7 @@ static PHP_METHOD(WriteResult, getInsertedCount) /* {{{ proto integer|null MongoDB\Driver\WriteResult::getMatchedCount() Returns the number of documents that matched the update criteria */ -static PHP_METHOD(WriteResult, getMatchedCount) +static PHP_METHOD(MongoDB_Driver_WriteResult, getMatchedCount) { bson_iter_t iter; php_phongo_writeresult_t* intern; @@ -139,7 +143,7 @@ static PHP_METHOD(WriteResult, getMatchedCount) /* {{{ proto integer|null MongoDB\Driver\WriteResult::getModifiedCount() Returns the number of documents that were actually modified by an update */ -static PHP_METHOD(WriteResult, getModifiedCount) +static PHP_METHOD(MongoDB_Driver_WriteResult, getModifiedCount) { bson_iter_t iter; php_phongo_writeresult_t* intern; @@ -153,7 +157,7 @@ static PHP_METHOD(WriteResult, getModifiedCount) /* {{{ proto integer|null MongoDB\Driver\WriteResult::getDeletedCount() Returns the number of documents that were deleted */ -static PHP_METHOD(WriteResult, getDeletedCount) +static PHP_METHOD(MongoDB_Driver_WriteResult, getDeletedCount) { bson_iter_t iter; php_phongo_writeresult_t* intern; @@ -167,7 +171,7 @@ static PHP_METHOD(WriteResult, getDeletedCount) /* {{{ proto integer|null MongoDB\Driver\WriteResult::getUpsertedCount() Returns the number of documents that were upserted */ -static PHP_METHOD(WriteResult, getUpsertedCount) +static PHP_METHOD(MongoDB_Driver_WriteResult, getUpsertedCount) { bson_iter_t iter; php_phongo_writeresult_t* intern; @@ -181,7 +185,7 @@ static PHP_METHOD(WriteResult, getUpsertedCount) /* {{{ proto MongoDB\Driver\Server MongoDB\Driver\WriteResult::getServer() Returns the Server from which the result originated */ -static PHP_METHOD(WriteResult, getServer) +static PHP_METHOD(MongoDB_Driver_WriteResult, getServer) { php_phongo_writeresult_t* intern; @@ -194,7 +198,7 @@ static PHP_METHOD(WriteResult, getServer) /* {{{ proto array MongoDB\Driver\WriteResult::getUpsertedIds() Returns the identifiers generated by the server for upsert operations. */ -static PHP_METHOD(WriteResult, getUpsertedIds) +static PHP_METHOD(MongoDB_Driver_WriteResult, getUpsertedIds) { bson_iter_t iter, child; php_phongo_writeresult_t* intern; @@ -235,7 +239,7 @@ static PHP_METHOD(WriteResult, getUpsertedIds) /* {{{ proto WriteConcernError MongoDB\Driver\WriteResult::getWriteConcernError() Return any write concern error that occurred */ -static PHP_METHOD(WriteResult, getWriteConcernError) +static PHP_METHOD(MongoDB_Driver_WriteResult, getWriteConcernError) { php_phongo_writeresult_t* intern; @@ -248,7 +252,7 @@ static PHP_METHOD(WriteResult, getWriteConcernError) /* {{{ proto WriteError[] MongoDB\Driver\WriteResult::getWriteErrors() Returns any write errors that occurred */ -static PHP_METHOD(WriteResult, getWriteErrors) +static PHP_METHOD(MongoDB_Driver_WriteResult, getWriteErrors) { php_phongo_writeresult_t* intern; @@ -262,7 +266,7 @@ static PHP_METHOD(WriteResult, getWriteErrors) /* {{{ proto boolean MongoDB\Driver\WriteResult::isAcknowledged() Returns whether the write operation was acknowledged (based on the write concern). */ -static PHP_METHOD(WriteResult, isAcknowledged) +static PHP_METHOD(MongoDB_Driver_WriteResult, isAcknowledged) { php_phongo_writeresult_t* intern; @@ -273,29 +277,6 @@ static PHP_METHOD(WriteResult, isAcknowledged) RETURN_BOOL(mongoc_write_concern_is_acknowledged(intern->write_concern)); } /* }}} */ -/* {{{ MongoDB\Driver\WriteResult function entries */ -ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -static zend_function_entry php_phongo_writeresult_me[] = { - /* clang-format off */ - PHP_ME(WriteResult, getInsertedCount, ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteResult, getMatchedCount, ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteResult, getModifiedCount, ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteResult, getDeletedCount, ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteResult, getUpsertedCount, ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteResult, getServer, ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteResult, getUpsertedIds, ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteResult, getWriteConcernError, ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteResult, getWriteErrors, ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_ME(WriteResult, isAcknowledged, ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__construct, PHP_FN(MongoDB_disabled___construct), ai_WriteResult_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL) - ZEND_NAMED_ME(__wakeup, PHP_FN(MongoDB_disabled___wakeup), ai_WriteResult_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL) - PHP_FE_END - /* clang-format on */ -}; -/* }}} */ - /* {{{ MongoDB\Driver\WriteResult object handlers */ static zend_object_handlers php_phongo_handler_writeresult; @@ -403,12 +384,8 @@ static HashTable* php_phongo_writeresult_get_debug_info(phongo_compat_object_han void php_phongo_writeresult_init_ce(INIT_FUNC_ARGS) /* {{{ */ { - zend_class_entry ce; - - INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "WriteResult", php_phongo_writeresult_me); - php_phongo_writeresult_ce = zend_register_internal_class(&ce); + php_phongo_writeresult_ce = register_class_MongoDB_Driver_WriteResult(); php_phongo_writeresult_ce->create_object = php_phongo_writeresult_create_object; - PHONGO_CE_FINAL(php_phongo_writeresult_ce); PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_writeresult_ce); memcpy(&php_phongo_handler_writeresult, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); diff --git a/src/MongoDB/WriteResult.stub.php b/src/MongoDB/WriteResult.stub.php new file mode 100644 index 000000000..dfb7766d4 --- /dev/null +++ b/src/MongoDB/WriteResult.stub.php @@ -0,0 +1,35 @@ +ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/src/phongo_classes.h b/src/phongo_classes.h index b304a6692..3d2a49e6e 100644 --- a/src/phongo_classes.h +++ b/src/phongo_classes.h @@ -20,7 +20,6 @@ #include "phongo_structs.h" /* Export zend_class_entry dependencies, which are initialized in MINIT */ -extern zend_class_entry* php_phongo_date_immutable_ce; extern zend_class_entry* php_phongo_json_serializable_ce; static inline php_phongo_bulkwrite_t* php_bulkwrite_fetch_object(zend_object* obj) diff --git a/src/phongo_compat.h b/src/phongo_compat.h index ddf9e5422..6dd877dc6 100644 --- a/src/phongo_compat.h +++ b/src/phongo_compat.h @@ -273,6 +273,45 @@ static inline zend_bool zend_ini_parse_bool(zend_string* str) ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args) #endif +/* ZEND_ABSTRACT_ME_WITH_FLAGS was introduced in PHP 8.0. */ +#ifndef ZEND_ABSTRACT_ME_WITH_FLAGS +#define ZEND_ABSTRACT_ME_WITH_FLAGS(classname, name, arg_info, flags) ZEND_RAW_FENTRY(#name, NULL, arg_info, flags) +#endif + +/* ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE was introduced in PHP 8.0. */ +#ifndef ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE +#define ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, type_hint, allow_null, default_value) \ + ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) +#endif + +/* ZEND_ARG_INFO_WITH_DEFAULT_VALUE was introduced in PHP 8.0. */ +#ifndef ZEND_ARG_INFO_WITH_DEFAULT_VALUE +#define ZEND_ARG_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, default_value) \ + ZEND_ARG_INFO(pass_by_ref, name) +#endif + +/* ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE was introduced in PHP 8.0. */ +#ifndef ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE +#define ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, classname, allow_null, default_value) \ + ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) +#endif + +/* The ZEND_BEGIN_ARG_WITH_TENTATIVE_* set of macros was introduced in PHP 8.1 */ +#ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX +#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \ + ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args) +#endif + +#ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX +#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(name, return_reference, required_num_args, type) \ + ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args) +#endif + +#ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX +#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \ + ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args) +#endif + zend_bool php_phongo_zend_hash_apply_protection_begin(HashTable* ht); zend_bool php_phongo_zend_hash_apply_protection_end(HashTable* ht); diff --git a/tests/apm/bug0950-002.phpt b/tests/apm/bug0950-002.phpt index 51381ab3a..1dd0a2cb0 100644 --- a/tests/apm/bug0950-002.phpt +++ b/tests/apm/bug0950-002.phpt @@ -14,17 +14,17 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("- started: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("- succeeded: %s\n", $event->getCommandName()); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { printf("- failed: %s\n", $event->getCommandName()); } diff --git a/tests/apm/commandFailedEvent-001.phpt b/tests/apm/commandFailedEvent-001.phpt index 8a3bb46ce..6d183578b 100644 --- a/tests/apm/commandFailedEvent-001.phpt +++ b/tests/apm/commandFailedEvent-001.phpt @@ -13,16 +13,16 @@ $m = create_test_manager(); class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "started: ", $event->getCommandName(), "\n"; } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { echo "failed: ", $event->getCommandName(), "\n"; echo "- getError() returns an object: ", is_object( $event->getError() ) ? 'yes' : 'no', "\n"; diff --git a/tests/apm/commandFailedEvent-002.phpt b/tests/apm/commandFailedEvent-002.phpt index 5fd9e5609..e0a23ab86 100644 --- a/tests/apm/commandFailedEvent-002.phpt +++ b/tests/apm/commandFailedEvent-002.phpt @@ -12,18 +12,18 @@ $m = create_test_manager(); class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "started: ", $event->getCommandName(), "\n"; $this->startRequestId = $event->getRequestId(); $this->startOperationId = $event->getOperationId(); } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { echo "failed: ", $event->getCommandName(), "\n"; echo "- requestId matches: ", $this->startRequestId == $event->getRequestId() ? 'yes' : 'no', " \n"; diff --git a/tests/apm/commandFailedEvent-debug-001.phpt b/tests/apm/commandFailedEvent-debug-001.phpt index f8df2973d..ba8383b3b 100644 --- a/tests/apm/commandFailedEvent-debug-001.phpt +++ b/tests/apm/commandFailedEvent-debug-001.phpt @@ -9,15 +9,15 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { var_dump($event); } diff --git a/tests/apm/commandFailedEvent-getReply-001.phpt b/tests/apm/commandFailedEvent-getReply-001.phpt index 6b1901f9b..6ede4a78f 100644 --- a/tests/apm/commandFailedEvent-getReply-001.phpt +++ b/tests/apm/commandFailedEvent-getReply-001.phpt @@ -11,17 +11,17 @@ $manager = create_test_manager(); class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "started: ", $event->getCommandName(), "\n"; } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { var_dump($event); } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { echo "failed: ", $event->getCommandName(), "\n"; var_dump($event->getReply()); diff --git a/tests/apm/commandFailedEvent-getServerConnectionId-001.phpt b/tests/apm/commandFailedEvent-getServerConnectionId-001.phpt index e4f523829..5084508d7 100644 --- a/tests/apm/commandFailedEvent-getServerConnectionId-001.phpt +++ b/tests/apm/commandFailedEvent-getServerConnectionId-001.phpt @@ -12,7 +12,7 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { private $commandStartedServerConnectionId; - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); @@ -20,11 +20,11 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber var_dump($this->commandStartedServerConnectionId); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { printf("commandFailed: %s\n", $event->getCommandName()); printf("same serverConnectionId as last commandStarted: %s\n", $event->getServerConnectionId() == $this->commandStartedServerConnectionId ? 'yes' : 'no'); diff --git a/tests/apm/commandFailedEvent-getServerConnectionId-002.phpt b/tests/apm/commandFailedEvent-getServerConnectionId-002.phpt index afd826194..a966dfd19 100644 --- a/tests/apm/commandFailedEvent-getServerConnectionId-002.phpt +++ b/tests/apm/commandFailedEvent-getServerConnectionId-002.phpt @@ -10,17 +10,17 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); var_dump($event->getServerConnectionId()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { printf("commandFailed: %s\n", $event->getCommandName()); var_dump($event->getServerConnectionId()); diff --git a/tests/apm/commandFailedEvent-getServiceId-001.phpt b/tests/apm/commandFailedEvent-getServiceId-001.phpt index cffcd00d1..48d014b6c 100644 --- a/tests/apm/commandFailedEvent-getServiceId-001.phpt +++ b/tests/apm/commandFailedEvent-getServiceId-001.phpt @@ -11,7 +11,7 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { private $commandStartedServiceId; - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); @@ -19,11 +19,11 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber var_dump($this->commandStartedServiceId); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { printf("commandFailed: %s\n", $event->getCommandName()); printf("same serviceId as last commandStarted: %s\n", $event->getServiceId() == $this->commandStartedServiceId ? 'yes' : 'no'); diff --git a/tests/apm/commandFailedEvent-getServiceId-002.phpt b/tests/apm/commandFailedEvent-getServiceId-002.phpt index 323a4afec..0e47948d7 100644 --- a/tests/apm/commandFailedEvent-getServiceId-002.phpt +++ b/tests/apm/commandFailedEvent-getServiceId-002.phpt @@ -9,17 +9,17 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); var_dump($event->getServiceId()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { printf("commandFailed: %s\n", $event->getCommandName()); var_dump($event->getServiceId()); diff --git a/tests/apm/commandStartedEvent-001.phpt b/tests/apm/commandStartedEvent-001.phpt index c08c3e1e7..24ed6f63f 100644 --- a/tests/apm/commandStartedEvent-001.phpt +++ b/tests/apm/commandStartedEvent-001.phpt @@ -12,7 +12,7 @@ $m = create_test_manager(); class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "started: ", $event->getCommandName(), "\n"; echo "- getCommand() returns an object: ", is_object( $event->getCommand() ) ? 'yes' : 'no', "\n"; @@ -27,11 +27,11 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber echo "- getRequestId() returns a string: ", is_string( $event->getRequestId() ) ? 'yes' : 'no', "\n"; } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/commandStartedEvent-002.phpt b/tests/apm/commandStartedEvent-002.phpt index acce0c779..fbbdcda8e 100644 --- a/tests/apm/commandStartedEvent-002.phpt +++ b/tests/apm/commandStartedEvent-002.phpt @@ -10,14 +10,14 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("Observed commandStarted for %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) {} + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void {} - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) {} + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void {} } $manager = create_test_manager(URI, [], ['disableClientPersistence' => true]); diff --git a/tests/apm/commandStartedEvent-debug-001.phpt b/tests/apm/commandStartedEvent-debug-001.phpt index 3d6e0c45a..b9b090554 100644 --- a/tests/apm/commandStartedEvent-debug-001.phpt +++ b/tests/apm/commandStartedEvent-debug-001.phpt @@ -9,16 +9,16 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { var_dump($event); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/apm/commandStartedEvent-getServerConnectionId-001.phpt b/tests/apm/commandStartedEvent-getServerConnectionId-001.phpt index 2f185b14c..7ba6b6628 100644 --- a/tests/apm/commandStartedEvent-getServerConnectionId-001.phpt +++ b/tests/apm/commandStartedEvent-getServerConnectionId-001.phpt @@ -12,7 +12,7 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { private $commandStartedServerConnectionId; - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); @@ -24,11 +24,11 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber var_dump($this->commandStartedServerConnectionId); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/apm/commandStartedEvent-getServerConnectionId-002.phpt b/tests/apm/commandStartedEvent-getServerConnectionId-002.phpt index f9c1977d0..9f7936a14 100644 --- a/tests/apm/commandStartedEvent-getServerConnectionId-002.phpt +++ b/tests/apm/commandStartedEvent-getServerConnectionId-002.phpt @@ -10,17 +10,17 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); var_dump($event->getServerConnectionId()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/apm/commandStartedEvent-getServiceId-001.phpt b/tests/apm/commandStartedEvent-getServiceId-001.phpt index 38cdf9db8..9852988f6 100644 --- a/tests/apm/commandStartedEvent-getServiceId-001.phpt +++ b/tests/apm/commandStartedEvent-getServiceId-001.phpt @@ -11,7 +11,7 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { private $commandStartedServiceId; - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); @@ -23,11 +23,11 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber var_dump($this->commandStartedServiceId); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/apm/commandStartedEvent-getServiceId-002.phpt b/tests/apm/commandStartedEvent-getServiceId-002.phpt index 1bf4af789..d5f0c5f94 100644 --- a/tests/apm/commandStartedEvent-getServiceId-002.phpt +++ b/tests/apm/commandStartedEvent-getServiceId-002.phpt @@ -9,17 +9,17 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); var_dump($event->getServiceId()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/apm/commandSucceededEvent-001.phpt b/tests/apm/commandSucceededEvent-001.phpt index 9707e3766..b437e10b0 100644 --- a/tests/apm/commandSucceededEvent-001.phpt +++ b/tests/apm/commandSucceededEvent-001.phpt @@ -13,12 +13,12 @@ $m = create_test_manager(); class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "started: ", $event->getCommandName(), "\n"; } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { echo "succeeded: ", $event->getCommandName(), "\n"; echo "- getReply() returns an object: ", is_object( $event->getReply() ) ? 'yes' : 'no', "\n"; @@ -33,7 +33,7 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber echo "- getRequestId() returns a string: ", is_string( $event->getRequestId() ) ? 'yes' : 'no', "\n"; } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/commandSucceededEvent-002.phpt b/tests/apm/commandSucceededEvent-002.phpt index ed445b161..1939d51c8 100644 --- a/tests/apm/commandSucceededEvent-002.phpt +++ b/tests/apm/commandSucceededEvent-002.phpt @@ -12,21 +12,21 @@ $m = create_test_manager(); class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "started: ", $event->getCommandName(), "\n"; $this->startRequestId = $event->getRequestId(); $this->startOperationId = $event->getOperationId(); } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { echo "succeeded: ", $event->getCommandName(), "\n"; echo "- requestId matches: ", $this->startRequestId == $event->getRequestId() ? 'yes' : 'no', " \n"; echo "- operationId matches: ", $this->startOperationId == $event->getOperationId() ? 'yes' : 'no', " \n"; } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/commandSucceededEvent-debug-001.phpt b/tests/apm/commandSucceededEvent-debug-001.phpt index f0f7201cb..361d2be23 100644 --- a/tests/apm/commandSucceededEvent-debug-001.phpt +++ b/tests/apm/commandSucceededEvent-debug-001.phpt @@ -9,16 +9,16 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { var_dump($event); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/apm/commandSucceededEvent-getServerConnectionId-001.phpt b/tests/apm/commandSucceededEvent-getServerConnectionId-001.phpt index a215c339f..e7cc1a0e8 100644 --- a/tests/apm/commandSucceededEvent-getServerConnectionId-001.phpt +++ b/tests/apm/commandSucceededEvent-getServerConnectionId-001.phpt @@ -12,7 +12,7 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { private $commandStartedServerConnectionId; - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); @@ -20,14 +20,14 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber var_dump($this->commandStartedServerConnectionId); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("commandSucceeded: %s\n", $event->getCommandName()); printf("same serverConnectionId as last commandStarted: %s\n", $event->getServerConnectionId() == $this->commandStartedServerConnectionId ? 'yes' : 'no'); var_dump($event->getServerConnectionId()); } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/commandSucceededEvent-getServerConnectionId-002.phpt b/tests/apm/commandSucceededEvent-getServerConnectionId-002.phpt index 1a4affb83..617077571 100644 --- a/tests/apm/commandSucceededEvent-getServerConnectionId-002.phpt +++ b/tests/apm/commandSucceededEvent-getServerConnectionId-002.phpt @@ -10,19 +10,19 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); var_dump($event->getServerConnectionId()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("commandSucceeded: %s\n", $event->getCommandName()); var_dump($event->getServerConnectionId()); } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/commandSucceededEvent-getServiceId-001.phpt b/tests/apm/commandSucceededEvent-getServiceId-001.phpt index 72abbd04d..8ecb1a915 100644 --- a/tests/apm/commandSucceededEvent-getServiceId-001.phpt +++ b/tests/apm/commandSucceededEvent-getServiceId-001.phpt @@ -11,7 +11,7 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { private $commandStartedServiceId; - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { printf("commandStarted: %s\n", $event->getCommandName()); @@ -19,14 +19,14 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber var_dump($this->commandStartedServiceId); } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { printf("commandSucceeded: %s\n", $event->getCommandName()); printf("same serviceId as last commandStarted: %s\n", $event->getServiceId() == $this->commandStartedServiceId ? 'yes' : 'no'); var_dump($event->getServiceId()); } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/commandSucceededEvent-getServiceId-002.phpt b/tests/apm/commandSucceededEvent-getServiceId-002.phpt index 2c40b237f..692bb6842 100644 --- a/tests/apm/commandSucceededEvent-getServiceId-002.phpt +++ b/tests/apm/commandSucceededEvent-getServiceId-002.phpt @@ -9,19 +9,19 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { printf("commandStarted: %s\n", $event->getCommandName()); var_dump($event->getServiceId()); } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { printf("commandSucceeded: %s\n", $event->getCommandName()); var_dump($event->getServiceId()); } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/monitoring-addSubscriber-001.phpt b/tests/apm/monitoring-addSubscriber-001.phpt index f4f9cc26d..4d8b37ba1 100644 --- a/tests/apm/monitoring-addSubscriber-001.phpt +++ b/tests/apm/monitoring-addSubscriber-001.phpt @@ -12,16 +12,16 @@ $m = create_test_manager(); class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "- started: ", $event->getCommandName(), "\n"; } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/monitoring-addSubscriber-002.phpt b/tests/apm/monitoring-addSubscriber-002.phpt index 300f5a6c4..dcc85035c 100644 --- a/tests/apm/monitoring-addSubscriber-002.phpt +++ b/tests/apm/monitoring-addSubscriber-002.phpt @@ -19,16 +19,16 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber $this->instanceName = $instanceName; } - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "- ({$this->instanceName}) - started: ", $event->getCommandName(), "\n"; } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/monitoring-addSubscriber-003.phpt b/tests/apm/monitoring-addSubscriber-003.phpt index 7989b3df2..7c8faf8df 100644 --- a/tests/apm/monitoring-addSubscriber-003.phpt +++ b/tests/apm/monitoring-addSubscriber-003.phpt @@ -12,16 +12,16 @@ $m = create_test_manager(); class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "- started: ", $event->getCommandName(), "\n"; } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/monitoring-addSubscriber-004.phpt b/tests/apm/monitoring-addSubscriber-004.phpt index 4712d7546..59d08dff5 100644 --- a/tests/apm/monitoring-addSubscriber-004.phpt +++ b/tests/apm/monitoring-addSubscriber-004.phpt @@ -19,16 +19,16 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber $this->instanceName = $instanceName; } - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "- ({$this->instanceName}) - started: ", $event->getCommandName(), "\n"; } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/monitoring-removeSubscriber-001.phpt b/tests/apm/monitoring-removeSubscriber-001.phpt index 34b163447..f1a704174 100644 --- a/tests/apm/monitoring-removeSubscriber-001.phpt +++ b/tests/apm/monitoring-removeSubscriber-001.phpt @@ -12,16 +12,16 @@ $m = create_test_manager(); class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "- started: ", $event->getCommandName(), "\n"; } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/monitoring-removeSubscriber-002.phpt b/tests/apm/monitoring-removeSubscriber-002.phpt index 239400516..f046606bd 100644 --- a/tests/apm/monitoring-removeSubscriber-002.phpt +++ b/tests/apm/monitoring-removeSubscriber-002.phpt @@ -19,16 +19,16 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber $this->instanceName = $instanceName; } - public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ) + public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event ): void { echo "- ({$this->instanceName}) - started: ", $event->getCommandName(), "\n"; } - public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ) + public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event ): void { } - public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ) + public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event ): void { } } diff --git a/tests/apm/serverChangedEvent-001.phpt b/tests/apm/serverChangedEvent-001.phpt index 8f5883a8c..af5d0db49 100644 --- a/tests/apm/serverChangedEvent-001.phpt +++ b/tests/apm/serverChangedEvent-001.phpt @@ -11,7 +11,7 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber { private $isObserved = false; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void { // Ignore multiple events for the purpose of this test if ($this->isObserved) { @@ -29,21 +29,21 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber var_dump($event); } - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) {} + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void {} - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} } $m = create_test_manager(); diff --git a/tests/apm/serverClosedEvent-001.phpt b/tests/apm/serverClosedEvent-001.phpt index b2351af19..8e6062717 100644 --- a/tests/apm/serverClosedEvent-001.phpt +++ b/tests/apm/serverClosedEvent-001.phpt @@ -11,9 +11,9 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber { private $isObserved = false; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void { // Ignore multiple events for the purpose of this test if ($this->isObserved) { @@ -29,19 +29,19 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber var_dump($event); } - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) {} + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void {} - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} } /* Note: load balanced topologies will always emit ServerClosedEvent before diff --git a/tests/apm/serverHeartbeatFailedEvent-001.phpt b/tests/apm/serverHeartbeatFailedEvent-001.phpt index 5e88ebacb..81c779a88 100644 --- a/tests/apm/serverHeartbeatFailedEvent-001.phpt +++ b/tests/apm/serverHeartbeatFailedEvent-001.phpt @@ -12,11 +12,11 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber { - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void { printf("getDurationMicros() returns an integer: %s\n", is_integer($event->getDurationMicros()) ? 'yes' : 'no'); printf("getError() returns an Exception: %s\n", ($event->getError() instanceof Exception) ? 'yes' : 'no'); @@ -27,17 +27,17 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber var_dump($event); } - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) {} + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void {} - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} } /* Use a separate client to configure the fail point and trigger a heartbeat diff --git a/tests/apm/serverHeartbeatStartedEvent-001.phpt b/tests/apm/serverHeartbeatStartedEvent-001.phpt index 7cf3e73df..d6adfdbf7 100644 --- a/tests/apm/serverHeartbeatStartedEvent-001.phpt +++ b/tests/apm/serverHeartbeatStartedEvent-001.phpt @@ -11,13 +11,13 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber { private $isObserved = false; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event) + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event): void { // Ignore multiple events for the purpose of this test if ($this->isObserved) { @@ -33,15 +33,15 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber var_dump($event); } - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) {} + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void {} - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} } $m = create_test_manager(); diff --git a/tests/apm/serverHeartbeatSucceededEvent-001.phpt b/tests/apm/serverHeartbeatSucceededEvent-001.phpt index e614e5254..1c06cc200 100644 --- a/tests/apm/serverHeartbeatSucceededEvent-001.phpt +++ b/tests/apm/serverHeartbeatSucceededEvent-001.phpt @@ -11,15 +11,15 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber { private $isObserved = false; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void { // Ignore multiple events for the purpose of this test if ($this->isObserved) { @@ -37,13 +37,13 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber var_dump($event); } - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) {} + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void {} - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} } $m = create_test_manager(); diff --git a/tests/apm/serverOpeningEvent-001.phpt b/tests/apm/serverOpeningEvent-001.phpt index 8ee76e4aa..a9b4fcfb7 100644 --- a/tests/apm/serverOpeningEvent-001.phpt +++ b/tests/apm/serverOpeningEvent-001.phpt @@ -11,17 +11,17 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber { private $isObserved = false; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void { // Ignore multiple events for the purpose of this test if ($this->isObserved) { @@ -37,11 +37,11 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber var_dump($event); } - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) {} + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void {} - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} } $m = create_test_manager(); diff --git a/tests/apm/topologyChangedEvent-001.phpt b/tests/apm/topologyChangedEvent-001.phpt index 003e431cd..4683cd1e3 100644 --- a/tests/apm/topologyChangedEvent-001.phpt +++ b/tests/apm/topologyChangedEvent-001.phpt @@ -11,19 +11,19 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber { private $isObserved = false; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void { // Ignore multiple events for the purpose of this test if ($this->isObserved) { @@ -39,9 +39,9 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber var_dump($event); } - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} } $m = create_test_manager(); diff --git a/tests/apm/topologyClosedEvent-001.phpt b/tests/apm/topologyClosedEvent-001.phpt index cd0ec992f..138e67634 100644 --- a/tests/apm/topologyClosedEvent-001.phpt +++ b/tests/apm/topologyClosedEvent-001.phpt @@ -9,28 +9,28 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber { - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) {} + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void {} - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void { printf("getTopologyId() returns an ObjectId: %s\n", ($event->getTopologyId() instanceof MongoDB\BSON\ObjectId) ? 'yes' : 'no'); var_dump($event); } - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} } /* Note: TopologyChangedEvent can only be observed for non-persistent clients. diff --git a/tests/apm/topologyOpeningEvent-001.phpt b/tests/apm/topologyOpeningEvent-001.phpt index abb6f0091..faf09d023 100644 --- a/tests/apm/topologyOpeningEvent-001.phpt +++ b/tests/apm/topologyOpeningEvent-001.phpt @@ -9,23 +9,23 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber { - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) {} + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void {} - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void { printf("getTopologyId() returns an ObjectId: %s\n", ($event->getTopologyId() instanceof MongoDB\BSON\ObjectId) ? 'yes' : 'no'); diff --git a/tests/apm/topologyOpeningEvent-002.phpt b/tests/apm/topologyOpeningEvent-002.phpt index 94d3ed39e..92ed4836d 100644 --- a/tests/apm/topologyOpeningEvent-002.phpt +++ b/tests/apm/topologyOpeningEvent-002.phpt @@ -12,38 +12,38 @@ class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber private $topologyId; public $numAssertions = 0; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void { $this->assertSameTopologyId($event); } - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void { $this->assertSameTopologyId($event); } - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\serverHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void { $this->assertSameTopologyId($event); } - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void { $this->assertSameTopologyId($event); } - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void { $this->assertSameTopologyId($event); } - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void { $this->topologyId = $event->getTopologyId(); } diff --git a/tests/bson/bson-decimal128_error-001.phpt b/tests/bson/bson-decimal128_error-001.phpt index 08a70cac5..cc54bb6b8 100644 --- a/tests/bson/bson-decimal128_error-001.phpt +++ b/tests/bson/bson-decimal128_error-001.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . '/../utils/basic.inc'; echo throws(function() { new MongoDB\BSON\Decimal128([]); -}, MongoDB\Driver\Exception\InvalidArgumentException::class), "\n"; +}, TypeError::class), "\n"; echo throws(function() { new MongoDB\BSON\Decimal128('foo'); @@ -21,7 +21,7 @@ echo throws(function() { ===DONE=== --EXPECTF-- -OK: Got MongoDB\Driver\Exception\InvalidArgumentException +OK: Got TypeError %SMongoDB\BSON\Decimal128::__construct()%sstring, array given OK: Got MongoDB\Driver\Exception\InvalidArgumentException Error parsing Decimal128 string: foo diff --git a/tests/bson/bson-decode-002.phpt b/tests/bson/bson-decode-002.phpt index c1c06001c..45d3933c5 100644 --- a/tests/bson/bson-decode-002.phpt +++ b/tests/bson/bson-decode-002.phpt @@ -6,7 +6,7 @@ BSON encoding: Encoding object/arrays data into user specificied classes require_once __DIR__ . '/../utils/basic.inc'; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) { + public function bsonUnserialize(array $data): void { parent::__construct($data); } } diff --git a/tests/bson/bson-encode-002.phpt b/tests/bson/bson-encode-002.phpt index 0171f5c3b..374e2f574 100644 --- a/tests/bson/bson-encode-002.phpt +++ b/tests/bson/bson-encode-002.phpt @@ -7,12 +7,13 @@ require_once __DIR__ . '/../utils/basic.inc'; class AssociativeArray implements MongoDB\BSON\Serializable, MongoDB\BSON\Unserializable { + #[\ReturnTypeWillChange] public function bsonSerialize() { return array("random" => "class", "data"); } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { echo __METHOD__, "() was called with data:\n"; var_dump($data); @@ -21,12 +22,13 @@ class AssociativeArray implements MongoDB\BSON\Serializable, MongoDB\BSON\Unseri class NumericArray implements MongoDB\BSON\Serializable, MongoDB\BSON\Unserializable { + #[\ReturnTypeWillChange] public function bsonSerialize() { return array(1, 2, 3); } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { echo __METHOD__, "() was called with data:\n"; var_dump($data); diff --git a/tests/bson/bson-encode-003.phpt b/tests/bson/bson-encode-003.phpt index 3e2a0af03..4f5205905 100644 --- a/tests/bson/bson-encode-003.phpt +++ b/tests/bson/bson-encode-003.phpt @@ -6,23 +6,25 @@ BSON encoding: Encoding objects into BSON representation require_once __DIR__ . '/../utils/basic.inc'; class MyClass implements MongoDB\BSON\Persistable { - function bsonSerialize() { + #[\ReturnTypeWillChange] + public function bsonSerialize() { return array( "random" => "class", "data" ); } - function bsonUnserialize(array $data) { + public function bsonUnserialize(array $data): void { $this->props = $data; } } class MyClass2 implements MongoDB\BSON\Persistable { - function bsonSerialize() { + #[\ReturnTypeWillChange] + public function bsonSerialize() { return array( 1, 2, 3, ); } - function bsonUnserialize(array $data) { + public function bsonUnserialize(array $data): void { $this->props = $data; } } diff --git a/tests/bson/bson-fromPHP-001.phpt b/tests/bson/bson-fromPHP-001.phpt index 778f1ce7b..3a763cff0 100644 --- a/tests/bson/bson-fromPHP-001.phpt +++ b/tests/bson/bson-fromPHP-001.phpt @@ -14,6 +14,7 @@ class MyDocument implements MongoDB\BSON\Serializable $this->data = $data; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return $this->data; diff --git a/tests/bson/bson-fromPHP_error-001.phpt b/tests/bson/bson-fromPHP_error-001.phpt index 03439b04b..d39ee7baa 100644 --- a/tests/bson/bson-fromPHP_error-001.phpt +++ b/tests/bson/bson-fromPHP_error-001.phpt @@ -14,6 +14,7 @@ class MyDocument implements MongoDB\BSON\Serializable $this->data = $data; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return $this->data; diff --git a/tests/bson/bson-fromPHP_error-005.phpt b/tests/bson/bson-fromPHP_error-005.phpt index 351407775..67668270f 100644 --- a/tests/bson/bson-fromPHP_error-005.phpt +++ b/tests/bson/bson-fromPHP_error-005.phpt @@ -9,6 +9,7 @@ class MyRecursiveSerializable implements MongoDB\BSON\Serializable { public $child = 1; + #[\ReturnTypeWillChange] public function bsonSerialize() { return $this; @@ -17,6 +18,7 @@ class MyRecursiveSerializable implements MongoDB\BSON\Serializable class MyIndirectlyRecursiveSerializable extends MyRecursiveSerializable { + #[\ReturnTypeWillChange] public function bsonSerialize() { return ['parent' => $this]; diff --git a/tests/bson/bson-fromPHP_error-007.phpt b/tests/bson/bson-fromPHP_error-007.phpt index ae82a3193..806f0952a 100644 --- a/tests/bson/bson-fromPHP_error-007.phpt +++ b/tests/bson/bson-fromPHP_error-007.phpt @@ -14,6 +14,7 @@ class MySerializable implements MongoDB\BSON\Serializable $this->data = $data; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return $this->data; diff --git a/tests/bson/bson-objectid_error-001.phpt b/tests/bson/bson-objectid_error-001.phpt index dd634338d..e06a34186 100644 --- a/tests/bson/bson-objectid_error-001.phpt +++ b/tests/bson/bson-objectid_error-001.phpt @@ -10,12 +10,12 @@ require_once __DIR__ . '/../utils/basic.inc'; echo throws(function() { new MongoDB\BSON\ObjectId(new stdclass); -}, MongoDB\Driver\Exception\InvalidArgumentException::class), "\n"; +}, TypeError::class), "\n"; ?> ===DONE=== --EXPECTF-- -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -%SMongoDB\BSON\ObjectId::__construct()%sstring, %r(object|stdClass)%r given +OK: Got TypeError +%SMongoDB\BSON\ObjectId::__construct()%sstring or null, %r(object|stdClass)%r given ===DONE=== diff --git a/tests/bson/bson-toPHP-001.phpt b/tests/bson/bson-toPHP-001.phpt index 7c21d43c5..e2d1c0744 100644 --- a/tests/bson/bson-toPHP-001.phpt +++ b/tests/bson/bson-toPHP-001.phpt @@ -11,7 +11,7 @@ abstract class MyAbstractDocument implements MongoDB\BSON\Persistable class MyDocument implements MongoDB\BSON\Unserializable { - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { $this->unserialized = true; } diff --git a/tests/bson/bson-toPHP-002.phpt b/tests/bson/bson-toPHP-002.phpt index 4523b9fc3..7bdcd3c4d 100644 --- a/tests/bson/bson-toPHP-002.phpt +++ b/tests/bson/bson-toPHP-002.phpt @@ -17,12 +17,13 @@ class MyDocument implements MongoDB\BSON\Persistable ); } + #[\ReturnTypeWillChange] public function bsonSerialize() { return $this->data; } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { foreach (array('list', 'map') as $key) { if (isset($data[$key])) { diff --git a/tests/bson/bson-toPHP-003.phpt b/tests/bson/bson-toPHP-003.phpt index 8ef7bbfcd..4e5e90a66 100644 --- a/tests/bson/bson-toPHP-003.phpt +++ b/tests/bson/bson-toPHP-003.phpt @@ -11,7 +11,7 @@ class MyClass class YourClass implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { foreach ($data as $key => $value) { $this->$key = $value; @@ -22,13 +22,14 @@ class YourClass implements MongoDB\BSON\Unserializable class OurClass implements MongoDB\BSON\Persistable { - function bsonSerialize() + #[\ReturnTypeWillChange] + public function bsonSerialize() { // Not tested with this test, so return empty array return array(); } - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { foreach ($data as $key => $value) { $this->$key = $value; diff --git a/tests/bson/bson-toPHP-004.phpt b/tests/bson/bson-toPHP-004.phpt index 56488b8ad..58387d06f 100644 --- a/tests/bson/bson-toPHP-004.phpt +++ b/tests/bson/bson-toPHP-004.phpt @@ -7,7 +7,7 @@ require_once __DIR__ . '/../utils/basic.inc'; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data); } diff --git a/tests/bson/bson-toPHP-007.phpt b/tests/bson/bson-toPHP-007.phpt index bf8d43209..6124119be 100644 --- a/tests/bson/bson-toPHP-007.phpt +++ b/tests/bson/bson-toPHP-007.phpt @@ -5,7 +5,7 @@ MongoDB\BSON\toPHP(): fieldPath typemaps without server class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, ArrayObject::ARRAY_AS_PROPS); } diff --git a/tests/bson/bson-toPHP-008.phpt b/tests/bson/bson-toPHP-008.phpt index 1860c31a6..48201b03f 100644 --- a/tests/bson/bson-toPHP-008.phpt +++ b/tests/bson/bson-toPHP-008.phpt @@ -7,7 +7,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data); } diff --git a/tests/bson/bson-toPHP-009.phpt b/tests/bson/bson-toPHP-009.phpt index 0f67328f5..8c08f056c 100644 --- a/tests/bson/bson-toPHP-009.phpt +++ b/tests/bson/bson-toPHP-009.phpt @@ -7,7 +7,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, ArrayObject::ARRAY_AS_PROPS); } diff --git a/tests/bson/bson-toPHP-010.phpt b/tests/bson/bson-toPHP-010.phpt index 109ba22a7..5772f9418 100644 --- a/tests/bson/bson-toPHP-010.phpt +++ b/tests/bson/bson-toPHP-010.phpt @@ -7,7 +7,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, ArrayObject::ARRAY_AS_PROPS); } @@ -15,7 +15,7 @@ class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable class MyWildcardArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, ArrayObject::ARRAY_AS_PROPS); } diff --git a/tests/bson/bson-toPHP-011.phpt b/tests/bson/bson-toPHP-011.phpt index f9fa77930..7ca35a26f 100644 --- a/tests/bson/bson-toPHP-011.phpt +++ b/tests/bson/bson-toPHP-011.phpt @@ -7,7 +7,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, ArrayObject::ARRAY_AS_PROPS); } diff --git a/tests/bson/bug0274.phpt b/tests/bson/bug0274.phpt index 2f4de6911..f4fb09478 100644 --- a/tests/bson/bug0274.phpt +++ b/tests/bson/bug0274.phpt @@ -7,6 +7,7 @@ require_once __DIR__ . '/../utils/basic.inc'; class AssociativeArray implements MongoDB\BSON\Serializable { + #[\ReturnTypeWillChange] public function bsonSerialize() { return array("random" => "class", "data"); @@ -15,6 +16,7 @@ class AssociativeArray implements MongoDB\BSON\Serializable class NumericArray implements MongoDB\BSON\Serializable { + #[\ReturnTypeWillChange] public function bsonSerialize() { return array(1, 2, 3); diff --git a/tests/bson/bug0334-001.phpt b/tests/bson/bug0334-001.phpt index b7743652b..a409b6389 100644 --- a/tests/bson/bug0334-001.phpt +++ b/tests/bson/bug0334-001.phpt @@ -6,13 +6,14 @@ PHPC-334: Injected __pclass should override a __pclass key in bsonSerialize() re require_once __DIR__ . '/../utils/basic.inc'; class MyClass implements MongoDB\BSON\Persistable { - function bsonSerialize() { + #[\ReturnTypeWillChange] + public function bsonSerialize() { return array( "__pclass" => "baz", "foo" => "bar", ); } - function bsonUnserialize(array $data) { + public function bsonUnserialize(array $data): void { } } diff --git a/tests/bson/bug0334-002.phpt b/tests/bson/bug0334-002.phpt index 579485f4f..e34824c6f 100644 --- a/tests/bson/bug0334-002.phpt +++ b/tests/bson/bug0334-002.phpt @@ -6,13 +6,14 @@ PHPC-334: Encoded BSON should never have multiple __pclass keys require_once __DIR__ . '/../utils/basic.inc'; class MyClass implements MongoDB\BSON\Persistable { - function bsonSerialize() { + #[\ReturnTypeWillChange] + public function bsonSerialize() { return array( "__pclass" => "baz", "foo" => "bar", ); } - function bsonUnserialize(array $data) { + public function bsonUnserialize(array $data): void { } } diff --git a/tests/bson/bug1006-001.phpt b/tests/bson/bug1006-001.phpt index 5ef31be74..4a8b26a98 100644 --- a/tests/bson/bug1006-001.phpt +++ b/tests/bson/bug1006-001.phpt @@ -17,12 +17,13 @@ class MyClass implements MongoDB\BSON\Persistable ]; } - function bsonSerialize() + #[\ReturnTypeWillChange] + public function bsonSerialize() { return $this->data; } - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { } } diff --git a/tests/bson/bug1006-002.phpt b/tests/bson/bug1006-002.phpt index 215aa9ecf..d2641220d 100644 --- a/tests/bson/bug1006-002.phpt +++ b/tests/bson/bug1006-002.phpt @@ -7,7 +7,8 @@ require_once __DIR__ . '/../utils/basic.inc'; class MyClass implements MongoDB\BSON\Serializable { - function bsonSerialize() + #[\ReturnTypeWillChange] + public function bsonSerialize() { return [ '__pclass' => 'baz', diff --git a/tests/bson/typemap-001.phpt b/tests/bson/typemap-001.phpt index 744ff2e33..ef22f460b 100644 --- a/tests/bson/typemap-001.phpt +++ b/tests/bson/typemap-001.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data); } diff --git a/tests/bson/typemap-003.phpt b/tests/bson/typemap-003.phpt index ef40cc04d..1bd2580ab 100644 --- a/tests/bson/typemap-003.phpt +++ b/tests/bson/typemap-003.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, \ArrayObject::ARRAY_AS_PROPS); } diff --git a/tests/bson/typemap-004.phpt b/tests/bson/typemap-004.phpt index 2e09d38f6..6d1e7bcf3 100644 --- a/tests/bson/typemap-004.phpt +++ b/tests/bson/typemap-004.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data); } diff --git a/tests/bson/typemap-005.phpt b/tests/bson/typemap-005.phpt index 99adf25b7..7f5d9c0ee 100644 --- a/tests/bson/typemap-005.phpt +++ b/tests/bson/typemap-005.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, ArrayObject::ARRAY_AS_PROPS); } diff --git a/tests/bson/typemap-006.phpt b/tests/bson/typemap-006.phpt index fc1caccf3..51d5607f9 100644 --- a/tests/bson/typemap-006.phpt +++ b/tests/bson/typemap-006.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, ArrayObject::ARRAY_AS_PROPS); } @@ -19,7 +19,7 @@ class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable class MyWildcardArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, ArrayObject::ARRAY_AS_PROPS); } diff --git a/tests/bson/typemap-007.phpt b/tests/bson/typemap-007.phpt index fa05567db..24f31f9d4 100644 --- a/tests/bson/typemap-007.phpt +++ b/tests/bson/typemap-007.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, ArrayObject::ARRAY_AS_PROPS); } diff --git a/tests/bulk/bulkwrite-ctor-comment-001.phpt b/tests/bulk/bulkwrite-ctor-comment-001.phpt index 7b996f80c..623d94c09 100644 --- a/tests/bulk/bulkwrite-ctor-comment-001.phpt +++ b/tests/bulk/bulkwrite-ctor-comment-001.phpt @@ -12,7 +12,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); @@ -25,11 +25,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s included comment: %s\n", $event->getCommandName(), json_encode($command->comment)); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/bulk/bulkwrite-ctor-comment_error-001.phpt b/tests/bulk/bulkwrite-ctor-comment_error-001.phpt index 7ecf4c604..6e1c8a3af 100644 --- a/tests/bulk/bulkwrite-ctor-comment_error-001.phpt +++ b/tests/bulk/bulkwrite-ctor-comment_error-001.phpt @@ -7,6 +7,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class Comment implements MongoDB\BSON\Serializable { + #[\ReturnTypeWillChange] public function bsonSerialize(): array { throw new Exception('php_phongo_zval_to_bson_value fails'); diff --git a/tests/bulk/bulkwrite-ctor-let-001.phpt b/tests/bulk/bulkwrite-ctor-let-001.phpt index e9243f21f..0acbda72b 100644 --- a/tests/bulk/bulkwrite-ctor-let-001.phpt +++ b/tests/bulk/bulkwrite-ctor-let-001.phpt @@ -12,7 +12,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); @@ -25,11 +25,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s included let: %s\n", $event->getCommandName(), json_encode($command->let)); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/bulk/bulkwrite-delete-001.phpt b/tests/bulk/bulkwrite-delete-001.phpt index 5aa0ced3d..b0bae3521 100644 --- a/tests/bulk/bulkwrite-delete-001.phpt +++ b/tests/bulk/bulkwrite-delete-001.phpt @@ -19,6 +19,7 @@ class MyClass implements MongoDB\BSON\Persistable $this->child = $child; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return [ @@ -27,7 +28,7 @@ class MyClass implements MongoDB\BSON\Persistable ]; } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { $this->id = $data['_id']; $this->child = $data['child']; diff --git a/tests/bulk/bulkwrite-delete-002.phpt b/tests/bulk/bulkwrite-delete-002.phpt index 47cd3ac94..00bdbd349 100644 --- a/tests/bulk/bulkwrite-delete-002.phpt +++ b/tests/bulk/bulkwrite-delete-002.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { if ($event->getCommandName() !== 'delete') { return; @@ -20,11 +20,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("delete included hint: %s\n", json_encode($event->getCommand()->deletes[0]->hint)); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/bulk/bulkwrite-insert-001.phpt b/tests/bulk/bulkwrite-insert-001.phpt index 1d9bcfbdb..4160a95f8 100644 --- a/tests/bulk/bulkwrite-insert-001.phpt +++ b/tests/bulk/bulkwrite-insert-001.phpt @@ -19,6 +19,7 @@ class MyClass implements MongoDB\BSON\Persistable $this->child = $child; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return [ @@ -27,7 +28,7 @@ class MyClass implements MongoDB\BSON\Persistable ]; } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { $this->id = $data['_id']; $this->child = $data['child']; diff --git a/tests/bulk/bulkwrite-insert-004.phpt b/tests/bulk/bulkwrite-insert-004.phpt index ded802ee0..aaa74b99c 100644 --- a/tests/bulk/bulkwrite-insert-004.phpt +++ b/tests/bulk/bulkwrite-insert-004.phpt @@ -17,6 +17,7 @@ class MySerializableId implements MongoDB\BSON\Serializable $this->id = $id; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return ['id' => $this->id]; @@ -25,7 +26,7 @@ class MySerializableId implements MongoDB\BSON\Serializable class MyPersistableId extends MySerializableId implements MongoDB\BSON\Persistable { - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { $this->id = $data['id']; } diff --git a/tests/bulk/bulkwrite-update-001.phpt b/tests/bulk/bulkwrite-update-001.phpt index 6c15d99c9..a02a78a90 100644 --- a/tests/bulk/bulkwrite-update-001.phpt +++ b/tests/bulk/bulkwrite-update-001.phpt @@ -19,6 +19,7 @@ class MyClass implements MongoDB\BSON\Persistable $this->child = $child; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return [ @@ -27,7 +28,7 @@ class MyClass implements MongoDB\BSON\Persistable ]; } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { $this->id = $data['_id']; $this->child = $data['child']; diff --git a/tests/bulk/bulkwrite-update-004.phpt b/tests/bulk/bulkwrite-update-004.phpt index d242b9f8b..30cfc2d02 100644 --- a/tests/bulk/bulkwrite-update-004.phpt +++ b/tests/bulk/bulkwrite-update-004.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { if ($event->getCommandName() !== 'update') { return; @@ -20,11 +20,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("update included hint: %s\n", json_encode($event->getCommand()->updates[0]->hint)); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/causal-consistency/causal-consistency-003.phpt b/tests/causal-consistency/causal-consistency-003.phpt index 89240e09b..546ca9cfc 100644 --- a/tests/causal-consistency/causal-consistency-003.phpt +++ b/tests/causal-consistency/causal-consistency-003.phpt @@ -68,11 +68,11 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { $reply = $event->getReply(); $hasOperationTime = isset($reply->{'operationTime'}); @@ -84,7 +84,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/causal-consistency/causal-consistency-004.phpt b/tests/causal-consistency/causal-consistency-004.phpt index 6c36698eb..4ea41c6b4 100644 --- a/tests/causal-consistency/causal-consistency-004.phpt +++ b/tests/causal-consistency/causal-consistency-004.phpt @@ -90,11 +90,11 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { $reply = $event->getReply(); $hasOperationTime = isset($reply->operationTime); @@ -106,7 +106,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/causal-consistency/causal-consistency-005.phpt b/tests/causal-consistency/causal-consistency-005.phpt index d01c94a4f..37da520e0 100644 --- a/tests/causal-consistency/causal-consistency-005.phpt +++ b/tests/causal-consistency/causal-consistency-005.phpt @@ -51,7 +51,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $hasAfterClusterTime = isset($command->readConcern->afterClusterTime); @@ -62,7 +62,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { $reply = $event->getReply(); $hasOperationTime = isset($reply->operationTime); @@ -74,7 +74,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/causal-consistency/causal-consistency-006.phpt b/tests/causal-consistency/causal-consistency-006.phpt index e8470035b..f3607a990 100644 --- a/tests/causal-consistency/causal-consistency-006.phpt +++ b/tests/causal-consistency/causal-consistency-006.phpt @@ -65,7 +65,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $hasAfterClusterTime = isset($command->readConcern->afterClusterTime); @@ -76,7 +76,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { $reply = $event->getReply(); $hasOperationTime = isset($reply->operationTime); @@ -88,7 +88,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/command/command-ctor-001.phpt b/tests/command/command-ctor-001.phpt index 24929f4d7..024b34d96 100644 --- a/tests/command/command-ctor-001.phpt +++ b/tests/command/command-ctor-001.phpt @@ -19,6 +19,7 @@ class MyClass implements MongoDB\BSON\Persistable $this->child = $child; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return [ @@ -27,7 +28,7 @@ class MyClass implements MongoDB\BSON\Persistable ]; } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { $this->id = $data['_id']; $this->child = $data['child']; diff --git a/tests/command/cursor-batchsize-001.phpt b/tests/command/cursor-batchsize-001.phpt index bd72cf1a1..520b2a380 100644 --- a/tests/command/cursor-batchsize-001.phpt +++ b/tests/command/cursor-batchsize-001.phpt @@ -37,7 +37,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); @@ -50,7 +50,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { $reply = $event->getReply(); @@ -63,7 +63,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/command/cursor-batchsize-002.phpt b/tests/command/cursor-batchsize-002.phpt index c76437fb9..feb12f637 100644 --- a/tests/command/cursor-batchsize-002.phpt +++ b/tests/command/cursor-batchsize-002.phpt @@ -37,7 +37,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); @@ -50,7 +50,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { $reply = $event->getReply(); @@ -63,7 +63,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/command/cursor-comment-001.phpt b/tests/command/cursor-comment-001.phpt index 7a8393c19..62814f8b7 100644 --- a/tests/command/cursor-comment-001.phpt +++ b/tests/command/cursor-comment-001.phpt @@ -39,7 +39,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); @@ -48,11 +48,11 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug0924-001.phpt b/tests/cursor/bug0924-001.phpt index 0e3793450..a8cef98c1 100644 --- a/tests/cursor/bug0924-001.phpt +++ b/tests/cursor/bug0924-001.phpt @@ -17,12 +17,13 @@ class MyDocument implements MongoDB\BSON\Serializable, MongoDB\BSON\Unserializab $this->data['_id'] = $id; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return (object) $this->data; } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { printf("%s called for ID: %s\n", __METHOD__, $data['_id']); $this->data = $data; diff --git a/tests/cursor/bug0924-002.phpt b/tests/cursor/bug0924-002.phpt index c28c94443..594dd591d 100644 --- a/tests/cursor/bug0924-002.phpt +++ b/tests/cursor/bug0924-002.phpt @@ -17,12 +17,13 @@ class MyDocument implements MongoDB\BSON\Persistable $this->data['_id'] = $id; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return (object) $this->data; } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { printf("%s called for ID: %s\n", __METHOD__, $data['_id']); $this->data = $data; diff --git a/tests/cursor/bug1050-001.phpt b/tests/cursor/bug1050-001.phpt index b64efbbdc..d1da9ae69 100644 --- a/tests/cursor/bug1050-001.phpt +++ b/tests/cursor/bug1050-001.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { if ($event->getCommandName() !== 'aggregate' && $event->getCommandName() !== 'getMore') { return; @@ -20,7 +20,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("Executing command: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { if ($event->getCommandName() !== 'aggregate' && $event->getCommandName() !== 'getMore') { return; @@ -29,7 +29,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("Executing command took %0.6f seconds\n", $event->getDurationMicros() / 1000000); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug1050-002.phpt b/tests/cursor/bug1050-002.phpt index 42c3bfe6c..b50c3fb24 100644 --- a/tests/cursor/bug1050-002.phpt +++ b/tests/cursor/bug1050-002.phpt @@ -19,7 +19,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { if ($event->getCommandName() !== 'aggregate' && $event->getCommandName() !== 'getMore') { return; @@ -28,7 +28,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("Executing command: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { if ($event->getCommandName() !== 'aggregate' && $event->getCommandName() !== 'getMore') { return; @@ -37,7 +37,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("Executing command took %0.6f seconds\n", $event->getDurationMicros() / 1000000); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug1152-001.phpt b/tests/cursor/bug1152-001.phpt index aefc107c7..328ca045d 100644 --- a/tests/cursor/bug1152-001.phpt +++ b/tests/cursor/bug1152-001.phpt @@ -56,7 +56,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber printf("Unique session IDs used: %d\n", count(array_unique($this->lsidByRequestId))); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $requestId = $event->getRequestId(); $sessionId = bin2hex((string) $event->getCommand()->lsid->id); @@ -92,7 +92,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { /* Associate the aggregate's session ID with its cursor ID so it can be * looked up by the subsequent getMore or killCursors */ @@ -104,7 +104,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug1152-002.phpt b/tests/cursor/bug1152-002.phpt index 39f7016ac..550b18ad3 100644 --- a/tests/cursor/bug1152-002.phpt +++ b/tests/cursor/bug1152-002.phpt @@ -54,7 +54,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber printf("Unique session IDs used: %d\n", count(array_unique($this->lsidByRequestId))); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $requestId = $event->getRequestId(); $sessionId = bin2hex((string) $event->getCommand()->lsid->id); @@ -90,7 +90,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { /* Associate the aggregate's session ID with its cursor ID so it can be * looked up by the subsequent getMore or killCursors */ @@ -102,7 +102,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug1274-001.phpt b/tests/cursor/bug1274-001.phpt index 9f3f3e132..8f02d3310 100644 --- a/tests/cursor/bug1274-001.phpt +++ b/tests/cursor/bug1274-001.phpt @@ -18,7 +18,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->pid = getmypid(); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $commandName = $event->getCommandName(); @@ -32,11 +32,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug1274-002.phpt b/tests/cursor/bug1274-002.phpt index fcecddc3c..c53df6b0e 100644 --- a/tests/cursor/bug1274-002.phpt +++ b/tests/cursor/bug1274-002.phpt @@ -19,7 +19,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->pid = getmypid(); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $commandName = $event->getCommandName(); @@ -33,11 +33,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug1274-003.phpt b/tests/cursor/bug1274-003.phpt index 65518c5ed..386366232 100644 --- a/tests/cursor/bug1274-003.phpt +++ b/tests/cursor/bug1274-003.phpt @@ -18,7 +18,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->pid = getmypid(); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $commandName = $event->getCommandName(); @@ -32,11 +32,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug1274-004.phpt b/tests/cursor/bug1274-004.phpt index f600dbff7..b5d6eefec 100644 --- a/tests/cursor/bug1274-004.phpt +++ b/tests/cursor/bug1274-004.phpt @@ -18,7 +18,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->pid = getmypid(); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $commandName = $event->getCommandName(); @@ -32,11 +32,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug1274-005.phpt b/tests/cursor/bug1274-005.phpt index 69a298143..e7c54525f 100644 --- a/tests/cursor/bug1274-005.phpt +++ b/tests/cursor/bug1274-005.phpt @@ -19,7 +19,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->pid = getmypid(); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $commandName = $event->getCommandName(); @@ -33,11 +33,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug1274-006.phpt b/tests/cursor/bug1274-006.phpt index 2e0edd10c..3debdabff 100644 --- a/tests/cursor/bug1274-006.phpt +++ b/tests/cursor/bug1274-006.phpt @@ -18,7 +18,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->pid = getmypid(); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $commandName = $event->getCommandName(); @@ -32,11 +32,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/bug1529-001.phpt b/tests/cursor/bug1529-001.phpt index 90045fa49..dfa043652 100644 --- a/tests/cursor/bug1529-001.phpt +++ b/tests/cursor/bug1529-001.phpt @@ -20,7 +20,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->pid = getmypid(); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $commandName = $event->getCommandName(); @@ -34,11 +34,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/cursor/cursor-setTypeMap_error-004.phpt b/tests/cursor/cursor-setTypeMap_error-004.phpt index e4511c406..42438bc95 100644 --- a/tests/cursor/cursor-setTypeMap_error-004.phpt +++ b/tests/cursor/cursor-setTypeMap_error-004.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyDocument extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data, ArrayObject::ARRAY_AS_PROPS); } diff --git a/tests/cursor/cursor-toArray-002.phpt b/tests/cursor/cursor-toArray-002.phpt index d867e22e9..7f002695f 100644 --- a/tests/cursor/cursor-toArray-002.phpt +++ b/tests/cursor/cursor-toArray-002.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { parent::__construct($data); } diff --git a/tests/exception/bulkwriteexception-getwriteresult-001.phpt b/tests/exception/bulkwriteexception-getwriteresult-001.phpt index 808ddceca..419e9c8e1 100644 --- a/tests/exception/bulkwriteexception-getwriteresult-001.phpt +++ b/tests/exception/bulkwriteexception-getwriteresult-001.phpt @@ -1,22 +1,60 @@ --TEST-- MongoDB\Driver\Exception\BulkWriteException::getWriteResult() +--SKIPIF-- + + + --FILE-- 1]; +$manager = create_test_manager(); -$reflection = new ReflectionClass($exception); - -$resultDocumentProperty = $reflection->getProperty('writeResult'); -$resultDocumentProperty->setAccessible(true); -$resultDocumentProperty->setValue($exception, $writeResult); - -var_dump($writeResult === $exception->getWriteResult()); +try { + $bulk = new MongoDB\Driver\BulkWrite; + $bulk->insert(['_id' => 1]); + $bulk->insert(['_id' => 1]); + $result = $manager->executeBulkWrite(NS, $bulk); +} catch (MongoDB\Driver\Exception\BulkWriteException $e) { + var_dump($e->getWriteResult()); +} ?> ===DONE=== ---EXPECT-- -bool(true) +--EXPECTF-- +object(MongoDB\Driver\WriteResult)#%d (%d) { + ["nInserted"]=> + int(1) + ["nMatched"]=> + int(0) + ["nModified"]=> + int(0) + ["nRemoved"]=> + int(0) + ["nUpserted"]=> + int(0) + ["upsertedIds"]=> + array(0) { + } + ["writeErrors"]=> + array(1) { + [0]=> + object(MongoDB\Driver\WriteError)#%d (%d) { + ["message"]=> + string(%d) %s + ["code"]=> + int(11000) + ["index"]=> + int(1) + ["info"]=> + NULL + } + } + ["writeConcernError"]=> + NULL + ["writeConcern"]=> + object(MongoDB\Driver\WriteConcern)#%d (%d) { + } +} ===DONE=== diff --git a/tests/exception/commandexception-getresultdocument-001.phpt b/tests/exception/commandexception-getresultdocument-001.phpt index f8880cc20..40c8989f7 100644 --- a/tests/exception/commandexception-getresultdocument-001.phpt +++ b/tests/exception/commandexception-getresultdocument-001.phpt @@ -4,7 +4,7 @@ MongoDB\Driver\Exception\CommandException::getResultDocument() 1]; +$resultDocument = (object) ['x' => 1]; $reflection = new ReflectionClass($exception); diff --git a/tests/manager/bug1163-001.phpt b/tests/manager/bug1163-001.phpt index 01accd4c6..beefbdffb 100644 --- a/tests/manager/bug1163-001.phpt +++ b/tests/manager/bug1163-001.phpt @@ -41,7 +41,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { if ($event->getCommandName() === 'insert') { $command = $event->getCommand(); @@ -53,11 +53,11 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/manager/manager-addSubscriber-001.phpt b/tests/manager/manager-addSubscriber-001.phpt index fabce2cf3..7bba718e4 100644 --- a/tests/manager/manager-addSubscriber-001.phpt +++ b/tests/manager/manager-addSubscriber-001.phpt @@ -11,17 +11,17 @@ require_once __DIR__ . '/../utils/basic.inc'; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("commandSucceeded: %s\n", $event->getCommandName()); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { printf("commandFailed: %s\n", $event->getCommandName()); } diff --git a/tests/manager/manager-addSubscriber-002.phpt b/tests/manager/manager-addSubscriber-002.phpt index efb782f3b..2998f37f9 100644 --- a/tests/manager/manager-addSubscriber-002.phpt +++ b/tests/manager/manager-addSubscriber-002.phpt @@ -18,17 +18,17 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber $this->id = $id; } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("MySubscriber(%s) commandStarted: %s\n", $this->id, $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("MySubscriber(%s) commandSucceeded: %s\n", $this->id, $event->getCommandName()); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { printf("MySubscriber(%s) commandFailed: %s\n", $this->id, $event->getCommandName()); } diff --git a/tests/manager/manager-addSubscriber-003.phpt b/tests/manager/manager-addSubscriber-003.phpt index 03abcfb56..63a1eabe7 100644 --- a/tests/manager/manager-addSubscriber-003.phpt +++ b/tests/manager/manager-addSubscriber-003.phpt @@ -11,17 +11,17 @@ require_once __DIR__ . '/../utils/basic.inc'; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("commandSucceeded: %s\n", $event->getCommandName()); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { printf("commandFailed: %s\n", $event->getCommandName()); } diff --git a/tests/manager/manager-addSubscriber-004.phpt b/tests/manager/manager-addSubscriber-004.phpt index a801495df..0b1f875e9 100644 --- a/tests/manager/manager-addSubscriber-004.phpt +++ b/tests/manager/manager-addSubscriber-004.phpt @@ -11,17 +11,17 @@ require_once __DIR__ . '/../utils/basic.inc'; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("commandSucceeded: %s\n", $event->getCommandName()); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { printf("commandFailed: %s\n", $event->getCommandName()); } diff --git a/tests/manager/manager-addSubscriber-005.phpt b/tests/manager/manager-addSubscriber-005.phpt index 00213a320..6c3e40873 100644 --- a/tests/manager/manager-addSubscriber-005.phpt +++ b/tests/manager/manager-addSubscriber-005.phpt @@ -11,17 +11,17 @@ require_once __DIR__ . '/../utils/basic.inc'; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("commandSucceeded: %s\n", $event->getCommandName()); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { printf("commandFailed: %s\n", $event->getCommandName()); } diff --git a/tests/manager/manager-addSubscriber-006.phpt b/tests/manager/manager-addSubscriber-006.phpt index 6c81de4c8..bbc2f084b 100644 --- a/tests/manager/manager-addSubscriber-006.phpt +++ b/tests/manager/manager-addSubscriber-006.phpt @@ -11,17 +11,17 @@ require_once __DIR__ . '/../utils/basic.inc'; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("commandStarted: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("commandSucceeded: %s\n", $event->getCommandName()); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { printf("commandFailed: %s\n", $event->getCommandName()); } diff --git a/tests/manager/manager-ctor-disableClientPersistence-008.phpt b/tests/manager/manager-ctor-disableClientPersistence-008.phpt index dfe65c163..7a388c582 100644 --- a/tests/manager/manager-ctor-disableClientPersistence-008.phpt +++ b/tests/manager/manager-ctor-disableClientPersistence-008.phpt @@ -11,17 +11,17 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { private $events = []; - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("Command started: %s\n", $event->getCommandName()); $this->events[] = $event; } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/manager/manager-ctor-disableClientPersistence-009.phpt b/tests/manager/manager-ctor-disableClientPersistence-009.phpt index 9b5cfc717..62209a103 100644 --- a/tests/manager/manager-ctor-disableClientPersistence-009.phpt +++ b/tests/manager/manager-ctor-disableClientPersistence-009.phpt @@ -11,17 +11,17 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { private $events = []; - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("Command succeeded: %s\n", $event->getCommandName()); $this->events[] = $event; } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/manager/manager-ctor-disableClientPersistence-010.phpt b/tests/manager/manager-ctor-disableClientPersistence-010.phpt index 79e81cf89..e09e6fe6c 100644 --- a/tests/manager/manager-ctor-disableClientPersistence-010.phpt +++ b/tests/manager/manager-ctor-disableClientPersistence-010.phpt @@ -11,15 +11,15 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { private $events = []; - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { printf("Command failed: %s\n", $event->getCommandName()); $this->events[] = $event; diff --git a/tests/manager/manager-ctor-disableClientPersistence-011.phpt b/tests/manager/manager-ctor-disableClientPersistence-011.phpt index 5f5f24863..3e8a53353 100644 --- a/tests/manager/manager-ctor-disableClientPersistence-011.phpt +++ b/tests/manager/manager-ctor-disableClientPersistence-011.phpt @@ -11,17 +11,17 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { private $events = []; - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("Command started: %s\n", $event->getCommandName()); $this->events[] = $event; } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/manager/manager-ctor-serverApi-001.phpt b/tests/manager/manager-ctor-serverApi-001.phpt index 092404397..f26e7c155 100644 --- a/tests/manager/manager-ctor-serverApi-001.phpt +++ b/tests/manager/manager-ctor-serverApi-001.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); var_dump($command->apiVersion); @@ -19,11 +19,11 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber var_dump(isset($command->apiDeprecationErrors)); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/manager/manager-executeQuery-005.phpt b/tests/manager/manager-executeQuery-005.phpt index 84f8f03b9..cdf763145 100644 --- a/tests/manager/manager-executeQuery-005.phpt +++ b/tests/manager/manager-executeQuery-005.phpt @@ -10,7 +10,7 @@ MongoDB\Driver\Manager::executeQuery() with filter and projection require_once __DIR__ . "/../utils/basic.inc"; class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable { - function bsonUnserialize(array $data) { + public function bsonUnserialize(array $data): void { parent::__construct($data); } } diff --git a/tests/manager/manager-removeSubscriber-001.phpt b/tests/manager/manager-removeSubscriber-001.phpt index fed974fe4..8226dc870 100644 --- a/tests/manager/manager-removeSubscriber-001.phpt +++ b/tests/manager/manager-removeSubscriber-001.phpt @@ -18,17 +18,17 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber $this->id = $id; } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("MySubscriber(%s) commandStarted: %s\n", $this->id, $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("MySubscriber(%s) commandSucceeded: %s\n", $this->id, $event->getCommandName()); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { printf("MySubscriber(%s) commandFailed: %s\n", $this->id, $event->getCommandName()); } diff --git a/tests/manager/manager-removeSubscriber-002.phpt b/tests/manager/manager-removeSubscriber-002.phpt index 004bb50a1..55f800e98 100644 --- a/tests/manager/manager-removeSubscriber-002.phpt +++ b/tests/manager/manager-removeSubscriber-002.phpt @@ -18,17 +18,17 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber $this->id = $id; } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("MySubscriber(%s) commandStarted: %s\n", $this->id, $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { printf("MySubscriber(%s) commandSucceeded: %s\n", $this->id, $event->getCommandName()); } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { printf("MySubscriber(%s) commandFailed: %s\n", $this->id, $event->getCommandName()); } diff --git a/tests/query/query-ctor-001.phpt b/tests/query/query-ctor-001.phpt index 8323ad437..98861f87c 100644 --- a/tests/query/query-ctor-001.phpt +++ b/tests/query/query-ctor-001.phpt @@ -19,6 +19,7 @@ class MyClass implements MongoDB\BSON\Persistable $this->child = $child; } + #[\ReturnTypeWillChange] public function bsonSerialize() { return [ @@ -27,7 +28,7 @@ class MyClass implements MongoDB\BSON\Persistable ]; } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { $this->id = $data['_id']; $this->child = $data['child']; diff --git a/tests/query/query-ctor-comment-001.phpt b/tests/query/query-ctor-comment-001.phpt index b0ecc3f4f..ddb0b79fa 100644 --- a/tests/query/query-ctor-comment-001.phpt +++ b/tests/query/query-ctor-comment-001.phpt @@ -12,7 +12,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); @@ -25,11 +25,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s included comment: %s\n", $event->getCommandName(), json_encode($command->comment)); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/query/query-ctor-comment_error-001.phpt b/tests/query/query-ctor-comment_error-001.phpt index c4f1bd80f..31375831f 100644 --- a/tests/query/query-ctor-comment_error-001.phpt +++ b/tests/query/query-ctor-comment_error-001.phpt @@ -7,6 +7,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class Comment implements MongoDB\BSON\Serializable { + #[\ReturnTypeWillChange] public function bsonSerialize(): array { throw new Exception('php_phongo_zval_to_bson_value fails'); diff --git a/tests/query/query-ctor-let-001.phpt b/tests/query/query-ctor-let-001.phpt index 14a3a88f1..22fb21b8a 100644 --- a/tests/query/query-ctor-let-001.phpt +++ b/tests/query/query-ctor-let-001.phpt @@ -12,7 +12,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); @@ -25,11 +25,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s included let: %s\n", $event->getCommandName(), json_encode($command->let)); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/readConcern/readconcern-ctor_error-002.phpt b/tests/readConcern/readconcern-ctor_error-002.phpt index 48446ac70..7e142d738 100644 --- a/tests/readConcern/readconcern-ctor_error-002.phpt +++ b/tests/readConcern/readconcern-ctor_error-002.phpt @@ -15,15 +15,15 @@ $tests = [ foreach ($tests as $test) { echo throws(function() use ($test) { new MongoDB\Driver\ReadConcern($test); - }, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n"; + }, TypeError::class), "\n"; } ?> ===DONE=== --EXPECTF-- -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -%SMongoDB\Driver\ReadConcern::__construct()%sstring, array given -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -%SMongoDB\Driver\ReadConcern::__construct()%sstring, %r(object|stdClass)%r given +OK: Got TypeError +%SMongoDB\Driver\ReadConcern::__construct()%sstring or null, array given +OK: Got TypeError +%SMongoDB\Driver\ReadConcern::__construct()%sstring or null, %r(object|stdClass)%r given ===DONE=== diff --git a/tests/retryable-reads/retryable-reads-001.phpt b/tests/retryable-reads/retryable-reads-001.phpt index 0f3e749cf..886615284 100644 --- a/tests/retryable-reads/retryable-reads-001.phpt +++ b/tests/retryable-reads/retryable-reads-001.phpt @@ -11,16 +11,16 @@ require_once __DIR__ . "/../utils/basic.inc"; class Observer implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("Command started: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/retryable-reads/retryable-reads-002.phpt b/tests/retryable-reads/retryable-reads-002.phpt index fcc21ee9e..e1855f5fd 100644 --- a/tests/retryable-reads/retryable-reads-002.phpt +++ b/tests/retryable-reads/retryable-reads-002.phpt @@ -11,16 +11,16 @@ require_once __DIR__ . "/../utils/basic.inc"; class Observer implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("Command started: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/retryable-reads/retryable-reads_error-001.phpt b/tests/retryable-reads/retryable-reads_error-001.phpt index 7038ab1e2..fa96eecc6 100644 --- a/tests/retryable-reads/retryable-reads_error-001.phpt +++ b/tests/retryable-reads/retryable-reads_error-001.phpt @@ -10,16 +10,16 @@ require_once __DIR__ . "/../utils/basic.inc"; class Observer implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("Command started: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/retryable-reads/retryable-reads_error-002.phpt b/tests/retryable-reads/retryable-reads_error-002.phpt index 84a9e6bd2..78fb21a11 100644 --- a/tests/retryable-reads/retryable-reads_error-002.phpt +++ b/tests/retryable-reads/retryable-reads_error-002.phpt @@ -10,16 +10,16 @@ require_once __DIR__ . "/../utils/basic.inc"; class Observer implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { printf("Command started: %s\n", $event->getCommandName()); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/retryable-writes/retryable-writes-001.phpt b/tests/retryable-writes/retryable-writes-001.phpt index edb0d95d9..84f31f5e6 100644 --- a/tests/retryable-writes/retryable-writes-001.phpt +++ b/tests/retryable-writes/retryable-writes-001.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $hasTransactionId = isset($command->lsid) && isset($command->txnNumber); @@ -19,11 +19,11 @@ class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscrib printf("%s command includes transaction ID: %s\n", $event->getCommandName(), $hasTransactionId ? 'yes' : 'no'); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/retryable-writes/retryable-writes-002.phpt b/tests/retryable-writes/retryable-writes-002.phpt index 8ac1d21d5..83c537446 100644 --- a/tests/retryable-writes/retryable-writes-002.phpt +++ b/tests/retryable-writes/retryable-writes-002.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $hasTransactionId = isset($command->lsid) && isset($command->txnNumber); @@ -19,11 +19,11 @@ class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscrib printf("%s command includes transaction ID: %s\n", $event->getCommandName(), $hasTransactionId ? 'yes' : 'no'); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/retryable-writes/retryable-writes-003.phpt b/tests/retryable-writes/retryable-writes-003.phpt index f8d5fc7a2..173962a10 100644 --- a/tests/retryable-writes/retryable-writes-003.phpt +++ b/tests/retryable-writes/retryable-writes-003.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $hasTransactionId = isset($command->lsid) && isset($command->txnNumber); @@ -19,11 +19,11 @@ class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscrib printf("%s command includes transaction ID: %s\n", $event->getCommandName(), $hasTransactionId ? 'yes' : 'no'); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/retryable-writes/retryable-writes-004.phpt b/tests/retryable-writes/retryable-writes-004.phpt index 295ca8ec2..a91b9fbf8 100644 --- a/tests/retryable-writes/retryable-writes-004.phpt +++ b/tests/retryable-writes/retryable-writes-004.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $hasTransactionId = isset($command->lsid) && isset($command->txnNumber); @@ -19,11 +19,11 @@ class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscrib printf("%s command includes transaction ID: %s\n", $event->getCommandName(), $hasTransactionId ? 'yes' : 'no'); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/retryable-writes/retryable-writes-005.phpt b/tests/retryable-writes/retryable-writes-005.phpt index 7bda7ab58..defb57cd1 100644 --- a/tests/retryable-writes/retryable-writes-005.phpt +++ b/tests/retryable-writes/retryable-writes-005.phpt @@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscriber { - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $hasTransactionId = isset($command->lsid) && isset($command->txnNumber); @@ -19,11 +19,11 @@ class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscrib printf("%s command includes transaction ID: %s\n", $event->getCommandName(), $hasTransactionId ? 'yes' : 'no'); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/session/bug1274-002.phpt b/tests/session/bug1274-002.phpt index f5886865f..7e38f1482 100644 --- a/tests/session/bug1274-002.phpt +++ b/tests/session/bug1274-002.phpt @@ -19,7 +19,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->pid = getmypid(); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $commandName = $event->getCommandName(); @@ -33,11 +33,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/session/bug1274-003.phpt b/tests/session/bug1274-003.phpt index 802d6f7f8..f5575586b 100644 --- a/tests/session/bug1274-003.phpt +++ b/tests/session/bug1274-003.phpt @@ -46,7 +46,7 @@ class SessionLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->manager->executeBulkWrite($this->logNamespace, $bulk); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); @@ -60,11 +60,11 @@ class SessionLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/session/bug1274-005.phpt b/tests/session/bug1274-005.phpt index b9df30822..9442b1c4d 100644 --- a/tests/session/bug1274-005.phpt +++ b/tests/session/bug1274-005.phpt @@ -19,7 +19,7 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->pid = getmypid(); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $commandName = $event->getCommandName(); @@ -33,11 +33,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/session/bug1274-006.phpt b/tests/session/bug1274-006.phpt index 642a934a8..0b6f783ce 100644 --- a/tests/session/bug1274-006.phpt +++ b/tests/session/bug1274-006.phpt @@ -46,7 +46,7 @@ class SessionLogger implements MongoDB\Driver\Monitoring\CommandSubscriber $this->manager->executeBulkWrite($this->logNamespace, $bulk); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); @@ -60,11 +60,11 @@ class SessionLogger implements MongoDB\Driver\Monitoring\CommandSubscriber printf("%s executes %s\n", $process, $commandName); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/session/session-002.phpt b/tests/session/session-002.phpt index a83b3d539..02b82ef3a 100644 --- a/tests/session/session-002.phpt +++ b/tests/session/session-002.phpt @@ -94,7 +94,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { $command = $event->getCommand(); $hasClusterTime = isset($command->{'$clusterTime'}); @@ -106,7 +106,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { $reply = $event->getReply(); $hasClusterTime = isset($reply->{'$clusterTime'}); @@ -118,7 +118,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber } } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/session/session-advanceOperationTime-003.phpt b/tests/session/session-advanceOperationTime-003.phpt index 3c51346d6..3bcb5f88e 100644 --- a/tests/session/session-advanceOperationTime-003.phpt +++ b/tests/session/session-advanceOperationTime-003.phpt @@ -10,17 +10,17 @@ require_once __DIR__ . "/../utils/basic.inc"; class MyTimestamp implements MongoDB\BSON\TimestampInterface { - public function getIncrement() + public function getIncrement(): int { return 5678; } - public function getTimestamp() + public function getTimestamp(): int { return 1234; } - public function __toString() + public function __toString(): string { return sprintf('[%d:%d]', $this->getIncrement(), $this->getTimestamp()); } diff --git a/tests/session/session-advanceOperationTime_error-001.phpt b/tests/session/session-advanceOperationTime_error-001.phpt index 8192bfbf9..2cf429015 100644 --- a/tests/session/session-advanceOperationTime_error-001.phpt +++ b/tests/session/session-advanceOperationTime_error-001.phpt @@ -19,7 +19,7 @@ class MyTimestamp implements MongoDB\BSON\TimestampInterface $this->failTimestamp = $failTimestamp; } - public function getIncrement() + public function getIncrement(): int { if ($this->failIncrement) { throw new Exception('getIncrement() failed'); @@ -28,7 +28,7 @@ class MyTimestamp implements MongoDB\BSON\TimestampInterface return 5678; } - public function getTimestamp() + public function getTimestamp(): int { if ($this->failTimestamp) { throw new Exception('getTimestamp() failed'); @@ -37,7 +37,7 @@ class MyTimestamp implements MongoDB\BSON\TimestampInterface return 1234; } - public function __toString() + public function __toString(): string { return sprintf('[%d:%d]', $this->getIncrement(), $this->getTimestamp()); } diff --git a/tests/session/session-commitTransaction-001.phpt b/tests/session/session-commitTransaction-001.phpt index 301935dca..1099af348 100644 --- a/tests/session/session-commitTransaction-001.phpt +++ b/tests/session/session-commitTransaction-001.phpt @@ -42,7 +42,7 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { if ($event->getCommandName() !== 'commitTransaction') { return; @@ -51,11 +51,11 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber printf("commitTransaction included write concern: %s\n", json_encode($event->getCommand()->writeConcern)); } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } } diff --git a/tests/standalone/bug0545.phpt b/tests/standalone/bug0545.phpt index 026255e98..c085c3e3b 100644 --- a/tests/standalone/bug0545.phpt +++ b/tests/standalone/bug0545.phpt @@ -10,13 +10,14 @@ require_once __DIR__ . "/../utils/basic.inc"; class Book implements MongoDB\BSON\Persistable { + #[\ReturnTypeWillChange] public function bsonSerialize() { $data = get_object_vars($this); return $data; } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { foreach ($data as $name => $value) { $this->{$name} = $value; @@ -26,13 +27,14 @@ class Book implements MongoDB\BSON\Persistable class Page implements MongoDB\BSON\Persistable { + #[\ReturnTypeWillChange] public function bsonSerialize() { $data = get_object_vars($this); return $data; } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { foreach ($data as $name => $value) { $this->{$name} = $value; diff --git a/tests/topologyDescription/topologyDescription-debug-001.phpt b/tests/topologyDescription/topologyDescription-debug-001.phpt index e96ebefcd..a45fa1b3b 100644 --- a/tests/topologyDescription/topologyDescription-debug-001.phpt +++ b/tests/topologyDescription/topologyDescription-debug-001.phpt @@ -11,26 +11,26 @@ class TopologyDescriptionProvider implements MongoDB\Driver\Monitoring\SDAMSubsc { private $topologyDescription; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void { $this->topologyDescription = $event->getNewDescription(); } - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} public function getTopologyDescription() { diff --git a/tests/topologyDescription/topologyDescription-getServers-001.phpt b/tests/topologyDescription/topologyDescription-getServers-001.phpt index 1ca2ccd78..102df1076 100644 --- a/tests/topologyDescription/topologyDescription-getServers-001.phpt +++ b/tests/topologyDescription/topologyDescription-getServers-001.phpt @@ -11,26 +11,26 @@ class TopologyDescriptionProvider implements MongoDB\Driver\Monitoring\SDAMSubsc { private $topologyDescription; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void { $this->topologyDescription = $event->getNewDescription(); } - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} public function getTopologyDescription() { diff --git a/tests/topologyDescription/topologyDescription-getType-001.phpt b/tests/topologyDescription/topologyDescription-getType-001.phpt index 64a6e3b0d..156e5de0a 100644 --- a/tests/topologyDescription/topologyDescription-getType-001.phpt +++ b/tests/topologyDescription/topologyDescription-getType-001.phpt @@ -11,26 +11,26 @@ class TopologyDescriptionProvider implements MongoDB\Driver\Monitoring\SDAMSubsc { private $topologyDescription; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void { $this->topologyDescription = $event->getNewDescription(); } - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} public function getTopologyDescription() { diff --git a/tests/topologyDescription/topologyDescription-hasReadableServer-001.phpt b/tests/topologyDescription/topologyDescription-hasReadableServer-001.phpt index 1f7c2d290..7baeaddd8 100644 --- a/tests/topologyDescription/topologyDescription-hasReadableServer-001.phpt +++ b/tests/topologyDescription/topologyDescription-hasReadableServer-001.phpt @@ -11,26 +11,26 @@ class TopologyDescriptionProvider implements MongoDB\Driver\Monitoring\SDAMSubsc { private $topologyDescription; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void { $this->topologyDescription = $event->getNewDescription(); } - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} public function getTopologyDescription() { diff --git a/tests/topologyDescription/topologyDescription-hasReadableServer-002.phpt b/tests/topologyDescription/topologyDescription-hasReadableServer-002.phpt index c0234ff3b..78ba72841 100644 --- a/tests/topologyDescription/topologyDescription-hasReadableServer-002.phpt +++ b/tests/topologyDescription/topologyDescription-hasReadableServer-002.phpt @@ -11,26 +11,26 @@ class TopologyDescriptionProvider implements MongoDB\Driver\Monitoring\SDAMSubsc { private $topologyDescription; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void { $this->topologyDescription = $event->getNewDescription(); } - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} public function getTopologyDescription() { diff --git a/tests/topologyDescription/topologyDescription-hasReadableServer_error-001.phpt b/tests/topologyDescription/topologyDescription-hasReadableServer_error-001.phpt index e6fc8e1fc..a2e942bc8 100644 --- a/tests/topologyDescription/topologyDescription-hasReadableServer_error-001.phpt +++ b/tests/topologyDescription/topologyDescription-hasReadableServer_error-001.phpt @@ -11,26 +11,26 @@ class TopologyDescriptionProvider implements MongoDB\Driver\Monitoring\SDAMSubsc { private $topologyDescription; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void { $this->topologyDescription = $event->getNewDescription(); } - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} public function getTopologyDescription() { @@ -44,7 +44,6 @@ class TopologyDescriptionProvider implements MongoDB\Driver\Monitoring\SDAMSubsc } $tests = [ - null, 1, [], ]; @@ -64,5 +63,4 @@ foreach ($tests as $test) { --EXPECT-- OK: Got TypeError OK: Got TypeError -OK: Got TypeError ===DONE=== diff --git a/tests/topologyDescription/topologyDescription-hasWritableServer-001.phpt b/tests/topologyDescription/topologyDescription-hasWritableServer-001.phpt index 17be4fb7b..5a109e7d5 100644 --- a/tests/topologyDescription/topologyDescription-hasWritableServer-001.phpt +++ b/tests/topologyDescription/topologyDescription-hasWritableServer-001.phpt @@ -11,26 +11,26 @@ class TopologyDescriptionProvider implements MongoDB\Driver\Monitoring\SDAMSubsc { private $topologyDescription; - public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) {} + public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event): void {} - public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) {} + public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event): void {} - public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event) {} + public function serverHeartbeatFailed(MongoDB\Driver\Monitoring\ServerHeartbeatFailedEvent $event): void {} - public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event) {} + public function serverHeartbeatStarted(MongoDB\Driver\Monitoring\ServerHeartbeatStartedEvent $event): void {} - public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event) {} + public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} - public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) {} + public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void {} - public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) + public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void { $this->topologyDescription = $event->getNewDescription(); } - public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event) {} + public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} - public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) {} + public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} public function getTopologyDescription() { diff --git a/tests/utils/classes.inc b/tests/utils/classes.inc index 57e4ae4be..f5a288cf5 100644 --- a/tests/utils/classes.inc +++ b/tests/utils/classes.inc @@ -7,19 +7,20 @@ class Person implements MongoDB\BSON\Persistable { protected $friends = array(); protected $secret = "none"; - function __construct($name, $age) { + public function __construct($name, $age) { $this->name = $name; $this->age = $age; $this->addresses = array(); $this->secret = "$name confidential info"; } - function addAddress(Address $address) { + public function addAddress(Address $address) { $this->addresses[] = $address; } - function addFriend(Person $friend) { + public function addFriend(Person $friend) { $this->friends[] = $friend; } - function bsonSerialize() { + #[\ReturnTypeWillChange] + public function bsonSerialize() { return array( "name" => $this->name, "age" => $this->age, @@ -27,7 +28,7 @@ class Person implements MongoDB\BSON\Persistable { "friends" => $this->friends, ); } - function bsonUnserialize(array $data) { + public function bsonUnserialize(array $data): void { $this->name = $data["name"]; $this->age = $data["age"]; $this->addresses = $data["addresses"]; @@ -38,17 +39,18 @@ class Address implements MongoDB\BSON\Persistable { protected $zip; protected $country; - function __construct($zip, $country) { + public function __construct($zip, $country) { $this->zip = $zip; $this->country = $country; } - function bsonSerialize() { + #[\ReturnTypeWillChange] + public function bsonSerialize() { return array( "zip" => $this->zip, "country" => $this->country, ); } - function bsonUnserialize(array $data) { + public function bsonUnserialize(array $data): void { $this->zip = $data["zip"]; $this->country = $data["country"]; } diff --git a/tests/utils/observer.php b/tests/utils/observer.php index cb424a09f..0f7432cfc 100644 --- a/tests/utils/observer.php +++ b/tests/utils/observer.php @@ -22,14 +22,14 @@ public function observe(callable $execution, callable $commandCallback) } } } - public function commandStarted(CommandStartedEvent $event) + public function commandStarted(CommandStartedEvent $event): void { $this->commands[] = $event->getCommand(); } - public function commandSucceeded(CommandSucceededEvent $event) + public function commandSucceeded(CommandSucceededEvent $event): void { } - public function commandFailed(CommandFailedEvent $event) + public function commandFailed(CommandFailedEvent $event): void { } } diff --git a/tests/writeError/writeerror-getInfo-002.phpt b/tests/writeError/writeerror-getInfo-002.phpt index ed1c0d9f6..d4ced2c80 100644 --- a/tests/writeError/writeerror-getInfo-002.phpt +++ b/tests/writeError/writeerror-getInfo-002.phpt @@ -46,18 +46,18 @@ class Test implements MongoDB\Driver\Monitoring\CommandSubscriber MongoDB\Driver\Monitoring\removeSubscriber($this); } - public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event) + public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void { } - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event) + public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void { if ($event->getCommandName() === 'insert') { $this->errInfo = $event->getReply()->writeErrors[0]->errInfo ?? null; } } - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event) + public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void { } }