From 088b111288e9919d2b8dd5fa1ebd81adbe553f0f Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 22:42:46 +0100 Subject: [PATCH 01/23] ZPP: move ZPP tests to zend_test --- {Zend/tests => ext/zend_test/tests/zpp}/iterable_or_null.phpt | 0 {Zend/tests => ext/zend_test/tests/zpp}/number_or_str_zpp.phpt | 0 .../zend_test/tests/zpp}/str_or_obj_of_class_zpp.phpt | 0 {Zend/tests => ext/zend_test/tests/zpp}/str_or_obj_zpp.phpt | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {Zend/tests => ext/zend_test/tests/zpp}/iterable_or_null.phpt (100%) rename {Zend/tests => ext/zend_test/tests/zpp}/number_or_str_zpp.phpt (100%) rename {Zend/tests => ext/zend_test/tests/zpp}/str_or_obj_of_class_zpp.phpt (100%) rename {Zend/tests => ext/zend_test/tests/zpp}/str_or_obj_zpp.phpt (100%) diff --git a/Zend/tests/iterable_or_null.phpt b/ext/zend_test/tests/zpp/iterable_or_null.phpt similarity index 100% rename from Zend/tests/iterable_or_null.phpt rename to ext/zend_test/tests/zpp/iterable_or_null.phpt diff --git a/Zend/tests/number_or_str_zpp.phpt b/ext/zend_test/tests/zpp/number_or_str_zpp.phpt similarity index 100% rename from Zend/tests/number_or_str_zpp.phpt rename to ext/zend_test/tests/zpp/number_or_str_zpp.phpt diff --git a/Zend/tests/str_or_obj_of_class_zpp.phpt b/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt similarity index 100% rename from Zend/tests/str_or_obj_of_class_zpp.phpt rename to ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt diff --git a/Zend/tests/str_or_obj_zpp.phpt b/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt similarity index 100% rename from Zend/tests/str_or_obj_zpp.phpt rename to ext/zend_test/tests/zpp/str_or_obj_zpp.phpt From 5f27f03e9509252c174d46eb0efda5c795e54783 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 22:43:49 +0100 Subject: [PATCH 02/23] zend_test: group ZPP test functions together --- ext/zend_test/test.c | 142 ++++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 70 deletions(-) diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index a880c09fc1ff..68ba08e7b266 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -225,6 +225,7 @@ static ZEND_FUNCTION(zend_delref) RETURN_NULL(); } +/* BEGIN ZPP test functions */ /* Tests Z_PARAM_OBJ_OR_STR */ static ZEND_FUNCTION(zend_string_or_object) { @@ -278,41 +279,6 @@ static ZEND_FUNCTION(zend_string_or_stdclass) } } -static ZEND_FUNCTION(zend_test_compile_string) -{ - zend_string *source_string = NULL; - zend_string *filename = NULL; - zend_long position = ZEND_COMPILE_POSITION_AT_OPEN_TAG; - - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(source_string) - Z_PARAM_PATH_STR(filename) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); - - zend_op_array *op_array = NULL; - - op_array = compile_string(source_string, ZSTR_VAL(filename), position); - - if (op_array) { - zval retval; - - zend_try { - ZVAL_UNDEF(&retval); - zend_execute(op_array, &retval); - } zend_catch { - destroy_op_array(op_array); - efree_size(op_array, sizeof(zend_op_array)); - zend_bailout(); - } zend_end_try(); - - destroy_op_array(op_array); - efree_size(op_array, sizeof(zend_op_array)); - } - - return; -} - /* Tests Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL */ static ZEND_FUNCTION(zend_string_or_stdclass_or_null) { @@ -376,6 +342,77 @@ static ZEND_FUNCTION(zend_number_or_string_or_null) } } +/* TESTS Z_PARAM_ITERABLE and Z_PARAM_ITERABLE_OR_NULL */ +static ZEND_FUNCTION(zend_iterable) +{ + zval *arg1, *arg2; + + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ITERABLE(arg1) + Z_PARAM_OPTIONAL + Z_PARAM_ITERABLE_OR_NULL(arg2) + ZEND_PARSE_PARAMETERS_END(); +} + +static ZEND_FUNCTION(zend_iterable_legacy) +{ + zval *arg1, *arg2; + + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ITERABLE(arg1) + Z_PARAM_OPTIONAL + Z_PARAM_ITERABLE_OR_NULL(arg2) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_COPY(arg1); +} + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_iterable_legacy, 0, 1, IS_ITERABLE, 0) + ZEND_ARG_TYPE_INFO(0, arg1, IS_ITERABLE, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arg2, IS_ITERABLE, 1, "null") +ZEND_END_ARG_INFO() + +static const zend_function_entry ext_function_legacy[] = { + ZEND_FE(zend_iterable_legacy, arginfo_zend_iterable_legacy) + ZEND_FE_END +}; +/* END ZPP test functions */ + +static ZEND_FUNCTION(zend_test_compile_string) +{ + zend_string *source_string = NULL; + zend_string *filename = NULL; + zend_long position = ZEND_COMPILE_POSITION_AT_OPEN_TAG; + + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(source_string) + Z_PARAM_PATH_STR(filename) + Z_PARAM_LONG(position) + ZEND_PARSE_PARAMETERS_END(); + + zend_op_array *op_array = NULL; + + op_array = compile_string(source_string, ZSTR_VAL(filename), position); + + if (op_array) { + zval retval; + + zend_try { + ZVAL_UNDEF(&retval); + zend_execute(op_array, &retval); + } zend_catch { + destroy_op_array(op_array); + efree_size(op_array, sizeof(zend_op_array)); + zend_bailout(); + } zend_end_try(); + + destroy_op_array(op_array); + efree_size(op_array, sizeof(zend_op_array)); + } + + return; +} + static ZEND_FUNCTION(zend_weakmap_attach) { zval *value; @@ -435,41 +472,6 @@ static ZEND_FUNCTION(zend_test_override_libxml_global_state) } #endif -/* TESTS Z_PARAM_ITERABLE and Z_PARAM_ITERABLE_OR_NULL */ -static ZEND_FUNCTION(zend_iterable) -{ - zval *arg1, *arg2; - - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ITERABLE(arg1) - Z_PARAM_OPTIONAL - Z_PARAM_ITERABLE_OR_NULL(arg2) - ZEND_PARSE_PARAMETERS_END(); -} - -static ZEND_FUNCTION(zend_iterable_legacy) -{ - zval *arg1, *arg2; - - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ITERABLE(arg1) - Z_PARAM_OPTIONAL - Z_PARAM_ITERABLE_OR_NULL(arg2) - ZEND_PARSE_PARAMETERS_END(); - - RETURN_COPY(arg1); -} - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_iterable_legacy, 0, 1, IS_ITERABLE, 0) - ZEND_ARG_TYPE_INFO(0, arg1, IS_ITERABLE, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arg2, IS_ITERABLE, 1, "null") -ZEND_END_ARG_INFO() - -static const zend_function_entry ext_function_legacy[] = { - ZEND_FE(zend_iterable_legacy, arginfo_zend_iterable_legacy) - ZEND_FE_END -}; - /* Call a method on a class or object using zend_call_method() */ static ZEND_FUNCTION(zend_call_method) { From 5eeaab8871ffc52bb16387e21d48c83297d3ca33 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:34:55 +0100 Subject: [PATCH 03/23] zend_test: extract types generation --- ...lass-string_zpp_specifier_strict_mode.phpt | 19 +----------------- .../class-string_zpp_specifier_weak_mode.phpt | 19 +----------------- ext/zend_test/tests/zpp/types.inc | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+), 36 deletions(-) create mode 100644 ext/zend_test/tests/zpp/types.inc diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt index a72d504a2db3..b389fa55dcf7 100644 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt +++ b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt @@ -7,24 +7,7 @@ zend_test declare(strict_types=1); -class S { - public function __toString(): string { - return 'S class'; - } -} - -$types = [ - null, - false, - true, - 42, - 73.5, - 'string', - [], - new stdClass(), - new S(), - STDOUT, -]; +$types = require 'types.inc'; foreach ($types as $type) { /* Use zend_object_init_with_constructor() function as it used Z_PARAM_CLASS */ diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt index 2110ecc4a0e4..e25baffdeda4 100644 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt +++ b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt @@ -5,24 +5,7 @@ zend_test --FILE-- Date: Wed, 12 Aug 2026 15:14:59 +0100 Subject: [PATCH 04/23] zend_test: add output about checked types --- ...lass-string_zpp_specifier_strict_mode.phpt | 13 +++++++++++- .../class-string_zpp_specifier_weak_mode.phpt | 16 +++++++++++++-- ext/zend_test/tests/zpp/types.inc | 20 +++++++++---------- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt index b389fa55dcf7..ff9bbd6f841d 100644 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt +++ b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt @@ -9,7 +9,8 @@ declare(strict_types=1); $types = require 'types.inc'; -foreach ($types as $type) { +foreach ($types as $name => $type) { + echo "Using $name:\n"; /* Use zend_object_init_with_constructor() function as it used Z_PARAM_CLASS */ try { var_dump(zend_object_init_with_constructor($type)); @@ -20,13 +21,23 @@ foreach ($types as $type) { ?> --EXPECT-- +Using null: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, null given +Using false: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, false given +Using true: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, true given +Using 42: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, int given +Using 73.5: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, float given +Using 'string': TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, string given +Using []: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, array given +Using new stdClass(): TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, stdClass given +Using new S(): TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, S given +Using STDOUT: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, resource given diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt index e25baffdeda4..bae06cedb2cb 100644 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt +++ b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt @@ -7,7 +7,8 @@ zend_test $types = require 'types.inc'; -foreach ($types as $type) { +foreach ($types as $name => $type) { + echo "Using $name:\n"; /* Use zend_object_init_with_constructor() function as it used Z_PARAM_CLASS */ try { var_dump(zend_object_init_with_constructor($type)); @@ -18,14 +19,25 @@ foreach ($types as $type) { ?> --EXPECTF-- +Using null: + Deprecated: zend_object_init_with_constructor(): Passing null to parameter #1 ($class) of type string is deprecated in %s on line %d TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, given +Using false: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, given +Using true: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 1 given +Using 42: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 42 given +Using 73.5: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 73.5 given +Using 'string': TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, string given +Using []: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, array given +Using new stdClass(): TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, stdClass given +Using new S(): TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, S class given -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, resource given +Using STDOUT: +TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, resource given \ No newline at end of file diff --git a/ext/zend_test/tests/zpp/types.inc b/ext/zend_test/tests/zpp/types.inc index e3918a8d2e20..15dec1874584 100644 --- a/ext/zend_test/tests/zpp/types.inc +++ b/ext/zend_test/tests/zpp/types.inc @@ -7,14 +7,14 @@ class S { } return [ - null, - false, - true, - 42, - 73.5, - 'string', - [], - new stdClass(), - new S(), - STDOUT, + 'null' => null, + 'false' => false, + 'true' => true, + '42' => 42, + '73.5' => 73.5, + "'string'" => 'string', + '[]' => [], + 'new stdClass()' => new stdClass(), + 'new S()' => new S(), + 'STDOUT' => STDOUT, ]; From b02f6b448a09503d42319898d0300d4cfef1c465 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:40:15 +0100 Subject: [PATCH 05/23] zend_test: use generic types file for other ZPP tests --- .../tests/zpp/number_or_str_zpp.phpt | 95 ++++++++----------- .../tests/zpp/str_or_obj_of_class_zpp.phpt | 93 ++++++++---------- ext/zend_test/tests/zpp/str_or_obj_zpp.phpt | 74 ++++++++------- 3 files changed, 121 insertions(+), 141 deletions(-) diff --git a/ext/zend_test/tests/zpp/number_or_str_zpp.phpt b/ext/zend_test/tests/zpp/number_or_str_zpp.phpt index 6ee47ec6f63d..8a8aaaaf542a 100644 --- a/ext/zend_test/tests/zpp/number_or_str_zpp.phpt +++ b/ext/zend_test/tests/zpp/number_or_str_zpp.phpt @@ -5,70 +5,53 @@ zend_test --FILE-- getMessage() . "\n"; -} -try { - zend_number_or_string(new Foo()); -} catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; -} - -var_dump(zend_number_or_string_or_null("string")); -var_dump(zend_number_or_string_or_null(1)); -var_dump(zend_number_or_string_or_null(5.5)); -var_dump(zend_number_or_string_or_null(null)); -var_dump(zend_number_or_string_or_null(false)); -var_dump(zend_number_or_string_or_null(true)); -var_dump(zend_number_or_string_or_null(new ToString())); - -try { - zend_number_or_string_or_null([]); -} catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; -} -try { - zend_number_or_string_or_null(new Foo()); -} catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; +foreach ($types as $name => $type) { + echo "Using $name:\n"; + try { + var_dump(zend_number_or_string($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_string_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } } ?> --EXPECTF-- -string(6) "string" -int(1) -float(5.5) +Using null: Deprecated: zend_number_or_string(): Passing null to parameter #1 ($param) of type string|int|float is deprecated in %s on line %d int(0) -int(0) -int(1) -string(8) "ToString" -zend_string_or_object(): Argument #1 ($param) must be of type object|string, array given -zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, Foo given -string(6) "string" -int(1) -float(5.5) NULL +Using false: int(0) +int(0) +Using true: +int(1) int(1) -string(8) "ToString" -zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, array given -zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, Foo given +Using 42: +int(42) +int(42) +Using 73.5: +float(73.5) +float(73.5) +Using 'string': +string(6) "string" +string(6) "string" +Using []: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, array given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, array given +Using new stdClass(): +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, stdClass given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, stdClass given +Using new S(): +string(7) "S class" +string(7) "S class" +Using STDOUT: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, resource given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, resource given diff --git a/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt b/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt index dec9bee69d5c..c9cd33d4a548 100644 --- a/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt +++ b/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt @@ -5,66 +5,55 @@ zend_test --FILE-- getMessage() . "\n"; -} - -try { - zend_string_or_stdclass(new Foo()); -} catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; -} - -var_dump(zend_string_or_stdclass_or_null("string")); -var_dump(zend_string_or_stdclass_or_null(1)); -var_dump(zend_string_or_stdclass_or_null(null)); -var_dump(zend_string_or_stdclass_or_null(new stdClass())); -var_dump(zend_string_or_stdclass_or_null(new ToString())); - -try { - zend_string_or_stdclass_or_null([]); -} catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; -} - -try { - zend_string_or_stdclass_or_null(new Foo()); -} catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; +$types = require 'types.inc'; + +foreach ($types as $name => $type) { + echo "Using $name:\n"; + try { + var_dump(zend_string_or_stdclass($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_string_or_stdclass_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } } ?> --EXPECTF-- -string(6) "string" -string(1) "1" +Using null: Deprecated: zend_string_or_stdclass(): Passing null to parameter #1 ($param) of type string is deprecated in %s on line %d string(0) "" +NULL +Using false: +string(0) "" +string(0) "" +Using true: +string(1) "1" +string(1) "1" +Using 42: +string(2) "42" +string(2) "42" +Using 73.5: +string(4) "73.5" +string(4) "73.5" +Using 'string': +string(6) "string" +string(6) "string" +Using []: +TypeError: zend_string_or_stdclass(): Argument #1 ($param) must be of type stdClass|string, array given +TypeError: zend_string_or_stdclass_or_null(): Argument #1 ($param) must be of type stdClass|string|null, array given +Using new stdClass(): object(stdClass)#1 (0) { } -string(8) "ToString" -zend_string_or_stdclass(): Argument #1 ($param) must be of type stdClass|string, array given -zend_string_or_stdclass(): Argument #1 ($param) must be of type stdClass|string, Foo given -string(6) "string" -string(1) "1" -NULL object(stdClass)#1 (0) { } -string(8) "ToString" -zend_string_or_stdclass_or_null(): Argument #1 ($param) must be of type stdClass|string|null, array given -zend_string_or_stdclass_or_null(): Argument #1 ($param) must be of type stdClass|string|null, Foo given +Using new S(): +string(7) "S class" +string(7) "S class" +Using STDOUT: +TypeError: zend_string_or_stdclass(): Argument #1 ($param) must be of type stdClass|string, resource given +TypeError: zend_string_or_stdclass_or_null(): Argument #1 ($param) must be of type stdClass|string|null, resource given diff --git a/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt b/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt index 3c71bde5fd3a..b8512a698fc0 100644 --- a/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt +++ b/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt @@ -5,49 +5,57 @@ zend_test --FILE-- getMessage() . "\n"; -} - -var_dump(zend_string_or_object_or_null("string")); -var_dump(zend_string_or_object_or_null(1)); -var_dump(zend_string_or_object_or_null(null)); -var_dump(zend_string_or_object_or_null(new stdClass())); -var_dump(zend_string_or_object_or_null(new Foo())); - -try { - zend_string_or_object_or_null([]); -} catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; +foreach ($types as $name => $type) { + echo "Using $name:\n"; + try { + var_dump(zend_string_or_object($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_string_or_object_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } } ?> --EXPECTF-- -string(6) "string" -string(1) "1" +Using null: Deprecated: zend_string_or_object(): Passing null to parameter #1 ($param) of type object|string is deprecated in %s on line %d string(0) "" +NULL +Using false: +string(0) "" +string(0) "" +Using true: +string(1) "1" +string(1) "1" +Using 42: +string(2) "42" +string(2) "42" +Using 73.5: +string(4) "73.5" +string(4) "73.5" +Using 'string': +string(6) "string" +string(6) "string" +Using []: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, array given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, array given +Using new stdClass(): object(stdClass)#1 (0) { } -object(Foo)#1 (0) { +object(stdClass)#1 (0) { } -zend_string_or_object(): Argument #1 ($param) must be of type object|string, array given -string(6) "string" -string(1) "1" -NULL -object(stdClass)#2 (0) { +Using new S(): +object(S)#2 (0) { } -object(Foo)#2 (0) { +object(S)#2 (0) { } -zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, array given +Using STDOUT: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, resource given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, resource given From 896544a88e963a4d5afdb6ddc8a39cf378c321ae Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:43:16 +0100 Subject: [PATCH 06/23] zend_test: add numeric strings --- .../tests/zpp/class-string_zpp_specifier_strict_mode.phpt | 4 ++++ .../tests/zpp/class-string_zpp_specifier_weak_mode.phpt | 6 +++++- ext/zend_test/tests/zpp/number_or_str_zpp.phpt | 6 ++++++ ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt | 6 ++++++ ext/zend_test/tests/zpp/str_or_obj_zpp.phpt | 6 ++++++ ext/zend_test/tests/zpp/types.inc | 2 ++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt index ff9bbd6f841d..84c41ed399c8 100644 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt +++ b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt @@ -33,6 +33,10 @@ Using 73.5: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, float given Using 'string': TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, string given +Using '15': +TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 15 given +Using '56.7': +TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 56.7 given Using []: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, array given Using new stdClass(): diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt index bae06cedb2cb..f76003e15562 100644 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt +++ b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt @@ -33,6 +33,10 @@ Using 73.5: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 73.5 given Using 'string': TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, string given +Using '15': +TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 15 given +Using '56.7': +TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 56.7 given Using []: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, array given Using new stdClass(): @@ -40,4 +44,4 @@ TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of Using new S(): TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, S class given Using STDOUT: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, resource given \ No newline at end of file +TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, resource given diff --git a/ext/zend_test/tests/zpp/number_or_str_zpp.phpt b/ext/zend_test/tests/zpp/number_or_str_zpp.phpt index 8a8aaaaf542a..cc4f21934ba6 100644 --- a/ext/zend_test/tests/zpp/number_or_str_zpp.phpt +++ b/ext/zend_test/tests/zpp/number_or_str_zpp.phpt @@ -43,6 +43,12 @@ float(73.5) Using 'string': string(6) "string" string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" Using []: TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, array given TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, array given diff --git a/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt b/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt index c9cd33d4a548..34232dd10e2d 100644 --- a/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt +++ b/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt @@ -43,6 +43,12 @@ string(4) "73.5" Using 'string': string(6) "string" string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" Using []: TypeError: zend_string_or_stdclass(): Argument #1 ($param) must be of type stdClass|string, array given TypeError: zend_string_or_stdclass_or_null(): Argument #1 ($param) must be of type stdClass|string|null, array given diff --git a/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt b/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt index b8512a698fc0..5e0a6b6e1ada 100644 --- a/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt +++ b/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt @@ -43,6 +43,12 @@ string(4) "73.5" Using 'string': string(6) "string" string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" Using []: TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, array given TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, array given diff --git a/ext/zend_test/tests/zpp/types.inc b/ext/zend_test/tests/zpp/types.inc index 15dec1874584..2365e40ac216 100644 --- a/ext/zend_test/tests/zpp/types.inc +++ b/ext/zend_test/tests/zpp/types.inc @@ -13,6 +13,8 @@ return [ '42' => 42, '73.5' => 73.5, "'string'" => 'string', + "'15'" => '15', + "'56.7'" => '56.7', '[]' => [], 'new stdClass()' => new stdClass(), 'new S()' => new S(), From bd87041098b5b6d288fae3d10a38fac1b1dc9b74 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 22:56:39 +0100 Subject: [PATCH 07/23] zend_test: add bool ZPP specifier test --- ext/zend_test/test.c | 52 ++++++ ext/zend_test/test.stub.php | 5 + ext/zend_test/test_arginfo.h | 22 ++- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 30 ++- .../zpp/bool_zpp_specifier_strict_mode.phpt | 166 +++++++++++++++++ .../zpp/bool_zpp_specifier_weak_mode.phpt | 172 ++++++++++++++++++ 7 files changed, 443 insertions(+), 12 deletions(-) create mode 100644 ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 68ba08e7b266..6b49a7a7d5d5 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -226,6 +226,58 @@ static ZEND_FUNCTION(zend_delref) } /* BEGIN ZPP test functions */ +static ZEND_FUNCTION(zend_bool) +{ + bool v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_BOOL(v); +} + +static ZEND_FUNCTION(zend_bool_or_null) +{ + bool v; + bool is_null; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL_OR_NULL(v, is_null) + ZEND_PARSE_PARAMETERS_END(); + + if (is_null) { + RETURN_NULL(); + } + RETURN_BOOL(v); +} + +static ZEND_FUNCTION(zend_bool_slow_zpp) +{ + bool v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &v) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_BOOL(v); +} + +static ZEND_FUNCTION(zend_bool_or_null_slow_zpp) +{ + bool v; + bool is_null; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b!", &v, &is_null) == FAILURE) { + RETURN_THROWS(); + } + + if (is_null) { + RETURN_NULL(); + } + RETURN_BOOL(v); +} + /* Tests Z_PARAM_OBJ_OR_STR */ static ZEND_FUNCTION(zend_string_or_object) { diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 7c96ea176a88..81b86b631344 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -299,6 +299,11 @@ function zend_leak_bytes(int $bytes = 3): void {} function zend_delref(mixed $variable): void {} + function zend_bool(bool $param): bool {} + function zend_bool_or_null(bool|null $param): bool|null {} + function zend_bool_slow_zpp(bool $param): bool {} + function zend_bool_or_null_slow_zpp(bool|null $param): bool|null {} + function zend_string_or_object(object|string $param): object|string {} function zend_string_or_object_or_null(object|string|null $param): object|string|null {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index b2e342382db7..96357a1146cd 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a221a3df3815679d61fd546ba120fd3a374fe71f + * Stub hash: 2a342f9a9b5b3652677b22163ec95d14e2b11c1e * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -53,6 +53,18 @@ ZEND_END_ARG_INFO() #define arginfo_zend_delref arginfo_zend_leak_variable +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_bool, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, param, _IS_BOOL, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_bool_or_null, 0, 1, _IS_BOOL, 1) + ZEND_ARG_TYPE_INFO(0, param, _IS_BOOL, 1) +ZEND_END_ARG_INFO() + +#define arginfo_zend_bool_slow_zpp arginfo_zend_bool + +#define arginfo_zend_bool_or_null_slow_zpp arginfo_zend_bool_or_null + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_string_or_object, 0, 1, MAY_BE_OBJECT|MAY_BE_STRING) ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() @@ -313,6 +325,10 @@ static ZEND_FUNCTION(zend_terminate_string); static ZEND_FUNCTION(zend_leak_variable); static ZEND_FUNCTION(zend_leak_bytes); static ZEND_FUNCTION(zend_delref); +static ZEND_FUNCTION(zend_bool); +static ZEND_FUNCTION(zend_bool_or_null); +static ZEND_FUNCTION(zend_bool_slow_zpp); +static ZEND_FUNCTION(zend_bool_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_string_or_stdclass); @@ -449,6 +465,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_leak_variable, arginfo_zend_leak_variable) ZEND_FE(zend_leak_bytes, arginfo_zend_leak_bytes) ZEND_FE(zend_delref, arginfo_zend_delref) + ZEND_FE(zend_bool, arginfo_zend_bool) + ZEND_FE(zend_bool_or_null, arginfo_zend_bool_or_null) + ZEND_FE(zend_bool_slow_zpp, arginfo_zend_bool_slow_zpp) + ZEND_FE(zend_bool_or_null_slow_zpp, arginfo_zend_bool_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index ea6a2c94fbdf..4a5f4bd1e0a2 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a221a3df3815679d61fd546ba120fd3a374fe71f */ + * Stub hash: 2a342f9a9b5b3652677b22163ec95d14e2b11c1e */ -#ifndef ZEND_TEST_DECL_a221a3df3815679d61fd546ba120fd3a374fe71f_H -#define ZEND_TEST_DECL_a221a3df3815679d61fd546ba120fd3a374fe71f_H +#ifndef ZEND_TEST_DECL_2a342f9a9b5b3652677b22163ec95d14e2b11c1e_H +#define ZEND_TEST_DECL_2a342f9a9b5b3652677b22163ec95d14e2b11c1e_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_a221a3df3815679d61fd546ba120fd3a374fe71f_H */ +#endif /* ZEND_TEST_DECL_2a342f9a9b5b3652677b22163ec95d14e2b11c1e_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index 05014c80fd5d..b032621134c0 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a221a3df3815679d61fd546ba120fd3a374fe71f + * Stub hash: 2a342f9a9b5b3652677b22163ec95d14e2b11c1e * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -49,19 +49,27 @@ ZEND_END_ARG_INFO() #define arginfo_zend_delref arginfo_zend_leak_variable -ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_string_or_object, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_bool, 0, 0, 1) ZEND_ARG_INFO(0, param) ZEND_END_ARG_INFO() -#define arginfo_zend_string_or_object_or_null arginfo_zend_string_or_object +#define arginfo_zend_bool_or_null arginfo_zend_bool -#define arginfo_zend_string_or_stdclass arginfo_zend_string_or_object +#define arginfo_zend_bool_slow_zpp arginfo_zend_bool -#define arginfo_zend_string_or_stdclass_or_null arginfo_zend_string_or_object +#define arginfo_zend_bool_or_null_slow_zpp arginfo_zend_bool -#define arginfo_zend_number_or_string arginfo_zend_string_or_object +#define arginfo_zend_string_or_object arginfo_zend_bool -#define arginfo_zend_number_or_string_or_null arginfo_zend_string_or_object +#define arginfo_zend_string_or_object_or_null arginfo_zend_bool + +#define arginfo_zend_string_or_stdclass arginfo_zend_bool + +#define arginfo_zend_string_or_stdclass_or_null arginfo_zend_bool + +#define arginfo_zend_number_or_string arginfo_zend_bool + +#define arginfo_zend_number_or_string_or_null arginfo_zend_bool ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_iterable, 0, 0, 1) ZEND_ARG_INFO(0, arg1) @@ -276,6 +284,10 @@ static ZEND_FUNCTION(zend_terminate_string); static ZEND_FUNCTION(zend_leak_variable); static ZEND_FUNCTION(zend_leak_bytes); static ZEND_FUNCTION(zend_delref); +static ZEND_FUNCTION(zend_bool); +static ZEND_FUNCTION(zend_bool_or_null); +static ZEND_FUNCTION(zend_bool_slow_zpp); +static ZEND_FUNCTION(zend_bool_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_string_or_stdclass); @@ -384,6 +396,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_leak_variable, arginfo_zend_leak_variable) ZEND_FE(zend_leak_bytes, arginfo_zend_leak_bytes) ZEND_FE(zend_delref, arginfo_zend_delref) + ZEND_FE(zend_bool, arginfo_zend_bool) + ZEND_FE(zend_bool_or_null, arginfo_zend_bool_or_null) + ZEND_FE(zend_bool_slow_zpp, arginfo_zend_bool_slow_zpp) + ZEND_FE(zend_bool_or_null_slow_zpp, arginfo_zend_bool_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) diff --git a/ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..8ad491a86d95 --- /dev/null +++ b/ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt @@ -0,0 +1,166 @@ +--TEST-- +Test bool ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_bool($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_bool($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, null given +NULL +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, null given +NULL +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, null given +NULL +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, null given +NULL +Using false: +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +Using true: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using 42: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, int given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, int given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, int given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, int given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, int given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, int given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, int given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, int given +Using 73.5: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, float given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, float given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, float given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, float given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, float given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, float given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, float given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, float given +Using 'string': +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +Using '15': +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +Using '56.7': +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +Using []: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, array given +Using new stdClass(): +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, stdClass given +Using new S(): +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, S given +Using STDOUT: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, resource given diff --git a/ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..0c324ef83a81 --- /dev/null +++ b/ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt @@ -0,0 +1,172 @@ +--TEST-- +Test bool ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_bool($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_bool($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_bool(): Passing null to parameter #1 ($param) of type bool is deprecated in %s on line %d +bool(false) +NULL + +Deprecated: zend_bool_slow_zpp(): Passing null to parameter #1 ($param) of type bool is deprecated in %s on line %d +bool(false) +NULL + +Deprecated: zend_bool(): Passing null to parameter #1 ($param) of type bool is deprecated in %s on line %d +bool(false) +NULL + +Deprecated: zend_bool_slow_zpp(): Passing null to parameter #1 ($param) of type bool is deprecated in %s on line %d +bool(false) +NULL +Using false: +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +Using true: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using 42: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using 73.5: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using 'string': +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using '15': +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using '56.7': +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using []: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, array given +Using new stdClass(): +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, stdClass given +Using new S(): +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, S given +Using STDOUT: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, resource given From 7701638fb14171d0c3fcc9c5ab2bf95fd70df31c Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:01:55 +0100 Subject: [PATCH 08/23] zend_test: add int ZPP specifier test --- ext/zend_test/test.c | 52 +++++ ext/zend_test/test.stub.php | 5 + ext/zend_test/test_arginfo.h | 22 +- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 18 +- .../zpp/int_zpp_specifier_strict_mode.phpt | 166 ++++++++++++++ .../zpp/int_zpp_specifier_weak_mode.phpt | 204 ++++++++++++++++++ 7 files changed, 469 insertions(+), 6 deletions(-) create mode 100644 ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 6b49a7a7d5d5..ed85547ad6f6 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -278,6 +278,58 @@ static ZEND_FUNCTION(zend_bool_or_null_slow_zpp) RETURN_BOOL(v); } +static ZEND_FUNCTION(zend_int) +{ + zend_long v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_LONG(v); +} + +static ZEND_FUNCTION(zend_int_or_null) +{ + zend_long v; + bool is_null; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG_OR_NULL(v, is_null) + ZEND_PARSE_PARAMETERS_END(); + + if (is_null) { + RETURN_NULL(); + } + RETURN_LONG(v); +} + +static ZEND_FUNCTION(zend_int_slow_zpp) +{ + zend_long v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &v) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_LONG(v); +} + +static ZEND_FUNCTION(zend_int_or_null_slow_zpp) +{ + zend_long v; + bool is_null; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l!", &v, &is_null) == FAILURE) { + RETURN_THROWS(); + } + + if (is_null) { + RETURN_NULL(); + } + RETURN_LONG(v); +} + /* Tests Z_PARAM_OBJ_OR_STR */ static ZEND_FUNCTION(zend_string_or_object) { diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 81b86b631344..ef9b5c97d2ba 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -304,6 +304,11 @@ function zend_bool_or_null(bool|null $param): bool|null {} function zend_bool_slow_zpp(bool $param): bool {} function zend_bool_or_null_slow_zpp(bool|null $param): bool|null {} + function zend_int(int $param): int {} + function zend_int_or_null(int|null $param): int|null {} + function zend_int_slow_zpp(int $param): int {} + function zend_int_or_null_slow_zpp(int|null $param): int|null {} + function zend_string_or_object(object|string $param): object|string {} function zend_string_or_object_or_null(object|string|null $param): object|string|null {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 96357a1146cd..313234b8c5cd 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 2a342f9a9b5b3652677b22163ec95d14e2b11c1e + * Stub hash: 7d67365d49f611ad817698274d4222732ef68bf1 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -65,6 +65,18 @@ ZEND_END_ARG_INFO() #define arginfo_zend_bool_or_null_slow_zpp arginfo_zend_bool_or_null +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_int, 0, 1, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, param, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_int_or_null, 0, 1, IS_LONG, 1) + ZEND_ARG_TYPE_INFO(0, param, IS_LONG, 1) +ZEND_END_ARG_INFO() + +#define arginfo_zend_int_slow_zpp arginfo_zend_int + +#define arginfo_zend_int_or_null_slow_zpp arginfo_zend_int_or_null + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_string_or_object, 0, 1, MAY_BE_OBJECT|MAY_BE_STRING) ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() @@ -329,6 +341,10 @@ static ZEND_FUNCTION(zend_bool); static ZEND_FUNCTION(zend_bool_or_null); static ZEND_FUNCTION(zend_bool_slow_zpp); static ZEND_FUNCTION(zend_bool_or_null_slow_zpp); +static ZEND_FUNCTION(zend_int); +static ZEND_FUNCTION(zend_int_or_null); +static ZEND_FUNCTION(zend_int_slow_zpp); +static ZEND_FUNCTION(zend_int_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_string_or_stdclass); @@ -469,6 +485,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_bool_or_null, arginfo_zend_bool_or_null) ZEND_FE(zend_bool_slow_zpp, arginfo_zend_bool_slow_zpp) ZEND_FE(zend_bool_or_null_slow_zpp, arginfo_zend_bool_or_null_slow_zpp) + ZEND_FE(zend_int, arginfo_zend_int) + ZEND_FE(zend_int_or_null, arginfo_zend_int_or_null) + ZEND_FE(zend_int_slow_zpp, arginfo_zend_int_slow_zpp) + ZEND_FE(zend_int_or_null_slow_zpp, arginfo_zend_int_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index 4a5f4bd1e0a2..3e5e6ef312fa 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 2a342f9a9b5b3652677b22163ec95d14e2b11c1e */ + * Stub hash: 7d67365d49f611ad817698274d4222732ef68bf1 */ -#ifndef ZEND_TEST_DECL_2a342f9a9b5b3652677b22163ec95d14e2b11c1e_H -#define ZEND_TEST_DECL_2a342f9a9b5b3652677b22163ec95d14e2b11c1e_H +#ifndef ZEND_TEST_DECL_7d67365d49f611ad817698274d4222732ef68bf1_H +#define ZEND_TEST_DECL_7d67365d49f611ad817698274d4222732ef68bf1_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_2a342f9a9b5b3652677b22163ec95d14e2b11c1e_H */ +#endif /* ZEND_TEST_DECL_7d67365d49f611ad817698274d4222732ef68bf1_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index b032621134c0..bd86cc75f80f 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 2a342f9a9b5b3652677b22163ec95d14e2b11c1e + * Stub hash: 7d67365d49f611ad817698274d4222732ef68bf1 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -59,6 +59,14 @@ ZEND_END_ARG_INFO() #define arginfo_zend_bool_or_null_slow_zpp arginfo_zend_bool +#define arginfo_zend_int arginfo_zend_bool + +#define arginfo_zend_int_or_null arginfo_zend_bool + +#define arginfo_zend_int_slow_zpp arginfo_zend_bool + +#define arginfo_zend_int_or_null_slow_zpp arginfo_zend_bool + #define arginfo_zend_string_or_object arginfo_zend_bool #define arginfo_zend_string_or_object_or_null arginfo_zend_bool @@ -288,6 +296,10 @@ static ZEND_FUNCTION(zend_bool); static ZEND_FUNCTION(zend_bool_or_null); static ZEND_FUNCTION(zend_bool_slow_zpp); static ZEND_FUNCTION(zend_bool_or_null_slow_zpp); +static ZEND_FUNCTION(zend_int); +static ZEND_FUNCTION(zend_int_or_null); +static ZEND_FUNCTION(zend_int_slow_zpp); +static ZEND_FUNCTION(zend_int_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_string_or_stdclass); @@ -400,6 +412,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_bool_or_null, arginfo_zend_bool_or_null) ZEND_FE(zend_bool_slow_zpp, arginfo_zend_bool_slow_zpp) ZEND_FE(zend_bool_or_null_slow_zpp, arginfo_zend_bool_or_null_slow_zpp) + ZEND_FE(zend_int, arginfo_zend_int) + ZEND_FE(zend_int_or_null, arginfo_zend_int_or_null) + ZEND_FE(zend_int_slow_zpp, arginfo_zend_int_slow_zpp) + ZEND_FE(zend_int_or_null_slow_zpp, arginfo_zend_int_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) diff --git a/ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..8743d9571a62 --- /dev/null +++ b/ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt @@ -0,0 +1,166 @@ +--TEST-- +Test int ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_int($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_int($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_int(): Argument #1 ($param) must be of type int, null given +NULL +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, null given +NULL +TypeError: zend_int(): Argument #1 ($param) must be of type int, null given +NULL +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, null given +NULL +Using false: +TypeError: zend_int(): Argument #1 ($param) must be of type int, false given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, false given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, false given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, false given +TypeError: zend_int(): Argument #1 ($param) must be of type int, false given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, false given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, false given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, false given +Using true: +TypeError: zend_int(): Argument #1 ($param) must be of type int, true given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, true given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, true given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, true given +TypeError: zend_int(): Argument #1 ($param) must be of type int, true given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, true given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, true given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, true given +Using 42: +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +Using 73.5: +TypeError: zend_int(): Argument #1 ($param) must be of type int, float given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, float given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, float given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, float given +TypeError: zend_int(): Argument #1 ($param) must be of type int, float given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, float given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, float given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, float given +Using 'string': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using '15': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using '56.7': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using []: +TypeError: zend_int(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, array given +Using new stdClass(): +TypeError: zend_int(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, stdClass given +Using new S(): +TypeError: zend_int(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, S given +Using STDOUT: +TypeError: zend_int(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, resource given diff --git a/ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..3117b1493de1 --- /dev/null +++ b/ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt @@ -0,0 +1,204 @@ +--TEST-- +Test int ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_int($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_int($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_int(): Passing null to parameter #1 ($param) of type int is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_int_slow_zpp(): Passing null to parameter #1 ($param) of type int is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_int(): Passing null to parameter #1 ($param) of type int is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_int_slow_zpp(): Passing null to parameter #1 ($param) of type int is deprecated in %s on line %d +int(0) +NULL +Using false: +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +Using true: +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +Using 42: +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +Using 73.5: + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) +Using 'string': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using '15': +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +Using '56.7': + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) +Using []: +TypeError: zend_int(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, array given +Using new stdClass(): +TypeError: zend_int(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, stdClass given +Using new S(): +TypeError: zend_int(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, S given +Using STDOUT: +TypeError: zend_int(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, resource given From 53159b89d640c8c1324b6cf6a117f982958f4664 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:11:33 +0100 Subject: [PATCH 09/23] zend_test: add float ZPP specifier test --- ext/zend_test/test.c | 52 ++++++ ext/zend_test/test.stub.php | 5 + ext/zend_test/test_arginfo.h | 22 ++- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 18 +- .../zpp/float_zpp_specifier_strict_mode.phpt | 166 +++++++++++++++++ .../zpp/float_zpp_specifier_weak_mode.phpt | 172 ++++++++++++++++++ 7 files changed, 437 insertions(+), 6 deletions(-) create mode 100644 ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index ed85547ad6f6..934c64a9286e 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -330,6 +330,58 @@ static ZEND_FUNCTION(zend_int_or_null_slow_zpp) RETURN_LONG(v); } +static ZEND_FUNCTION(zend_float) +{ + double v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_DOUBLE(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_DOUBLE(v); +} + +static ZEND_FUNCTION(zend_float_or_null) +{ + double v; + bool is_null; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_DOUBLE_OR_NULL(v, is_null) + ZEND_PARSE_PARAMETERS_END(); + + if (is_null) { + RETURN_NULL(); + } + RETURN_DOUBLE(v); +} + +static ZEND_FUNCTION(zend_float_slow_zpp) +{ + double v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "d", &v) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_DOUBLE(v); +} + +static ZEND_FUNCTION(zend_float_or_null_slow_zpp) +{ + double v; + bool is_null; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "d!", &v, &is_null) == FAILURE) { + RETURN_THROWS(); + } + + if (is_null) { + RETURN_NULL(); + } + RETURN_DOUBLE(v); +} + /* Tests Z_PARAM_OBJ_OR_STR */ static ZEND_FUNCTION(zend_string_or_object) { diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index ef9b5c97d2ba..5f045e3e959c 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -309,6 +309,11 @@ function zend_int_or_null(int|null $param): int|null {} function zend_int_slow_zpp(int $param): int {} function zend_int_or_null_slow_zpp(int|null $param): int|null {} + function zend_float(float $param): float {} + function zend_float_or_null(float|null $param): float|null {} + function zend_float_slow_zpp(float $param): float {} + function zend_float_or_null_slow_zpp(float|null $param): float|null {} + function zend_string_or_object(object|string $param): object|string {} function zend_string_or_object_or_null(object|string|null $param): object|string|null {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 313234b8c5cd..e4ed762dd46c 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 7d67365d49f611ad817698274d4222732ef68bf1 + * Stub hash: 54a2f7675eceb53a04ca3925765a22537c5410dd * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -77,6 +77,18 @@ ZEND_END_ARG_INFO() #define arginfo_zend_int_or_null_slow_zpp arginfo_zend_int_or_null +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_float, 0, 1, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO(0, param, IS_DOUBLE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_float_or_null, 0, 1, IS_DOUBLE, 1) + ZEND_ARG_TYPE_INFO(0, param, IS_DOUBLE, 1) +ZEND_END_ARG_INFO() + +#define arginfo_zend_float_slow_zpp arginfo_zend_float + +#define arginfo_zend_float_or_null_slow_zpp arginfo_zend_float_or_null + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_string_or_object, 0, 1, MAY_BE_OBJECT|MAY_BE_STRING) ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() @@ -345,6 +357,10 @@ static ZEND_FUNCTION(zend_int); static ZEND_FUNCTION(zend_int_or_null); static ZEND_FUNCTION(zend_int_slow_zpp); static ZEND_FUNCTION(zend_int_or_null_slow_zpp); +static ZEND_FUNCTION(zend_float); +static ZEND_FUNCTION(zend_float_or_null); +static ZEND_FUNCTION(zend_float_slow_zpp); +static ZEND_FUNCTION(zend_float_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_string_or_stdclass); @@ -489,6 +505,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_int_or_null, arginfo_zend_int_or_null) ZEND_FE(zend_int_slow_zpp, arginfo_zend_int_slow_zpp) ZEND_FE(zend_int_or_null_slow_zpp, arginfo_zend_int_or_null_slow_zpp) + ZEND_FE(zend_float, arginfo_zend_float) + ZEND_FE(zend_float_or_null, arginfo_zend_float_or_null) + ZEND_FE(zend_float_slow_zpp, arginfo_zend_float_slow_zpp) + ZEND_FE(zend_float_or_null_slow_zpp, arginfo_zend_float_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index 3e5e6ef312fa..dbae50fc4479 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 7d67365d49f611ad817698274d4222732ef68bf1 */ + * Stub hash: 54a2f7675eceb53a04ca3925765a22537c5410dd */ -#ifndef ZEND_TEST_DECL_7d67365d49f611ad817698274d4222732ef68bf1_H -#define ZEND_TEST_DECL_7d67365d49f611ad817698274d4222732ef68bf1_H +#ifndef ZEND_TEST_DECL_54a2f7675eceb53a04ca3925765a22537c5410dd_H +#define ZEND_TEST_DECL_54a2f7675eceb53a04ca3925765a22537c5410dd_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_7d67365d49f611ad817698274d4222732ef68bf1_H */ +#endif /* ZEND_TEST_DECL_54a2f7675eceb53a04ca3925765a22537c5410dd_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index bd86cc75f80f..63a84c2086ea 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 7d67365d49f611ad817698274d4222732ef68bf1 + * Stub hash: 54a2f7675eceb53a04ca3925765a22537c5410dd * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -67,6 +67,14 @@ ZEND_END_ARG_INFO() #define arginfo_zend_int_or_null_slow_zpp arginfo_zend_bool +#define arginfo_zend_float arginfo_zend_bool + +#define arginfo_zend_float_or_null arginfo_zend_bool + +#define arginfo_zend_float_slow_zpp arginfo_zend_bool + +#define arginfo_zend_float_or_null_slow_zpp arginfo_zend_bool + #define arginfo_zend_string_or_object arginfo_zend_bool #define arginfo_zend_string_or_object_or_null arginfo_zend_bool @@ -300,6 +308,10 @@ static ZEND_FUNCTION(zend_int); static ZEND_FUNCTION(zend_int_or_null); static ZEND_FUNCTION(zend_int_slow_zpp); static ZEND_FUNCTION(zend_int_or_null_slow_zpp); +static ZEND_FUNCTION(zend_float); +static ZEND_FUNCTION(zend_float_or_null); +static ZEND_FUNCTION(zend_float_slow_zpp); +static ZEND_FUNCTION(zend_float_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_string_or_stdclass); @@ -416,6 +428,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_int_or_null, arginfo_zend_int_or_null) ZEND_FE(zend_int_slow_zpp, arginfo_zend_int_slow_zpp) ZEND_FE(zend_int_or_null_slow_zpp, arginfo_zend_int_or_null_slow_zpp) + ZEND_FE(zend_float, arginfo_zend_float) + ZEND_FE(zend_float_or_null, arginfo_zend_float_or_null) + ZEND_FE(zend_float_slow_zpp, arginfo_zend_float_slow_zpp) + ZEND_FE(zend_float_or_null_slow_zpp, arginfo_zend_float_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) diff --git a/ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..aeb8cd6842dd --- /dev/null +++ b/ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt @@ -0,0 +1,166 @@ +--TEST-- +Test float ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_float($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_float($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_float(): Argument #1 ($param) must be of type float, null given +NULL +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, null given +NULL +TypeError: zend_float(): Argument #1 ($param) must be of type float, null given +NULL +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, null given +NULL +Using false: +TypeError: zend_float(): Argument #1 ($param) must be of type float, false given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, false given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, false given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, false given +TypeError: zend_float(): Argument #1 ($param) must be of type float, false given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, false given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, false given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, false given +Using true: +TypeError: zend_float(): Argument #1 ($param) must be of type float, true given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, true given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, true given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, true given +TypeError: zend_float(): Argument #1 ($param) must be of type float, true given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, true given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, true given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, true given +Using 42: +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +Using 73.5: +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +Using 'string': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using '15': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using '56.7': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using []: +TypeError: zend_float(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, array given +Using new stdClass(): +TypeError: zend_float(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, stdClass given +Using new S(): +TypeError: zend_float(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, S given +Using STDOUT: +TypeError: zend_float(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, resource given diff --git a/ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..2c2004d66950 --- /dev/null +++ b/ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt @@ -0,0 +1,172 @@ +--TEST-- +Test float ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_float($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_float($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_float(): Passing null to parameter #1 ($param) of type float is deprecated in %s on line %d +float(0) +NULL + +Deprecated: zend_float_slow_zpp(): Passing null to parameter #1 ($param) of type float is deprecated in %s on line %d +float(0) +NULL + +Deprecated: zend_float(): Passing null to parameter #1 ($param) of type float is deprecated in %s on line %d +float(0) +NULL + +Deprecated: zend_float_slow_zpp(): Passing null to parameter #1 ($param) of type float is deprecated in %s on line %d +float(0) +NULL +Using false: +float(0) +float(0) +float(0) +float(0) +float(0) +float(0) +float(0) +float(0) +Using true: +float(1) +float(1) +float(1) +float(1) +float(1) +float(1) +float(1) +float(1) +Using 42: +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +Using 73.5: +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +Using 'string': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using '15': +float(15) +float(15) +float(15) +float(15) +float(15) +float(15) +float(15) +float(15) +Using '56.7': +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +Using []: +TypeError: zend_float(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, array given +Using new stdClass(): +TypeError: zend_float(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, stdClass given +Using new S(): +TypeError: zend_float(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, S given +Using STDOUT: +TypeError: zend_float(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, resource given From c94217300daa482a80fae31b95ca4be1b7ba26a1 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:25:59 +0100 Subject: [PATCH 10/23] zend_test: add number ZPP specifier test --- ext/zend_test/test.c | 50 +++++ ext/zend_test/test.stub.php | 5 + ext/zend_test/test_arginfo.h | 22 ++- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 18 +- .../zpp/number_zpp_specifier_strict_mode.phpt | 166 +++++++++++++++++ .../zpp/number_zpp_specifier_weak_mode.phpt | 172 ++++++++++++++++++ 7 files changed, 435 insertions(+), 6 deletions(-) create mode 100644 ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 934c64a9286e..d4e3f53e48cc 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -382,6 +382,56 @@ static ZEND_FUNCTION(zend_float_or_null_slow_zpp) RETURN_DOUBLE(v); } +static ZEND_FUNCTION(zend_number) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_NUMBER(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_number_or_null) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_NUMBER_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_number_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "n", &v) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_number_or_null_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "n!", &v) == FAILURE) { + RETURN_THROWS(); + } + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + /* Tests Z_PARAM_OBJ_OR_STR */ static ZEND_FUNCTION(zend_string_or_object) { diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 5f045e3e959c..b313ffc909b4 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -314,6 +314,11 @@ function zend_float_or_null(float|null $param): float|null {} function zend_float_slow_zpp(float $param): float {} function zend_float_or_null_slow_zpp(float|null $param): float|null {} + function zend_number(int|float $param): int|float {} + function zend_number_or_null(int|float|null $param): int|float|null {} + function zend_number_slow_zpp(int|float $param): int|float {} + function zend_number_or_null_slow_zpp(int|float|null $param): int|float|null {} + function zend_string_or_object(object|string $param): object|string {} function zend_string_or_object_or_null(object|string|null $param): object|string|null {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index e4ed762dd46c..70f1937e6930 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 54a2f7675eceb53a04ca3925765a22537c5410dd + * Stub hash: 644affbfdb8223583e0c401fa1243a84ed4636ad * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -89,6 +89,18 @@ ZEND_END_ARG_INFO() #define arginfo_zend_float_or_null_slow_zpp arginfo_zend_float_or_null +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_number, 0, 1, MAY_BE_LONG|MAY_BE_DOUBLE) + ZEND_ARG_TYPE_MASK(0, param, MAY_BE_LONG|MAY_BE_DOUBLE, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_number_or_null, 0, 1, MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_NULL) + ZEND_ARG_TYPE_MASK(0, param, MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_NULL, NULL) +ZEND_END_ARG_INFO() + +#define arginfo_zend_number_slow_zpp arginfo_zend_number + +#define arginfo_zend_number_or_null_slow_zpp arginfo_zend_number_or_null + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_string_or_object, 0, 1, MAY_BE_OBJECT|MAY_BE_STRING) ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() @@ -361,6 +373,10 @@ static ZEND_FUNCTION(zend_float); static ZEND_FUNCTION(zend_float_or_null); static ZEND_FUNCTION(zend_float_slow_zpp); static ZEND_FUNCTION(zend_float_or_null_slow_zpp); +static ZEND_FUNCTION(zend_number); +static ZEND_FUNCTION(zend_number_or_null); +static ZEND_FUNCTION(zend_number_slow_zpp); +static ZEND_FUNCTION(zend_number_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_string_or_stdclass); @@ -509,6 +525,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_float_or_null, arginfo_zend_float_or_null) ZEND_FE(zend_float_slow_zpp, arginfo_zend_float_slow_zpp) ZEND_FE(zend_float_or_null_slow_zpp, arginfo_zend_float_or_null_slow_zpp) + ZEND_FE(zend_number, arginfo_zend_number) + ZEND_FE(zend_number_or_null, arginfo_zend_number_or_null) + ZEND_FE(zend_number_slow_zpp, arginfo_zend_number_slow_zpp) + ZEND_FE(zend_number_or_null_slow_zpp, arginfo_zend_number_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index dbae50fc4479..4c71de5474e5 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 54a2f7675eceb53a04ca3925765a22537c5410dd */ + * Stub hash: 644affbfdb8223583e0c401fa1243a84ed4636ad */ -#ifndef ZEND_TEST_DECL_54a2f7675eceb53a04ca3925765a22537c5410dd_H -#define ZEND_TEST_DECL_54a2f7675eceb53a04ca3925765a22537c5410dd_H +#ifndef ZEND_TEST_DECL_644affbfdb8223583e0c401fa1243a84ed4636ad_H +#define ZEND_TEST_DECL_644affbfdb8223583e0c401fa1243a84ed4636ad_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_54a2f7675eceb53a04ca3925765a22537c5410dd_H */ +#endif /* ZEND_TEST_DECL_644affbfdb8223583e0c401fa1243a84ed4636ad_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index 63a84c2086ea..e40c7b875ed6 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 54a2f7675eceb53a04ca3925765a22537c5410dd + * Stub hash: 644affbfdb8223583e0c401fa1243a84ed4636ad * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -75,6 +75,14 @@ ZEND_END_ARG_INFO() #define arginfo_zend_float_or_null_slow_zpp arginfo_zend_bool +#define arginfo_zend_number arginfo_zend_bool + +#define arginfo_zend_number_or_null arginfo_zend_bool + +#define arginfo_zend_number_slow_zpp arginfo_zend_bool + +#define arginfo_zend_number_or_null_slow_zpp arginfo_zend_bool + #define arginfo_zend_string_or_object arginfo_zend_bool #define arginfo_zend_string_or_object_or_null arginfo_zend_bool @@ -312,6 +320,10 @@ static ZEND_FUNCTION(zend_float); static ZEND_FUNCTION(zend_float_or_null); static ZEND_FUNCTION(zend_float_slow_zpp); static ZEND_FUNCTION(zend_float_or_null_slow_zpp); +static ZEND_FUNCTION(zend_number); +static ZEND_FUNCTION(zend_number_or_null); +static ZEND_FUNCTION(zend_number_slow_zpp); +static ZEND_FUNCTION(zend_number_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_string_or_stdclass); @@ -432,6 +444,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_float_or_null, arginfo_zend_float_or_null) ZEND_FE(zend_float_slow_zpp, arginfo_zend_float_slow_zpp) ZEND_FE(zend_float_or_null_slow_zpp, arginfo_zend_float_or_null_slow_zpp) + ZEND_FE(zend_number, arginfo_zend_number) + ZEND_FE(zend_number_or_null, arginfo_zend_number_or_null) + ZEND_FE(zend_number_slow_zpp, arginfo_zend_number_slow_zpp) + ZEND_FE(zend_number_or_null_slow_zpp, arginfo_zend_number_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) diff --git a/ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..f764158ee943 --- /dev/null +++ b/ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt @@ -0,0 +1,166 @@ +--TEST-- +Test number ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_number($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_number($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, null given +NULL +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, null given +NULL +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, null given +NULL +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, null given +NULL +Using false: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, false given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, false given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, false given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, false given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, false given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, false given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, false given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, false given +Using true: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, true given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, true given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, true given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, true given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, true given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, true given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, true given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, true given +Using 42: +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +Using 73.5: +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +Using 'string': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using '15': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using '56.7': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using []: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, array given +Using new stdClass(): +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, stdClass given +Using new S(): +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, S given +Using STDOUT: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, resource given diff --git a/ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..2ee53cf1f457 --- /dev/null +++ b/ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt @@ -0,0 +1,172 @@ +--TEST-- +Test number ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_number($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_number($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_number(): Passing null to parameter #1 ($param) of type int|float is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_number_slow_zpp(): Passing null to parameter #1 ($param) of type int|float is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_number(): Passing null to parameter #1 ($param) of type int|float is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_number_slow_zpp(): Passing null to parameter #1 ($param) of type int|float is deprecated in %s on line %d +int(0) +NULL +Using false: +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +Using true: +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +Using 42: +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +Using 73.5: +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +Using 'string': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using '15': +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +Using '56.7': +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +Using []: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, array given +Using new stdClass(): +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, stdClass given +Using new S(): +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, S given +Using STDOUT: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, resource given From 0a4065b61609a33cff5748d240c0b005265775ae Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 12 Aug 2026 15:47:57 +0100 Subject: [PATCH 11/23] zend_test: add resource ZPP specifier test --- Zend/Optimizer/zend_func_infos.h | 4 + ext/zend_test/test.c | 50 ++++++ ext/zend_test/test.stub.php | 21 +++ ext/zend_test/test_arginfo.h | 20 ++- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 18 +- .../resource_zpp_specifier_strict_mode.phpt | 166 ++++++++++++++++++ .../zpp/resource_zpp_specifier_weak_mode.phpt | 164 +++++++++++++++++ 8 files changed, 445 insertions(+), 6 deletions(-) create mode 100644 ext/zend_test/tests/zpp/resource_zpp_specifier_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/resource_zpp_specifier_weak_mode.phpt diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 88d012149beb..cfe758db7961 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -615,6 +615,10 @@ static const func_info_t func_infos[] = { F1("serialize", MAY_BE_STRING), F1("xml_error_string", MAY_BE_STRING|MAY_BE_NULL), F1("xml_parser_get_option", MAY_BE_STRING|MAY_BE_LONG|MAY_BE_BOOL), + FN("zend_resource", MAY_BE_RESOURCE), + FN("zend_resource_or_null", MAY_BE_RESOURCE|MAY_BE_NULL), + FN("zend_resource_slow_zpp", MAY_BE_RESOURCE), + FN("zend_resource_or_null_slow_zpp", MAY_BE_RESOURCE|MAY_BE_NULL), FN("zend_test_create_throwing_resource", MAY_BE_RESOURCE), FN("zip_open", MAY_BE_RESOURCE|MAY_BE_LONG|MAY_BE_FALSE), FN("zip_read", MAY_BE_RESOURCE|MAY_BE_FALSE), diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index d4e3f53e48cc..796547ad15ce 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -432,6 +432,56 @@ static ZEND_FUNCTION(zend_number_or_null_slow_zpp) RETURN_COPY(v); } +static ZEND_FUNCTION(zend_resource) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_RESOURCE(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_resource_or_null) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_RESOURCE_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_resource_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &v) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_resource_or_null_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "r!", &v) == FAILURE) { + RETURN_THROWS(); + } + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + /* Tests Z_PARAM_OBJ_OR_STR */ static ZEND_FUNCTION(zend_string_or_object) { diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index b313ffc909b4..c1999518ac25 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -319,6 +319,27 @@ function zend_number_or_null(int|float|null $param): int|float|null {} function zend_number_slow_zpp(int|float $param): int|float {} function zend_number_or_null_slow_zpp(int|float|null $param): int|float|null {} + /** + * @param resource $param + * @return resource + */ + function zend_resource($param) {} + /** + * @param resource|null $param + * @return resource|null + */ + function zend_resource_or_null($param) {} + /** + * @param resource $param + * @return resource + */ + function zend_resource_slow_zpp($param) {} + /** + * @param resource|null $param + * @return resource|null + */ + function zend_resource_or_null_slow_zpp($param) {} + function zend_string_or_object(object|string $param): object|string {} function zend_string_or_object_or_null(object|string|null $param): object|string|null {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 70f1937e6930..787f7222dc55 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 644affbfdb8223583e0c401fa1243a84ed4636ad + * Stub hash: ed33b9480f56ed1261bba98db9fb99b2ee5373b5 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -101,6 +101,16 @@ ZEND_END_ARG_INFO() #define arginfo_zend_number_or_null_slow_zpp arginfo_zend_number_or_null +ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_resource, 0, 0, 1) + ZEND_ARG_INFO(0, param) +ZEND_END_ARG_INFO() + +#define arginfo_zend_resource_or_null arginfo_zend_resource + +#define arginfo_zend_resource_slow_zpp arginfo_zend_resource + +#define arginfo_zend_resource_or_null_slow_zpp arginfo_zend_resource + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_string_or_object, 0, 1, MAY_BE_OBJECT|MAY_BE_STRING) ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() @@ -377,6 +387,10 @@ static ZEND_FUNCTION(zend_number); static ZEND_FUNCTION(zend_number_or_null); static ZEND_FUNCTION(zend_number_slow_zpp); static ZEND_FUNCTION(zend_number_or_null_slow_zpp); +static ZEND_FUNCTION(zend_resource); +static ZEND_FUNCTION(zend_resource_or_null); +static ZEND_FUNCTION(zend_resource_slow_zpp); +static ZEND_FUNCTION(zend_resource_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_string_or_stdclass); @@ -529,6 +543,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_number_or_null, arginfo_zend_number_or_null) ZEND_FE(zend_number_slow_zpp, arginfo_zend_number_slow_zpp) ZEND_FE(zend_number_or_null_slow_zpp, arginfo_zend_number_or_null_slow_zpp) + ZEND_FE(zend_resource, arginfo_zend_resource) + ZEND_FE(zend_resource_or_null, arginfo_zend_resource_or_null) + ZEND_FE(zend_resource_slow_zpp, arginfo_zend_resource_slow_zpp) + ZEND_FE(zend_resource_or_null_slow_zpp, arginfo_zend_resource_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index 4c71de5474e5..a6f18f6e84b3 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 644affbfdb8223583e0c401fa1243a84ed4636ad */ + * Stub hash: ed33b9480f56ed1261bba98db9fb99b2ee5373b5 */ -#ifndef ZEND_TEST_DECL_644affbfdb8223583e0c401fa1243a84ed4636ad_H -#define ZEND_TEST_DECL_644affbfdb8223583e0c401fa1243a84ed4636ad_H +#ifndef ZEND_TEST_DECL_ed33b9480f56ed1261bba98db9fb99b2ee5373b5_H +#define ZEND_TEST_DECL_ed33b9480f56ed1261bba98db9fb99b2ee5373b5_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_644affbfdb8223583e0c401fa1243a84ed4636ad_H */ +#endif /* ZEND_TEST_DECL_ed33b9480f56ed1261bba98db9fb99b2ee5373b5_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index e40c7b875ed6..7eb08c2f936a 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 644affbfdb8223583e0c401fa1243a84ed4636ad + * Stub hash: ed33b9480f56ed1261bba98db9fb99b2ee5373b5 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -83,6 +83,14 @@ ZEND_END_ARG_INFO() #define arginfo_zend_number_or_null_slow_zpp arginfo_zend_bool +#define arginfo_zend_resource arginfo_zend_bool + +#define arginfo_zend_resource_or_null arginfo_zend_bool + +#define arginfo_zend_resource_slow_zpp arginfo_zend_bool + +#define arginfo_zend_resource_or_null_slow_zpp arginfo_zend_bool + #define arginfo_zend_string_or_object arginfo_zend_bool #define arginfo_zend_string_or_object_or_null arginfo_zend_bool @@ -324,6 +332,10 @@ static ZEND_FUNCTION(zend_number); static ZEND_FUNCTION(zend_number_or_null); static ZEND_FUNCTION(zend_number_slow_zpp); static ZEND_FUNCTION(zend_number_or_null_slow_zpp); +static ZEND_FUNCTION(zend_resource); +static ZEND_FUNCTION(zend_resource_or_null); +static ZEND_FUNCTION(zend_resource_slow_zpp); +static ZEND_FUNCTION(zend_resource_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_string_or_stdclass); @@ -448,6 +460,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_number_or_null, arginfo_zend_number_or_null) ZEND_FE(zend_number_slow_zpp, arginfo_zend_number_slow_zpp) ZEND_FE(zend_number_or_null_slow_zpp, arginfo_zend_number_or_null_slow_zpp) + ZEND_FE(zend_resource, arginfo_zend_resource) + ZEND_FE(zend_resource_or_null, arginfo_zend_resource_or_null) + ZEND_FE(zend_resource_slow_zpp, arginfo_zend_resource_slow_zpp) + ZEND_FE(zend_resource_or_null_slow_zpp, arginfo_zend_resource_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) diff --git a/ext/zend_test/tests/zpp/resource_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/resource_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..87787c9a79c9 --- /dev/null +++ b/ext/zend_test/tests/zpp/resource_zpp_specifier_strict_mode.phpt @@ -0,0 +1,166 @@ +--TEST-- +Test resource ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_resource($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_resource($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, null given +NULL +Using false: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, false given +Using true: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, true given +Using 42: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, int given +Using 73.5: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, float given +Using 'string': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using '15': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using '56.7': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using []: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, array given +Using new stdClass(): +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, stdClass given +Using new S(): +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, S given +Using STDOUT: +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) diff --git a/ext/zend_test/tests/zpp/resource_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/resource_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..333a5e433df8 --- /dev/null +++ b/ext/zend_test/tests/zpp/resource_zpp_specifier_weak_mode.phpt @@ -0,0 +1,164 @@ +--TEST-- +Test resource ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_resource($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_resource($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, null given +NULL +Using false: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, false given +Using true: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, true given +Using 42: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, int given +Using 73.5: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, float given +Using 'string': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using '15': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using '56.7': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using []: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, array given +Using new stdClass(): +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, stdClass given +Using new S(): +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, S given +Using STDOUT: +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) From 4b436cfa3e2db50f589dd1f912c56fc0affc6867 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 13 Aug 2026 01:27:10 +0100 Subject: [PATCH 12/23] Add class string and anonymous class string to test fixtures --- .../zpp/bool_zpp_specifier_strict_mode.phpt | 18 ++++++++++++++++++ .../zpp/bool_zpp_specifier_weak_mode.phpt | 18 ++++++++++++++++++ ...class-string_zpp_specifier_strict_mode.phpt | 6 ++++++ .../class-string_zpp_specifier_weak_mode.phpt | 6 ++++++ .../zpp/float_zpp_specifier_strict_mode.phpt | 18 ++++++++++++++++++ .../zpp/float_zpp_specifier_weak_mode.phpt | 18 ++++++++++++++++++ .../zpp/int_zpp_specifier_strict_mode.phpt | 18 ++++++++++++++++++ .../tests/zpp/int_zpp_specifier_weak_mode.phpt | 18 ++++++++++++++++++ ext/zend_test/tests/zpp/number_or_str_zpp.phpt | 6 ++++++ .../zpp/number_zpp_specifier_strict_mode.phpt | 18 ++++++++++++++++++ .../zpp/number_zpp_specifier_weak_mode.phpt | 18 ++++++++++++++++++ .../resource_zpp_specifier_strict_mode.phpt | 18 ++++++++++++++++++ .../zpp/resource_zpp_specifier_weak_mode.phpt | 18 ++++++++++++++++++ .../tests/zpp/str_or_obj_of_class_zpp.phpt | 10 ++++++++-- ext/zend_test/tests/zpp/str_or_obj_zpp.phpt | 14 ++++++++++---- ext/zend_test/tests/zpp/types.inc | 4 ++++ 16 files changed, 220 insertions(+), 6 deletions(-) diff --git a/ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt index 8ad491a86d95..49e056213e3a 100644 --- a/ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt +++ b/ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt @@ -128,6 +128,24 @@ TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +Using 'stdClass': +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +Using anon class name: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given Using []: TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given diff --git a/ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt index 0c324ef83a81..705487f8ba73 100644 --- a/ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt +++ b/ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt @@ -134,6 +134,24 @@ bool(true) bool(true) bool(true) bool(true) +Using 'stdClass': +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using anon class name: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) Using []: TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt index 84c41ed399c8..661b5f0b7523 100644 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt +++ b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt @@ -37,6 +37,12 @@ Using '15': TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 15 given Using '56.7': TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 56.7 given +Using 'stdClass': +object(stdClass)#4 (0) { +} +Using anon class name: +object(class@anonymous)#4 (0) { +} Using []: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, array given Using new stdClass(): diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt index f76003e15562..543c0b781b12 100644 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt +++ b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt @@ -37,6 +37,12 @@ Using '15': TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 15 given Using '56.7': TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 56.7 given +Using 'stdClass': +object(stdClass)#4 (0) { +} +Using anon class name: +object(class@anonymous)#4 (0) { +} Using []: TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, array given Using new stdClass(): diff --git a/ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt index aeb8cd6842dd..2d316737b7cd 100644 --- a/ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt +++ b/ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt @@ -128,6 +128,24 @@ TypeError: zend_float(): Argument #1 ($param) must be of type float, string give TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using 'stdClass': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using anon class name: +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given Using []: TypeError: zend_float(): Argument #1 ($param) must be of type float, array given TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, array given diff --git a/ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt index 2c2004d66950..1520e8055bd3 100644 --- a/ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt +++ b/ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt @@ -134,6 +134,24 @@ float(56.7) float(56.7) float(56.7) float(56.7) +Using 'stdClass': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using anon class name: +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given Using []: TypeError: zend_float(): Argument #1 ($param) must be of type float, array given TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, array given diff --git a/ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt index 8743d9571a62..58585c3656cd 100644 --- a/ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt +++ b/ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt @@ -128,6 +128,24 @@ TypeError: zend_int(): Argument #1 ($param) must be of type int, string given TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using 'stdClass': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using anon class name: +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given Using []: TypeError: zend_int(): Argument #1 ($param) must be of type int, array given TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, array given diff --git a/ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt index 3117b1493de1..9258d6864355 100644 --- a/ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt +++ b/ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt @@ -166,6 +166,24 @@ int(56) Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d int(56) +Using 'stdClass': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using anon class name: +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given Using []: TypeError: zend_int(): Argument #1 ($param) must be of type int, array given TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, array given diff --git a/ext/zend_test/tests/zpp/number_or_str_zpp.phpt b/ext/zend_test/tests/zpp/number_or_str_zpp.phpt index cc4f21934ba6..151c99841073 100644 --- a/ext/zend_test/tests/zpp/number_or_str_zpp.phpt +++ b/ext/zend_test/tests/zpp/number_or_str_zpp.phpt @@ -49,6 +49,12 @@ string(2) "15" Using '56.7': string(4) "56.7" string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" Using []: TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, array given TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, array given diff --git a/ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt index f764158ee943..a91dd9f7b287 100644 --- a/ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt +++ b/ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt @@ -128,6 +128,24 @@ TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using 'stdClass': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using anon class name: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given Using []: TypeError: zend_number(): Argument #1 ($param) must be of type int|float, array given TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, array given diff --git a/ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt index 2ee53cf1f457..2cdc710405ab 100644 --- a/ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt +++ b/ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt @@ -134,6 +134,24 @@ float(56.7) float(56.7) float(56.7) float(56.7) +Using 'stdClass': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using anon class name: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given Using []: TypeError: zend_number(): Argument #1 ($param) must be of type int|float, array given TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, array given diff --git a/ext/zend_test/tests/zpp/resource_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/resource_zpp_specifier_strict_mode.phpt index 87787c9a79c9..3b3da48bdf5f 100644 --- a/ext/zend_test/tests/zpp/resource_zpp_specifier_strict_mode.phpt +++ b/ext/zend_test/tests/zpp/resource_zpp_specifier_strict_mode.phpt @@ -128,6 +128,24 @@ TypeError: zend_resource(): Argument #1 ($param) must be of type resource, strin TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using 'stdClass': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using anon class name: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given Using []: TypeError: zend_resource(): Argument #1 ($param) must be of type resource, array given TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, array given diff --git a/ext/zend_test/tests/zpp/resource_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/resource_zpp_specifier_weak_mode.phpt index 333a5e433df8..04bc27cb01dc 100644 --- a/ext/zend_test/tests/zpp/resource_zpp_specifier_weak_mode.phpt +++ b/ext/zend_test/tests/zpp/resource_zpp_specifier_weak_mode.phpt @@ -126,6 +126,24 @@ TypeError: zend_resource(): Argument #1 ($param) must be of type resource, strin TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using 'stdClass': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using anon class name: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given Using []: TypeError: zend_resource(): Argument #1 ($param) must be of type resource, array given TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, array given diff --git a/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt b/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt index 34232dd10e2d..428bef0baa6a 100644 --- a/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt +++ b/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt @@ -49,13 +49,19 @@ string(2) "15" Using '56.7': string(4) "56.7" string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" Using []: TypeError: zend_string_or_stdclass(): Argument #1 ($param) must be of type stdClass|string, array given TypeError: zend_string_or_stdclass_or_null(): Argument #1 ($param) must be of type stdClass|string|null, array given Using new stdClass(): -object(stdClass)#1 (0) { +object(stdClass)#2 (0) { } -object(stdClass)#1 (0) { +object(stdClass)#2 (0) { } Using new S(): string(7) "S class" diff --git a/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt b/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt index 5e0a6b6e1ada..34376f94983b 100644 --- a/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt +++ b/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt @@ -49,18 +49,24 @@ string(2) "15" Using '56.7': string(4) "56.7" string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" Using []: TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, array given TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, array given Using new stdClass(): -object(stdClass)#1 (0) { +object(stdClass)#2 (0) { } -object(stdClass)#1 (0) { +object(stdClass)#2 (0) { } Using new S(): -object(S)#2 (0) { +object(S)#3 (0) { } -object(S)#2 (0) { +object(S)#3 (0) { } Using STDOUT: TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, resource given diff --git a/ext/zend_test/tests/zpp/types.inc b/ext/zend_test/tests/zpp/types.inc index 2365e40ac216..43cac4a15602 100644 --- a/ext/zend_test/tests/zpp/types.inc +++ b/ext/zend_test/tests/zpp/types.inc @@ -6,6 +6,8 @@ class S { } } +$anon = new class {}; + return [ 'null' => null, 'false' => false, @@ -15,6 +17,8 @@ return [ "'string'" => 'string', "'15'" => '15', "'56.7'" => '56.7', + "'stdClass'" => 'stdClass', + 'anon class name' => $anon::class, '[]' => [], 'new stdClass()' => new stdClass(), 'new S()' => new S(), From b729dbde4b992102e2749ba84a181aca670ae872 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 12 Aug 2026 16:07:53 +0100 Subject: [PATCH 13/23] zend_test: improve class name ZPP test --- ext/zend_test/test.c | 50 +++++ ext/zend_test/test.stub.php | 5 + ext/zend_test/test_arginfo.h | 22 ++- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 18 +- ...lass-string_zpp_specifier_strict_mode.phpt | 177 +++++++++++++++-- .../class-string_zpp_specifier_weak_mode.phpt | 179 ++++++++++++++++-- 7 files changed, 415 insertions(+), 44 deletions(-) diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 796547ad15ce..57dcb45e8e82 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -432,6 +432,56 @@ static ZEND_FUNCTION(zend_number_or_null_slow_zpp) RETURN_COPY(v); } +static ZEND_FUNCTION(zend_class_name) +{ + zend_class_entry *v = NULL; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_CLASS(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_STR_COPY(v->name); +} + +static ZEND_FUNCTION(zend_class_name_or_null) +{ + zend_class_entry *v = NULL; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_CLASS_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_STR_COPY(v->name); +} + +static ZEND_FUNCTION(zend_class_name_slow_zpp) +{ + zend_class_entry *v = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "C", &v) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_STR_COPY(v->name); +} + +static ZEND_FUNCTION(zend_class_name_or_null_slow_zpp) +{ + zend_class_entry *v = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "C!", &v) == FAILURE) { + RETURN_THROWS(); + } + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_STR_COPY(v->name); +} + static ZEND_FUNCTION(zend_resource) { zval *v; diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index c1999518ac25..45e0405431cf 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -319,6 +319,11 @@ function zend_number_or_null(int|float|null $param): int|float|null {} function zend_number_slow_zpp(int|float $param): int|float {} function zend_number_or_null_slow_zpp(int|float|null $param): int|float|null {} + function zend_class_name(string $param): string {} + function zend_class_name_or_null(string|null $param): string|null {} + function zend_class_name_slow_zpp(string $param): string {} + function zend_class_name_or_null_slow_zpp(string|null $param): string|null {} + /** * @param resource $param * @return resource diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 787f7222dc55..04b2590040f2 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: ed33b9480f56ed1261bba98db9fb99b2ee5373b5 + * Stub hash: 7f4f91a2a8c8463caad01e606a38a1ff3b706553 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -101,6 +101,18 @@ ZEND_END_ARG_INFO() #define arginfo_zend_number_or_null_slow_zpp arginfo_zend_number_or_null +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_class_name, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, param, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_class_name_or_null, 0, 1, IS_STRING, 1) + ZEND_ARG_TYPE_INFO(0, param, IS_STRING, 1) +ZEND_END_ARG_INFO() + +#define arginfo_zend_class_name_slow_zpp arginfo_zend_class_name + +#define arginfo_zend_class_name_or_null_slow_zpp arginfo_zend_class_name_or_null + ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_resource, 0, 0, 1) ZEND_ARG_INFO(0, param) ZEND_END_ARG_INFO() @@ -387,6 +399,10 @@ static ZEND_FUNCTION(zend_number); static ZEND_FUNCTION(zend_number_or_null); static ZEND_FUNCTION(zend_number_slow_zpp); static ZEND_FUNCTION(zend_number_or_null_slow_zpp); +static ZEND_FUNCTION(zend_class_name); +static ZEND_FUNCTION(zend_class_name_or_null); +static ZEND_FUNCTION(zend_class_name_slow_zpp); +static ZEND_FUNCTION(zend_class_name_or_null_slow_zpp); static ZEND_FUNCTION(zend_resource); static ZEND_FUNCTION(zend_resource_or_null); static ZEND_FUNCTION(zend_resource_slow_zpp); @@ -543,6 +559,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_number_or_null, arginfo_zend_number_or_null) ZEND_FE(zend_number_slow_zpp, arginfo_zend_number_slow_zpp) ZEND_FE(zend_number_or_null_slow_zpp, arginfo_zend_number_or_null_slow_zpp) + ZEND_FE(zend_class_name, arginfo_zend_class_name) + ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) + ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) + ZEND_FE(zend_class_name_or_null_slow_zpp, arginfo_zend_class_name_or_null_slow_zpp) ZEND_FE(zend_resource, arginfo_zend_resource) ZEND_FE(zend_resource_or_null, arginfo_zend_resource_or_null) ZEND_FE(zend_resource_slow_zpp, arginfo_zend_resource_slow_zpp) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index a6f18f6e84b3..c698f1eb1057 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: ed33b9480f56ed1261bba98db9fb99b2ee5373b5 */ + * Stub hash: 7f4f91a2a8c8463caad01e606a38a1ff3b706553 */ -#ifndef ZEND_TEST_DECL_ed33b9480f56ed1261bba98db9fb99b2ee5373b5_H -#define ZEND_TEST_DECL_ed33b9480f56ed1261bba98db9fb99b2ee5373b5_H +#ifndef ZEND_TEST_DECL_7f4f91a2a8c8463caad01e606a38a1ff3b706553_H +#define ZEND_TEST_DECL_7f4f91a2a8c8463caad01e606a38a1ff3b706553_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_ed33b9480f56ed1261bba98db9fb99b2ee5373b5_H */ +#endif /* ZEND_TEST_DECL_7f4f91a2a8c8463caad01e606a38a1ff3b706553_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index 7eb08c2f936a..6ead4d32cbaf 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: ed33b9480f56ed1261bba98db9fb99b2ee5373b5 + * Stub hash: 7f4f91a2a8c8463caad01e606a38a1ff3b706553 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -83,6 +83,14 @@ ZEND_END_ARG_INFO() #define arginfo_zend_number_or_null_slow_zpp arginfo_zend_bool +#define arginfo_zend_class_name arginfo_zend_bool + +#define arginfo_zend_class_name_or_null arginfo_zend_bool + +#define arginfo_zend_class_name_slow_zpp arginfo_zend_bool + +#define arginfo_zend_class_name_or_null_slow_zpp arginfo_zend_bool + #define arginfo_zend_resource arginfo_zend_bool #define arginfo_zend_resource_or_null arginfo_zend_bool @@ -332,6 +340,10 @@ static ZEND_FUNCTION(zend_number); static ZEND_FUNCTION(zend_number_or_null); static ZEND_FUNCTION(zend_number_slow_zpp); static ZEND_FUNCTION(zend_number_or_null_slow_zpp); +static ZEND_FUNCTION(zend_class_name); +static ZEND_FUNCTION(zend_class_name_or_null); +static ZEND_FUNCTION(zend_class_name_slow_zpp); +static ZEND_FUNCTION(zend_class_name_or_null_slow_zpp); static ZEND_FUNCTION(zend_resource); static ZEND_FUNCTION(zend_resource_or_null); static ZEND_FUNCTION(zend_resource_slow_zpp); @@ -460,6 +472,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_number_or_null, arginfo_zend_number_or_null) ZEND_FE(zend_number_slow_zpp, arginfo_zend_number_slow_zpp) ZEND_FE(zend_number_or_null_slow_zpp, arginfo_zend_number_or_null_slow_zpp) + ZEND_FE(zend_class_name, arginfo_zend_class_name) + ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) + ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) + ZEND_FE(zend_class_name_or_null_slow_zpp, arginfo_zend_class_name_or_null_slow_zpp) ZEND_FE(zend_resource, arginfo_zend_resource) ZEND_FE(zend_resource_or_null, arginfo_zend_resource_or_null) ZEND_FE(zend_resource_slow_zpp, arginfo_zend_resource_slow_zpp) diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt index 661b5f0b7523..bdc48e27d4ad 100644 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt +++ b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt @@ -11,43 +11,182 @@ $types = require 'types.inc'; foreach ($types as $name => $type) { echo "Using $name:\n"; - /* Use zend_object_init_with_constructor() function as it used Z_PARAM_CLASS */ try { - var_dump(zend_object_init_with_constructor($type)); + var_dump(zend_class_name($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_class_name($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null_slow_zpp($ref)); } catch (Throwable $e) { echo $e::class, ': ', $e->getMessage(), PHP_EOL; } } ?> ---EXPECT-- +--EXPECTF-- Using null: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, null given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, null given +NULL +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +NULL +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, null given +NULL +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +NULL Using false: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, false given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, false given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, false given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, false given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, false given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, given Using true: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, true given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, true given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, true given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 1 given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, true given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, true given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 1 given Using 42: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, int given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, int given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, int given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 42 given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, int given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, int given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 42 given Using 73.5: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, float given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, float given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, float given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 73.5 given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, float given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, float given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 73.5 given Using 'string': -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, string given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, string given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, string given Using '15': -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 15 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 15 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 15 given Using '56.7': -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 56.7 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 56.7 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 56.7 given Using 'stdClass': -object(stdClass)#4 (0) { -} +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" Using anon class name: -object(class@anonymous)#4 (0) { -} +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" Using []: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, array given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, array given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Array given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, array given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Array given Using new stdClass(): -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, stdClass given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, stdClass given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, stdClass given +Error: Object of class stdClass could not be converted to string +Error: Object of class stdClass could not be converted to string +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, stdClass given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, stdClass given +Error: Object of class stdClass could not be converted to string +Error: Object of class stdClass could not be converted to string Using new S(): -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, S given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, S given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, S given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, S class given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, S given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, S given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, S class given Using STDOUT: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, resource given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, resource given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, resource given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Resource id #2 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Resource id #2 given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, resource given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, resource given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Resource id #2 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Resource id #2 given diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt index 543c0b781b12..9341ecbb4102 100644 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt +++ b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt @@ -9,9 +9,44 @@ $types = require 'types.inc'; foreach ($types as $name => $type) { echo "Using $name:\n"; - /* Use zend_object_init_with_constructor() function as it used Z_PARAM_CLASS */ try { - var_dump(zend_object_init_with_constructor($type)); + var_dump(zend_class_name($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_class_name($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null_slow_zpp($ref)); } catch (Throwable $e) { echo $e::class, ': ', $e->getMessage(), PHP_EOL; } @@ -21,33 +56,139 @@ foreach ($types as $name => $type) { --EXPECTF-- Using null: -Deprecated: zend_object_init_with_constructor(): Passing null to parameter #1 ($class) of type string is deprecated in %s on line %d -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, given +Deprecated: zend_class_name(): Passing null to parameter #1 ($param) of type string is deprecated in %s on line %d +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, given +NULL +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +NULL + +Deprecated: zend_class_name(): Passing null to parameter #1 ($param) of type string is deprecated in %s on line %d +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, given +NULL +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +NULL Using false: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, given Using true: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 1 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 1 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 1 given Using 42: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 42 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 42 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 42 given Using 73.5: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 73.5 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 73.5 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 73.5 given Using 'string': -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, string given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, string given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, string given Using '15': -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 15 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 15 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 15 given Using '56.7': -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 56.7 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 56.7 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 56.7 given Using 'stdClass': -object(stdClass)#4 (0) { -} +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" Using anon class name: -object(class@anonymous)#4 (0) { -} +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" Using []: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, array given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, array given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Array given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, array given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Array given Using new stdClass(): -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, stdClass given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, stdClass given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, stdClass given +Error: Object of class stdClass could not be converted to string +Error: Object of class stdClass could not be converted to string +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, stdClass given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, stdClass given +Error: Object of class stdClass could not be converted to string +Error: Object of class stdClass could not be converted to string Using new S(): -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, S class given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, S class given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, S class given Using STDOUT: -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, resource given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, resource given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, resource given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Resource id #2 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Resource id #2 given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, resource given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, resource given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Resource id #2 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Resource id #2 given From 4e48d7db89c6852db663733131fc99878194c530 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 12 Aug 2026 18:25:29 +0100 Subject: [PATCH 14/23] zend_test: add object ZPP specifier test --- ext/zend_test/test.c | 50 +++++ ext/zend_test/test.stub.php | 5 + ext/zend_test/test_arginfo.h | 22 +- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 18 +- .../zpp/object_zpp_specifier_strict_mode.phpt | 200 ++++++++++++++++++ .../zpp/object_zpp_specifier_weak_mode.phpt | 198 +++++++++++++++++ 7 files changed, 495 insertions(+), 6 deletions(-) create mode 100644 ext/zend_test/tests/zpp/object_zpp_specifier_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/object_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 57dcb45e8e82..d6423df55fd8 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -432,6 +432,56 @@ static ZEND_FUNCTION(zend_number_or_null_slow_zpp) RETURN_COPY(v); } +static ZEND_FUNCTION(zend_object) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_or_null) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &v) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_or_null_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "o!", &v) == FAILURE) { + RETURN_THROWS(); + } + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + static ZEND_FUNCTION(zend_class_name) { zend_class_entry *v = NULL; diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 45e0405431cf..bb795d6ab309 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -319,6 +319,11 @@ function zend_number_or_null(int|float|null $param): int|float|null {} function zend_number_slow_zpp(int|float $param): int|float {} function zend_number_or_null_slow_zpp(int|float|null $param): int|float|null {} + function zend_object(object $param): object {} + function zend_object_or_null(object|null $param): object|null {} + function zend_object_slow_zpp(object $param): object {} + function zend_object_or_null_slow_zpp(object|null $param): object|null {} + function zend_class_name(string $param): string {} function zend_class_name_or_null(string|null $param): string|null {} function zend_class_name_slow_zpp(string $param): string {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 04b2590040f2..547244bb8d0d 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 7f4f91a2a8c8463caad01e606a38a1ff3b706553 + * Stub hash: 0316665e4b64b07ca07f014e2fef5e8cfe2bc626 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -101,6 +101,18 @@ ZEND_END_ARG_INFO() #define arginfo_zend_number_or_null_slow_zpp arginfo_zend_number_or_null +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_object, 0, 1, IS_OBJECT, 0) + ZEND_ARG_TYPE_INFO(0, param, IS_OBJECT, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_object_or_null, 0, 1, IS_OBJECT, 1) + ZEND_ARG_TYPE_INFO(0, param, IS_OBJECT, 1) +ZEND_END_ARG_INFO() + +#define arginfo_zend_object_slow_zpp arginfo_zend_object + +#define arginfo_zend_object_or_null_slow_zpp arginfo_zend_object_or_null + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_class_name, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, param, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -399,6 +411,10 @@ static ZEND_FUNCTION(zend_number); static ZEND_FUNCTION(zend_number_or_null); static ZEND_FUNCTION(zend_number_slow_zpp); static ZEND_FUNCTION(zend_number_or_null_slow_zpp); +static ZEND_FUNCTION(zend_object); +static ZEND_FUNCTION(zend_object_or_null); +static ZEND_FUNCTION(zend_object_slow_zpp); +static ZEND_FUNCTION(zend_object_or_null_slow_zpp); static ZEND_FUNCTION(zend_class_name); static ZEND_FUNCTION(zend_class_name_or_null); static ZEND_FUNCTION(zend_class_name_slow_zpp); @@ -559,6 +575,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_number_or_null, arginfo_zend_number_or_null) ZEND_FE(zend_number_slow_zpp, arginfo_zend_number_slow_zpp) ZEND_FE(zend_number_or_null_slow_zpp, arginfo_zend_number_or_null_slow_zpp) + ZEND_FE(zend_object, arginfo_zend_object) + ZEND_FE(zend_object_or_null, arginfo_zend_object_or_null) + ZEND_FE(zend_object_slow_zpp, arginfo_zend_object_slow_zpp) + ZEND_FE(zend_object_or_null_slow_zpp, arginfo_zend_object_or_null_slow_zpp) ZEND_FE(zend_class_name, arginfo_zend_class_name) ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index c698f1eb1057..f845a771b54e 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 7f4f91a2a8c8463caad01e606a38a1ff3b706553 */ + * Stub hash: 0316665e4b64b07ca07f014e2fef5e8cfe2bc626 */ -#ifndef ZEND_TEST_DECL_7f4f91a2a8c8463caad01e606a38a1ff3b706553_H -#define ZEND_TEST_DECL_7f4f91a2a8c8463caad01e606a38a1ff3b706553_H +#ifndef ZEND_TEST_DECL_0316665e4b64b07ca07f014e2fef5e8cfe2bc626_H +#define ZEND_TEST_DECL_0316665e4b64b07ca07f014e2fef5e8cfe2bc626_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_7f4f91a2a8c8463caad01e606a38a1ff3b706553_H */ +#endif /* ZEND_TEST_DECL_0316665e4b64b07ca07f014e2fef5e8cfe2bc626_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index 6ead4d32cbaf..61a80029ad2b 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 7f4f91a2a8c8463caad01e606a38a1ff3b706553 + * Stub hash: 0316665e4b64b07ca07f014e2fef5e8cfe2bc626 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -83,6 +83,14 @@ ZEND_END_ARG_INFO() #define arginfo_zend_number_or_null_slow_zpp arginfo_zend_bool +#define arginfo_zend_object arginfo_zend_bool + +#define arginfo_zend_object_or_null arginfo_zend_bool + +#define arginfo_zend_object_slow_zpp arginfo_zend_bool + +#define arginfo_zend_object_or_null_slow_zpp arginfo_zend_bool + #define arginfo_zend_class_name arginfo_zend_bool #define arginfo_zend_class_name_or_null arginfo_zend_bool @@ -340,6 +348,10 @@ static ZEND_FUNCTION(zend_number); static ZEND_FUNCTION(zend_number_or_null); static ZEND_FUNCTION(zend_number_slow_zpp); static ZEND_FUNCTION(zend_number_or_null_slow_zpp); +static ZEND_FUNCTION(zend_object); +static ZEND_FUNCTION(zend_object_or_null); +static ZEND_FUNCTION(zend_object_slow_zpp); +static ZEND_FUNCTION(zend_object_or_null_slow_zpp); static ZEND_FUNCTION(zend_class_name); static ZEND_FUNCTION(zend_class_name_or_null); static ZEND_FUNCTION(zend_class_name_slow_zpp); @@ -472,6 +484,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_number_or_null, arginfo_zend_number_or_null) ZEND_FE(zend_number_slow_zpp, arginfo_zend_number_slow_zpp) ZEND_FE(zend_number_or_null_slow_zpp, arginfo_zend_number_or_null_slow_zpp) + ZEND_FE(zend_object, arginfo_zend_object) + ZEND_FE(zend_object_or_null, arginfo_zend_object_or_null) + ZEND_FE(zend_object_slow_zpp, arginfo_zend_object_slow_zpp) + ZEND_FE(zend_object_or_null_slow_zpp, arginfo_zend_object_or_null_slow_zpp) ZEND_FE(zend_class_name, arginfo_zend_class_name) ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) diff --git a/ext/zend_test/tests/zpp/object_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/object_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..c0f66a7846aa --- /dev/null +++ b/ext/zend_test/tests/zpp/object_zpp_specifier_strict_mode.phpt @@ -0,0 +1,200 @@ +--TEST-- +Test object ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, null given +NULL +Using false: +TypeError: zend_object(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, false given +Using true: +TypeError: zend_object(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, true given +Using 42: +TypeError: zend_object(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, int given +Using 73.5: +TypeError: zend_object(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, float given +Using 'string': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using '15': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using '56.7': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using 'stdClass': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using anon class name: +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using []: +TypeError: zend_object(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_object(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, resource given diff --git a/ext/zend_test/tests/zpp/object_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/object_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..d97078aaca46 --- /dev/null +++ b/ext/zend_test/tests/zpp/object_zpp_specifier_weak_mode.phpt @@ -0,0 +1,198 @@ +--TEST-- +Test object ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, null given +NULL +Using false: +TypeError: zend_object(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, false given +Using true: +TypeError: zend_object(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, true given +Using 42: +TypeError: zend_object(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, int given +Using 73.5: +TypeError: zend_object(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, float given +Using 'string': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using '15': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using '56.7': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using 'stdClass': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using anon class name: +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using []: +TypeError: zend_object(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_object(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, resource given From c08d26ad3aaf88ae2535ce90a736b3dc6a81561d Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 13 Aug 2026 00:58:12 +0100 Subject: [PATCH 15/23] zend_test: add Z_PARAM_OBJ ZPP specifier test --- ext/zend_test/test.c | 25 ++++ ext/zend_test/test.stub.php | 3 + ext/zend_test/test_arginfo.h | 10 +- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 10 +- .../zpp/obj_zpp_specifier_strict_mode.phpt | 116 ++++++++++++++++++ .../zpp/obj_zpp_specifier_weak_mode.phpt | 114 +++++++++++++++++ 7 files changed, 280 insertions(+), 6 deletions(-) create mode 100644 ext/zend_test/tests/zpp/obj_zpp_specifier_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/obj_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index d6423df55fd8..7aff605b06cd 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -482,6 +482,31 @@ static ZEND_FUNCTION(zend_object_or_null_slow_zpp) RETURN_COPY(v); } +static ZEND_FUNCTION(zend_obj) +{ + zend_object *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_OBJ_COPY(v); +} + +static ZEND_FUNCTION(zend_obj_or_null) +{ + zend_object *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_OBJ_COPY(v); +} + static ZEND_FUNCTION(zend_class_name) { zend_class_entry *v = NULL; diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index bb795d6ab309..b33ad2b1625d 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -324,6 +324,9 @@ function zend_object_or_null(object|null $param): object|null {} function zend_object_slow_zpp(object $param): object {} function zend_object_or_null_slow_zpp(object|null $param): object|null {} + function zend_obj(object $param): object {} + function zend_obj_or_null(object|null $param): object|null {} + function zend_class_name(string $param): string {} function zend_class_name_or_null(string|null $param): string|null {} function zend_class_name_slow_zpp(string $param): string {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 547244bb8d0d..0d83785ae84d 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 0316665e4b64b07ca07f014e2fef5e8cfe2bc626 + * Stub hash: dfaf2f073e5a5bb028297448002c9ffe40bce307 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -113,6 +113,10 @@ ZEND_END_ARG_INFO() #define arginfo_zend_object_or_null_slow_zpp arginfo_zend_object_or_null +#define arginfo_zend_obj arginfo_zend_object + +#define arginfo_zend_obj_or_null arginfo_zend_object_or_null + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_class_name, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, param, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -415,6 +419,8 @@ static ZEND_FUNCTION(zend_object); static ZEND_FUNCTION(zend_object_or_null); static ZEND_FUNCTION(zend_object_slow_zpp); static ZEND_FUNCTION(zend_object_or_null_slow_zpp); +static ZEND_FUNCTION(zend_obj); +static ZEND_FUNCTION(zend_obj_or_null); static ZEND_FUNCTION(zend_class_name); static ZEND_FUNCTION(zend_class_name_or_null); static ZEND_FUNCTION(zend_class_name_slow_zpp); @@ -579,6 +585,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_object_or_null, arginfo_zend_object_or_null) ZEND_FE(zend_object_slow_zpp, arginfo_zend_object_slow_zpp) ZEND_FE(zend_object_or_null_slow_zpp, arginfo_zend_object_or_null_slow_zpp) + ZEND_FE(zend_obj, arginfo_zend_obj) + ZEND_FE(zend_obj_or_null, arginfo_zend_obj_or_null) ZEND_FE(zend_class_name, arginfo_zend_class_name) ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index f845a771b54e..c73c5e3b165d 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 0316665e4b64b07ca07f014e2fef5e8cfe2bc626 */ + * Stub hash: dfaf2f073e5a5bb028297448002c9ffe40bce307 */ -#ifndef ZEND_TEST_DECL_0316665e4b64b07ca07f014e2fef5e8cfe2bc626_H -#define ZEND_TEST_DECL_0316665e4b64b07ca07f014e2fef5e8cfe2bc626_H +#ifndef ZEND_TEST_DECL_dfaf2f073e5a5bb028297448002c9ffe40bce307_H +#define ZEND_TEST_DECL_dfaf2f073e5a5bb028297448002c9ffe40bce307_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_0316665e4b64b07ca07f014e2fef5e8cfe2bc626_H */ +#endif /* ZEND_TEST_DECL_dfaf2f073e5a5bb028297448002c9ffe40bce307_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index 61a80029ad2b..45c19ee1da9f 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 0316665e4b64b07ca07f014e2fef5e8cfe2bc626 + * Stub hash: dfaf2f073e5a5bb028297448002c9ffe40bce307 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -91,6 +91,10 @@ ZEND_END_ARG_INFO() #define arginfo_zend_object_or_null_slow_zpp arginfo_zend_bool +#define arginfo_zend_obj arginfo_zend_bool + +#define arginfo_zend_obj_or_null arginfo_zend_bool + #define arginfo_zend_class_name arginfo_zend_bool #define arginfo_zend_class_name_or_null arginfo_zend_bool @@ -352,6 +356,8 @@ static ZEND_FUNCTION(zend_object); static ZEND_FUNCTION(zend_object_or_null); static ZEND_FUNCTION(zend_object_slow_zpp); static ZEND_FUNCTION(zend_object_or_null_slow_zpp); +static ZEND_FUNCTION(zend_obj); +static ZEND_FUNCTION(zend_obj_or_null); static ZEND_FUNCTION(zend_class_name); static ZEND_FUNCTION(zend_class_name_or_null); static ZEND_FUNCTION(zend_class_name_slow_zpp); @@ -488,6 +494,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_object_or_null, arginfo_zend_object_or_null) ZEND_FE(zend_object_slow_zpp, arginfo_zend_object_slow_zpp) ZEND_FE(zend_object_or_null_slow_zpp, arginfo_zend_object_or_null_slow_zpp) + ZEND_FE(zend_obj, arginfo_zend_obj) + ZEND_FE(zend_obj_or_null, arginfo_zend_obj_or_null) ZEND_FE(zend_class_name, arginfo_zend_class_name) ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) diff --git a/ext/zend_test/tests/zpp/obj_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/obj_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..fecfb294bb45 --- /dev/null +++ b/ext/zend_test/tests/zpp/obj_zpp_specifier_strict_mode.phpt @@ -0,0 +1,116 @@ +--TEST-- +Test Z_PARAM_OBJ() and Z_PARAM_OBJ_OR_NULL (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_obj($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_obj(): Argument #1 ($param) must be of type object, null given +NULL +Using false: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, false given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, false given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, false given +Using true: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, true given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, true given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, true given +Using 42: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, int given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, int given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, int given +Using 73.5: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, float given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, float given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, float given +Using 'string': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using '15': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using '56.7': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using 'stdClass': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using anon class name: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using []: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, array given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, array given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, resource given diff --git a/ext/zend_test/tests/zpp/obj_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/obj_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..0557f1f03f37 --- /dev/null +++ b/ext/zend_test/tests/zpp/obj_zpp_specifier_weak_mode.phpt @@ -0,0 +1,114 @@ +--TEST-- +Test Z_PARAM_OBJ() and Z_PARAM_OBJ_OR_NULL (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_obj($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_obj(): Argument #1 ($param) must be of type object, null given +NULL +Using false: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, false given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, false given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, false given +Using true: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, true given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, true given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, true given +Using 42: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, int given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, int given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, int given +Using 73.5: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, float given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, float given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, float given +Using 'string': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using '15': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using '56.7': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using 'stdClass': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using anon class name: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using []: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, array given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, array given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, resource given From 9175cc36002fe36519282e6c7416cdc3292b66c1 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 13 Aug 2026 01:06:06 +0100 Subject: [PATCH 16/23] zend_test: improve testing for object|string ZPP Rename test file to match the ZPP specifier order --- .../tests/zpp/obj_or_str_zpp_strict_mode.phpt | 73 +++++++++++++++++++ ...zpp.phpt => obj_or_str_zpp_weak_mode.phpt} | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 ext/zend_test/tests/zpp/obj_or_str_zpp_strict_mode.phpt rename ext/zend_test/tests/zpp/{str_or_obj_zpp.phpt => obj_or_str_zpp_weak_mode.phpt} (95%) diff --git a/ext/zend_test/tests/zpp/obj_or_str_zpp_strict_mode.phpt b/ext/zend_test/tests/zpp/obj_or_str_zpp_strict_mode.phpt new file mode 100644 index 000000000000..9614acdee272 --- /dev/null +++ b/ext/zend_test/tests/zpp/obj_or_str_zpp_strict_mode.phpt @@ -0,0 +1,73 @@ +--TEST-- +Test Z_PARAM_OBJ_OR_STR() and Z_PARAM_OBJ_OR_STR_OR_NULL (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_string_or_object($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_string_or_object_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, null given +NULL +Using false: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, false given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, false given +Using true: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, true given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, true given +Using 42: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, int given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, int given +Using 73.5: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, float given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, float given +Using 'string': +string(6) "string" +string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, array given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, resource given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, resource given diff --git a/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt b/ext/zend_test/tests/zpp/obj_or_str_zpp_weak_mode.phpt similarity index 95% rename from ext/zend_test/tests/zpp/str_or_obj_zpp.phpt rename to ext/zend_test/tests/zpp/obj_or_str_zpp_weak_mode.phpt index 34376f94983b..76198926ffe8 100644 --- a/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt +++ b/ext/zend_test/tests/zpp/obj_or_str_zpp_weak_mode.phpt @@ -1,5 +1,5 @@ --TEST-- -Test Z_PARAM_OBJ_OR_STR() and Z_PARAM_OBJ_OR_STR_OR_NULL +Test Z_PARAM_OBJ_OR_STR() and Z_PARAM_OBJ_OR_STR_OR_NULL (weak_mode) --EXTENSIONS-- zend_test --FILE-- From 4883499d0a1fa2c80412188df4c09ec892a1d1ed Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 13 Aug 2026 01:13:26 +0100 Subject: [PATCH 17/23] zend_test: add Z_PARAM_OBJ_OR_CLASS_NAME ZPP specifier test --- ext/zend_test/test.c | 25 +++++++ ext/zend_test/test.stub.php | 3 + ext/zend_test/test_arginfo.h | 14 +++- ext/zend_test/test_decl.h | 8 +-- ext/zend_test/test_legacy_arginfo.h | 10 ++- .../obj_or_class_name_zpp_strict_mode.phpt | 69 +++++++++++++++++++ .../zpp/obj_or_class_name_zpp_weak_mode.phpt | 67 ++++++++++++++++++ 7 files changed, 190 insertions(+), 6 deletions(-) create mode 100644 ext/zend_test/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 7aff605b06cd..66df820b21a3 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -507,6 +507,31 @@ static ZEND_FUNCTION(zend_obj_or_null) RETURN_OBJ_COPY(v); } +static ZEND_FUNCTION(zend_obj_or_class_name) +{ + zend_class_entry *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OR_CLASS_NAME(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_STR_COPY(v->name); +} + +static ZEND_FUNCTION(zend_obj_or_class_name_or_null) +{ + zend_class_entry *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OR_CLASS_NAME_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_STR_COPY(v->name); +} + static ZEND_FUNCTION(zend_class_name) { zend_class_entry *v = NULL; diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index b33ad2b1625d..04e50253ccf1 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -327,6 +327,9 @@ function zend_object_or_null_slow_zpp(object|null $param): object|null {} function zend_obj(object $param): object {} function zend_obj_or_null(object|null $param): object|null {} + function zend_obj_or_class_name(object|string $param): string {} + function zend_obj_or_class_name_or_null(object|string|null $param): string|null {} + function zend_class_name(string $param): string {} function zend_class_name_or_null(string|null $param): string|null {} function zend_class_name_slow_zpp(string $param): string {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 0d83785ae84d..8b5bc52f8efd 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: dfaf2f073e5a5bb028297448002c9ffe40bce307 + * Stub hash: 6499804aa782b477d471188835bce331e1c02137 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -117,6 +117,14 @@ ZEND_END_ARG_INFO() #define arginfo_zend_obj_or_null arginfo_zend_object_or_null +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_obj_or_class_name, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_obj_or_class_name_or_null, 0, 1, IS_STRING, 1) + ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING|MAY_BE_NULL, NULL) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_class_name, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, param, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -421,6 +429,8 @@ static ZEND_FUNCTION(zend_object_slow_zpp); static ZEND_FUNCTION(zend_object_or_null_slow_zpp); static ZEND_FUNCTION(zend_obj); static ZEND_FUNCTION(zend_obj_or_null); +static ZEND_FUNCTION(zend_obj_or_class_name); +static ZEND_FUNCTION(zend_obj_or_class_name_or_null); static ZEND_FUNCTION(zend_class_name); static ZEND_FUNCTION(zend_class_name_or_null); static ZEND_FUNCTION(zend_class_name_slow_zpp); @@ -587,6 +597,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_object_or_null_slow_zpp, arginfo_zend_object_or_null_slow_zpp) ZEND_FE(zend_obj, arginfo_zend_obj) ZEND_FE(zend_obj_or_null, arginfo_zend_obj_or_null) + ZEND_FE(zend_obj_or_class_name, arginfo_zend_obj_or_class_name) + ZEND_FE(zend_obj_or_class_name_or_null, arginfo_zend_obj_or_class_name_or_null) ZEND_FE(zend_class_name, arginfo_zend_class_name) ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index c73c5e3b165d..4e5c676db188 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: dfaf2f073e5a5bb028297448002c9ffe40bce307 */ + * Stub hash: 6499804aa782b477d471188835bce331e1c02137 */ -#ifndef ZEND_TEST_DECL_dfaf2f073e5a5bb028297448002c9ffe40bce307_H -#define ZEND_TEST_DECL_dfaf2f073e5a5bb028297448002c9ffe40bce307_H +#ifndef ZEND_TEST_DECL_6499804aa782b477d471188835bce331e1c02137_H +#define ZEND_TEST_DECL_6499804aa782b477d471188835bce331e1c02137_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_dfaf2f073e5a5bb028297448002c9ffe40bce307_H */ +#endif /* ZEND_TEST_DECL_6499804aa782b477d471188835bce331e1c02137_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index 45c19ee1da9f..18dc62e3b65c 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: dfaf2f073e5a5bb028297448002c9ffe40bce307 + * Stub hash: 6499804aa782b477d471188835bce331e1c02137 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -95,6 +95,10 @@ ZEND_END_ARG_INFO() #define arginfo_zend_obj_or_null arginfo_zend_bool +#define arginfo_zend_obj_or_class_name arginfo_zend_bool + +#define arginfo_zend_obj_or_class_name_or_null arginfo_zend_bool + #define arginfo_zend_class_name arginfo_zend_bool #define arginfo_zend_class_name_or_null arginfo_zend_bool @@ -358,6 +362,8 @@ static ZEND_FUNCTION(zend_object_slow_zpp); static ZEND_FUNCTION(zend_object_or_null_slow_zpp); static ZEND_FUNCTION(zend_obj); static ZEND_FUNCTION(zend_obj_or_null); +static ZEND_FUNCTION(zend_obj_or_class_name); +static ZEND_FUNCTION(zend_obj_or_class_name_or_null); static ZEND_FUNCTION(zend_class_name); static ZEND_FUNCTION(zend_class_name_or_null); static ZEND_FUNCTION(zend_class_name_slow_zpp); @@ -496,6 +502,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_object_or_null_slow_zpp, arginfo_zend_object_or_null_slow_zpp) ZEND_FE(zend_obj, arginfo_zend_obj) ZEND_FE(zend_obj_or_null, arginfo_zend_obj_or_null) + ZEND_FE(zend_obj_or_class_name, arginfo_zend_obj_or_class_name) + ZEND_FE(zend_obj_or_class_name_or_null, arginfo_zend_obj_or_class_name_or_null) ZEND_FE(zend_class_name, arginfo_zend_class_name) ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) diff --git a/ext/zend_test/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt b/ext/zend_test/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt new file mode 100644 index 000000000000..9bdfd66ae4ee --- /dev/null +++ b/ext/zend_test/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test Z_PARAM_OBJ_OR_CLASS_NAME() and Z_PARAM_OBJ_OR_CLASS_NAME_OR_NULL (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_or_class_name($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_class_name_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, null given +NULL +Using false: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, false given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, false given +Using true: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, true given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, true given +Using 42: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, int given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, int given +Using 73.5: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, float given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, float given +Using 'string': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using '15': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using '56.7': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, array given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, array given +Using new stdClass(): +string(8) "stdClass" +string(8) "stdClass" +Using new S(): +string(1) "S" +string(1) "S" +Using STDOUT: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, resource given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, resource given diff --git a/ext/zend_test/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt b/ext/zend_test/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt new file mode 100644 index 000000000000..c14250a14f9e --- /dev/null +++ b/ext/zend_test/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt @@ -0,0 +1,67 @@ +--TEST-- +Test Z_PARAM_OBJ_OR_CLASS_NAME() and Z_PARAM_OBJ_OR_CLASS_NAME_OR_NULL (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_or_class_name($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_class_name_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, null given +NULL +Using false: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, false given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, false given +Using true: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, true given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, true given +Using 42: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, int given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, int given +Using 73.5: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, float given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, float given +Using 'string': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using '15': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using '56.7': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, array given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, array given +Using new stdClass(): +string(8) "stdClass" +string(8) "stdClass" +Using new S(): +string(1) "S" +string(1) "S" +Using STDOUT: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, resource given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, resource given From 75d96aa0a7c693484fc8d813a230d606e82bfe0b Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 13 Aug 2026 12:51:42 +0100 Subject: [PATCH 18/23] improve number or str ZPP tests --- .../zpp/number_or_str_zpp_strict_mode.phpt | 69 +++++++++++++++++++ ....phpt => number_or_str_zpp_weak_mode.phpt} | 2 +- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 ext/zend_test/tests/zpp/number_or_str_zpp_strict_mode.phpt rename ext/zend_test/tests/zpp/{number_or_str_zpp.phpt => number_or_str_zpp_weak_mode.phpt} (95%) diff --git a/ext/zend_test/tests/zpp/number_or_str_zpp_strict_mode.phpt b/ext/zend_test/tests/zpp/number_or_str_zpp_strict_mode.phpt new file mode 100644 index 000000000000..15c616c37099 --- /dev/null +++ b/ext/zend_test/tests/zpp/number_or_str_zpp_strict_mode.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test Z_PARAM_NUMBER_OR_STR() and Z_PARAM_NUMBER_OR_STR_OR_NULL (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_number_or_string($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_string_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, null given +NULL +Using false: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, false given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, false given +Using true: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, true given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, true given +Using 42: +int(42) +int(42) +Using 73.5: +float(73.5) +float(73.5) +Using 'string': +string(6) "string" +string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, array given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, array given +Using new stdClass(): +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, stdClass given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, stdClass given +Using new S(): +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, S given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, S given +Using STDOUT: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, resource given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, resource given diff --git a/ext/zend_test/tests/zpp/number_or_str_zpp.phpt b/ext/zend_test/tests/zpp/number_or_str_zpp_weak_mode.phpt similarity index 95% rename from ext/zend_test/tests/zpp/number_or_str_zpp.phpt rename to ext/zend_test/tests/zpp/number_or_str_zpp_weak_mode.phpt index 151c99841073..f0a8985297fe 100644 --- a/ext/zend_test/tests/zpp/number_or_str_zpp.phpt +++ b/ext/zend_test/tests/zpp/number_or_str_zpp_weak_mode.phpt @@ -1,5 +1,5 @@ --TEST-- -Test Z_PARAM_NUMBER_OR_STR() and Z_PARAM_NUMBER_OR_STR_OR_NULL +Test Z_PARAM_NUMBER_OR_STR() and Z_PARAM_NUMBER_OR_STR_OR_NULL (weak_mode) --EXTENSIONS-- zend_test --FILE-- From 5025421f2317582de064adf27641ca6725aec958 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 13 Aug 2026 13:04:47 +0100 Subject: [PATCH 19/23] zend_test: add object of class ZPP specifier test --- ext/zend_test/test.c | 50 +++++ ext/zend_test/test.stub.php | 5 + ext/zend_test/test_arginfo.h | 22 +- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 18 +- ...ct_of_class_zpp_specifier_strict_mode.phpt | 192 ++++++++++++++++++ ...ject_of_class_zpp_specifier_weak_mode.phpt | 190 +++++++++++++++++ 7 files changed, 479 insertions(+), 6 deletions(-) create mode 100644 ext/zend_test/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 66df820b21a3..eefa0d5cbc06 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -582,6 +582,56 @@ static ZEND_FUNCTION(zend_class_name_or_null_slow_zpp) RETURN_STR_COPY(v->name); } +static ZEND_FUNCTION(zend_object_sdtClass) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(v, zend_standard_class_def) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_sdtClass_or_null) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(v, zend_standard_class_def) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_sdtClass_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &v, zend_standard_class_def) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_sdtClass_or_null_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O!", &v, zend_standard_class_def) == FAILURE) { + RETURN_THROWS(); + } + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + static ZEND_FUNCTION(zend_resource) { zval *v; diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 04e50253ccf1..a2a147e8b63d 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -335,6 +335,11 @@ function zend_class_name_or_null(string|null $param): string|null {} function zend_class_name_slow_zpp(string $param): string {} function zend_class_name_or_null_slow_zpp(string|null $param): string|null {} + function zend_object_sdtClass(stdClass $param): stdClass {} + function zend_object_sdtClass_or_null(stdClass|null $param): stdClass|null {} + function zend_object_sdtClass_slow_zpp(stdClass $param): stdClass {} + function zend_object_sdtClass_or_null_slow_zpp(stdClass|null $param): stdClass|null {} + /** * @param resource $param * @return resource diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 8b5bc52f8efd..78423ed8eba0 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 6499804aa782b477d471188835bce331e1c02137 + * Stub hash: fd89676f0b8f255ba02ff1a9b04c935badfc6338 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -137,6 +137,18 @@ ZEND_END_ARG_INFO() #define arginfo_zend_class_name_or_null_slow_zpp arginfo_zend_class_name_or_null +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_zend_object_sdtClass, 0, 1, stdClass, 0) + ZEND_ARG_OBJ_INFO(0, param, stdClass, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_zend_object_sdtClass_or_null, 0, 1, stdClass, 1) + ZEND_ARG_OBJ_INFO(0, param, stdClass, 1) +ZEND_END_ARG_INFO() + +#define arginfo_zend_object_sdtClass_slow_zpp arginfo_zend_object_sdtClass + +#define arginfo_zend_object_sdtClass_or_null_slow_zpp arginfo_zend_object_sdtClass_or_null + ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_resource, 0, 0, 1) ZEND_ARG_INFO(0, param) ZEND_END_ARG_INFO() @@ -435,6 +447,10 @@ static ZEND_FUNCTION(zend_class_name); static ZEND_FUNCTION(zend_class_name_or_null); static ZEND_FUNCTION(zend_class_name_slow_zpp); static ZEND_FUNCTION(zend_class_name_or_null_slow_zpp); +static ZEND_FUNCTION(zend_object_sdtClass); +static ZEND_FUNCTION(zend_object_sdtClass_or_null); +static ZEND_FUNCTION(zend_object_sdtClass_slow_zpp); +static ZEND_FUNCTION(zend_object_sdtClass_or_null_slow_zpp); static ZEND_FUNCTION(zend_resource); static ZEND_FUNCTION(zend_resource_or_null); static ZEND_FUNCTION(zend_resource_slow_zpp); @@ -603,6 +619,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) ZEND_FE(zend_class_name_or_null_slow_zpp, arginfo_zend_class_name_or_null_slow_zpp) + ZEND_FE(zend_object_sdtClass, arginfo_zend_object_sdtClass) + ZEND_FE(zend_object_sdtClass_or_null, arginfo_zend_object_sdtClass_or_null) + ZEND_FE(zend_object_sdtClass_slow_zpp, arginfo_zend_object_sdtClass_slow_zpp) + ZEND_FE(zend_object_sdtClass_or_null_slow_zpp, arginfo_zend_object_sdtClass_or_null_slow_zpp) ZEND_FE(zend_resource, arginfo_zend_resource) ZEND_FE(zend_resource_or_null, arginfo_zend_resource_or_null) ZEND_FE(zend_resource_slow_zpp, arginfo_zend_resource_slow_zpp) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index 4e5c676db188..0b86e7e993f2 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 6499804aa782b477d471188835bce331e1c02137 */ + * Stub hash: fd89676f0b8f255ba02ff1a9b04c935badfc6338 */ -#ifndef ZEND_TEST_DECL_6499804aa782b477d471188835bce331e1c02137_H -#define ZEND_TEST_DECL_6499804aa782b477d471188835bce331e1c02137_H +#ifndef ZEND_TEST_DECL_fd89676f0b8f255ba02ff1a9b04c935badfc6338_H +#define ZEND_TEST_DECL_fd89676f0b8f255ba02ff1a9b04c935badfc6338_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_6499804aa782b477d471188835bce331e1c02137_H */ +#endif /* ZEND_TEST_DECL_fd89676f0b8f255ba02ff1a9b04c935badfc6338_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index 18dc62e3b65c..c301a16c2df0 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 6499804aa782b477d471188835bce331e1c02137 + * Stub hash: fd89676f0b8f255ba02ff1a9b04c935badfc6338 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -107,6 +107,14 @@ ZEND_END_ARG_INFO() #define arginfo_zend_class_name_or_null_slow_zpp arginfo_zend_bool +#define arginfo_zend_object_sdtClass arginfo_zend_bool + +#define arginfo_zend_object_sdtClass_or_null arginfo_zend_bool + +#define arginfo_zend_object_sdtClass_slow_zpp arginfo_zend_bool + +#define arginfo_zend_object_sdtClass_or_null_slow_zpp arginfo_zend_bool + #define arginfo_zend_resource arginfo_zend_bool #define arginfo_zend_resource_or_null arginfo_zend_bool @@ -368,6 +376,10 @@ static ZEND_FUNCTION(zend_class_name); static ZEND_FUNCTION(zend_class_name_or_null); static ZEND_FUNCTION(zend_class_name_slow_zpp); static ZEND_FUNCTION(zend_class_name_or_null_slow_zpp); +static ZEND_FUNCTION(zend_object_sdtClass); +static ZEND_FUNCTION(zend_object_sdtClass_or_null); +static ZEND_FUNCTION(zend_object_sdtClass_slow_zpp); +static ZEND_FUNCTION(zend_object_sdtClass_or_null_slow_zpp); static ZEND_FUNCTION(zend_resource); static ZEND_FUNCTION(zend_resource_or_null); static ZEND_FUNCTION(zend_resource_slow_zpp); @@ -508,6 +520,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) ZEND_FE(zend_class_name_or_null_slow_zpp, arginfo_zend_class_name_or_null_slow_zpp) + ZEND_FE(zend_object_sdtClass, arginfo_zend_object_sdtClass) + ZEND_FE(zend_object_sdtClass_or_null, arginfo_zend_object_sdtClass_or_null) + ZEND_FE(zend_object_sdtClass_slow_zpp, arginfo_zend_object_sdtClass_slow_zpp) + ZEND_FE(zend_object_sdtClass_or_null_slow_zpp, arginfo_zend_object_sdtClass_or_null_slow_zpp) ZEND_FE(zend_resource, arginfo_zend_resource) ZEND_FE(zend_resource_or_null, arginfo_zend_resource_or_null) ZEND_FE(zend_resource_slow_zpp, arginfo_zend_resource_slow_zpp) diff --git a/ext/zend_test/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..94c31e1972fb --- /dev/null +++ b/ext/zend_test/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt @@ -0,0 +1,192 @@ +--TEST-- +Test object of class ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object_sdtClass($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object_sdtClass($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +Using false: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +Using true: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +Using 42: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +Using 73.5: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +Using 'string': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '15': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '56.7': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using 'stdClass': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using anon class name: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using []: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +Using STDOUT: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given diff --git a/ext/zend_test/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..b5ed5029645a --- /dev/null +++ b/ext/zend_test/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt @@ -0,0 +1,190 @@ +--TEST-- +Test object of class ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object_sdtClass($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object_sdtClass($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +Using false: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +Using true: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +Using 42: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +Using 73.5: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +Using 'string': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '15': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '56.7': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using 'stdClass': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using anon class name: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using []: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +Using STDOUT: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given From 65daf32efc98897a15933be8e86007628c630964 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 13 Aug 2026 13:07:58 +0100 Subject: [PATCH 20/23] zend_test: add Z_PARAM_OBJ_OF_CLASS ZPP specifier test --- ext/zend_test/test.c | 25 +++ ext/zend_test/test.stub.php | 3 + ext/zend_test/test_arginfo.h | 10 +- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 10 +- ...bj_of_class_zpp_specifier_strict_mode.phpt | 192 ++++++++++++++++++ .../obj_of_class_zpp_specifier_weak_mode.phpt | 190 +++++++++++++++++ 7 files changed, 432 insertions(+), 6 deletions(-) create mode 100644 ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index eefa0d5cbc06..3ff76b947666 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -632,6 +632,31 @@ static ZEND_FUNCTION(zend_object_sdtClass_or_null_slow_zpp) RETURN_COPY(v); } +static ZEND_FUNCTION(zend_obj_sdtClass) +{ + zend_object *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OF_CLASS(v, zend_standard_class_def) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_OBJ_COPY(v); +} + +static ZEND_FUNCTION(zend_obj_sdtClass_or_null) +{ + zend_object *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OF_CLASS_OR_NULL(v, zend_standard_class_def) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_OBJ_COPY(v); +} + static ZEND_FUNCTION(zend_resource) { zval *v; diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index a2a147e8b63d..26185c959dcd 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -340,6 +340,9 @@ function zend_object_sdtClass_or_null(stdClass|null $param): stdClass|null {} function zend_object_sdtClass_slow_zpp(stdClass $param): stdClass {} function zend_object_sdtClass_or_null_slow_zpp(stdClass|null $param): stdClass|null {} + function zend_obj_sdtClass(stdClass $param): stdClass {} + function zend_obj_sdtClass_or_null(stdClass|null $param): stdClass|null {} + /** * @param resource $param * @return resource diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 78423ed8eba0..9c9fa05fc3e7 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: fd89676f0b8f255ba02ff1a9b04c935badfc6338 + * Stub hash: 3ec17c7386ee9bd519b64b65443ea90d6546a9a3 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -149,6 +149,10 @@ ZEND_END_ARG_INFO() #define arginfo_zend_object_sdtClass_or_null_slow_zpp arginfo_zend_object_sdtClass_or_null +#define arginfo_zend_obj_sdtClass arginfo_zend_object_sdtClass + +#define arginfo_zend_obj_sdtClass_or_null arginfo_zend_object_sdtClass_or_null + ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_resource, 0, 0, 1) ZEND_ARG_INFO(0, param) ZEND_END_ARG_INFO() @@ -451,6 +455,8 @@ static ZEND_FUNCTION(zend_object_sdtClass); static ZEND_FUNCTION(zend_object_sdtClass_or_null); static ZEND_FUNCTION(zend_object_sdtClass_slow_zpp); static ZEND_FUNCTION(zend_object_sdtClass_or_null_slow_zpp); +static ZEND_FUNCTION(zend_obj_sdtClass); +static ZEND_FUNCTION(zend_obj_sdtClass_or_null); static ZEND_FUNCTION(zend_resource); static ZEND_FUNCTION(zend_resource_or_null); static ZEND_FUNCTION(zend_resource_slow_zpp); @@ -623,6 +629,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_object_sdtClass_or_null, arginfo_zend_object_sdtClass_or_null) ZEND_FE(zend_object_sdtClass_slow_zpp, arginfo_zend_object_sdtClass_slow_zpp) ZEND_FE(zend_object_sdtClass_or_null_slow_zpp, arginfo_zend_object_sdtClass_or_null_slow_zpp) + ZEND_FE(zend_obj_sdtClass, arginfo_zend_obj_sdtClass) + ZEND_FE(zend_obj_sdtClass_or_null, arginfo_zend_obj_sdtClass_or_null) ZEND_FE(zend_resource, arginfo_zend_resource) ZEND_FE(zend_resource_or_null, arginfo_zend_resource_or_null) ZEND_FE(zend_resource_slow_zpp, arginfo_zend_resource_slow_zpp) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index 0b86e7e993f2..318d4b57d2c3 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: fd89676f0b8f255ba02ff1a9b04c935badfc6338 */ + * Stub hash: 3ec17c7386ee9bd519b64b65443ea90d6546a9a3 */ -#ifndef ZEND_TEST_DECL_fd89676f0b8f255ba02ff1a9b04c935badfc6338_H -#define ZEND_TEST_DECL_fd89676f0b8f255ba02ff1a9b04c935badfc6338_H +#ifndef ZEND_TEST_DECL_3ec17c7386ee9bd519b64b65443ea90d6546a9a3_H +#define ZEND_TEST_DECL_3ec17c7386ee9bd519b64b65443ea90d6546a9a3_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_fd89676f0b8f255ba02ff1a9b04c935badfc6338_H */ +#endif /* ZEND_TEST_DECL_3ec17c7386ee9bd519b64b65443ea90d6546a9a3_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index c301a16c2df0..1262bfa25612 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: fd89676f0b8f255ba02ff1a9b04c935badfc6338 + * Stub hash: 3ec17c7386ee9bd519b64b65443ea90d6546a9a3 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -115,6 +115,10 @@ ZEND_END_ARG_INFO() #define arginfo_zend_object_sdtClass_or_null_slow_zpp arginfo_zend_bool +#define arginfo_zend_obj_sdtClass arginfo_zend_bool + +#define arginfo_zend_obj_sdtClass_or_null arginfo_zend_bool + #define arginfo_zend_resource arginfo_zend_bool #define arginfo_zend_resource_or_null arginfo_zend_bool @@ -380,6 +384,8 @@ static ZEND_FUNCTION(zend_object_sdtClass); static ZEND_FUNCTION(zend_object_sdtClass_or_null); static ZEND_FUNCTION(zend_object_sdtClass_slow_zpp); static ZEND_FUNCTION(zend_object_sdtClass_or_null_slow_zpp); +static ZEND_FUNCTION(zend_obj_sdtClass); +static ZEND_FUNCTION(zend_obj_sdtClass_or_null); static ZEND_FUNCTION(zend_resource); static ZEND_FUNCTION(zend_resource_or_null); static ZEND_FUNCTION(zend_resource_slow_zpp); @@ -524,6 +530,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_object_sdtClass_or_null, arginfo_zend_object_sdtClass_or_null) ZEND_FE(zend_object_sdtClass_slow_zpp, arginfo_zend_object_sdtClass_slow_zpp) ZEND_FE(zend_object_sdtClass_or_null_slow_zpp, arginfo_zend_object_sdtClass_or_null_slow_zpp) + ZEND_FE(zend_obj_sdtClass, arginfo_zend_obj_sdtClass) + ZEND_FE(zend_obj_sdtClass_or_null, arginfo_zend_obj_sdtClass_or_null) ZEND_FE(zend_resource, arginfo_zend_resource) ZEND_FE(zend_resource_or_null, arginfo_zend_resource_or_null) ZEND_FE(zend_resource_slow_zpp, arginfo_zend_resource_slow_zpp) diff --git a/ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..b337a74d6a8e --- /dev/null +++ b/ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt @@ -0,0 +1,192 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS() and Z_PARAM_OBJ_OF_CLASS_OR_NULL() (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object_sdtClass($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object_sdtClass($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +Using false: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +Using true: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +Using 42: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +Using 73.5: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +Using 'string': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '15': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '56.7': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using 'stdClass': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using anon class name: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using []: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +Using STDOUT: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given diff --git a/ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..cbd0d6ffeee7 --- /dev/null +++ b/ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt @@ -0,0 +1,190 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS() and Z_PARAM_OBJ_OF_CLASS_OR_NULL() (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object_sdtClass($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object_sdtClass($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +Using false: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +Using true: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +Using 42: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +Using 73.5: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +Using 'string': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '15': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '56.7': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using 'stdClass': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using anon class name: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using []: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +Using STDOUT: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given From efddc236f911c29d0e38769093d88110cd27976f Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 13 Aug 2026 13:16:59 +0100 Subject: [PATCH 21/23] Improve testing of Z_PARAM_OBJ_OF_CLASS_OR_STR --- ext/zend_test/test.c | 70 +++++++++--------- ext/zend_test/test.stub.php | 7 +- ext/zend_test/test_arginfo.h | 18 ++--- ext/zend_test/test_decl.h | 8 +-- ext/zend_test/test_legacy_arginfo.h | 14 ++-- .../obj_of_class_or_str_zpp_strict_mode.phpt | 71 +++++++++++++++++++ ...=> obj_of_class_or_str_zpp_weak_mode.phpt} | 16 ++--- 7 files changed, 135 insertions(+), 69 deletions(-) create mode 100644 ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt rename ext/zend_test/tests/zpp/{str_or_obj_of_class_zpp.phpt => obj_of_class_or_str_zpp_weak_mode.phpt} (58%) diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 3ff76b947666..49af88e35474 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -657,6 +657,40 @@ static ZEND_FUNCTION(zend_obj_sdtClass_or_null) RETURN_OBJ_COPY(v); } +static ZEND_FUNCTION(zend_obj_stdclass_or_string) +{ + zend_string *str; + zend_object *object; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OF_CLASS_OR_STR(object, zend_standard_class_def, str) + ZEND_PARSE_PARAMETERS_END(); + + if (str) { + RETURN_STR_COPY(str); + } else { + RETURN_OBJ_COPY(object); + } +} + +static ZEND_FUNCTION(zend_obj_stdclass_or_string_or_null) +{ + zend_string *str; + zend_object *object; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL(object, zend_standard_class_def, str) + ZEND_PARSE_PARAMETERS_END(); + + if (str) { + RETURN_STR_COPY(str); + } else if (object) { + RETURN_OBJ_COPY(object); + } else { + RETURN_NULL(); + } +} + static ZEND_FUNCTION(zend_resource) { zval *v; @@ -743,42 +777,6 @@ static ZEND_FUNCTION(zend_string_or_object_or_null) } } -/* Tests Z_PARAM_OBJ_OF_CLASS_OR_STR */ -static ZEND_FUNCTION(zend_string_or_stdclass) -{ - zend_string *str; - zend_object *object; - - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJ_OF_CLASS_OR_STR(object, zend_standard_class_def, str) - ZEND_PARSE_PARAMETERS_END(); - - if (str) { - RETURN_STR_COPY(str); - } else { - RETURN_OBJ_COPY(object); - } -} - -/* Tests Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL */ -static ZEND_FUNCTION(zend_string_or_stdclass_or_null) -{ - zend_string *str; - zend_object *object; - - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL(object, zend_standard_class_def, str) - ZEND_PARSE_PARAMETERS_END(); - - if (str) { - RETURN_STR_COPY(str); - } else if (object) { - RETURN_OBJ_COPY(object); - } else { - RETURN_NULL(); - } -} - /* Tests Z_PARAM_NUMBER_OR_STR */ static ZEND_FUNCTION(zend_number_or_string) { diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 26185c959dcd..738f8ec1e25d 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -368,11 +368,8 @@ function zend_string_or_object(object|string $param): object|string {} function zend_string_or_object_or_null(object|string|null $param): object|string|null {} - /** @param stdClass|string $param */ - function zend_string_or_stdclass($param): stdClass|string {} - - /** @param stdClass|string|null $param */ - function zend_string_or_stdclass_or_null($param): stdClass|string|null {} + function zend_obj_stdclass_or_string(stdClass|string|null $param): stdClass|string {} + function zend_obj_stdclass_or_string_or_null(stdClass|string|null $param): stdClass|string|null {} function zend_number_or_string(string|int|float $param): string|int|float {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 9c9fa05fc3e7..f5e4057578e2 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 3ec17c7386ee9bd519b64b65443ea90d6546a9a3 + * Stub hash: 01451f7b0c0e673c67e06a79f102f14229c67737 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -171,12 +171,12 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_string_or_object_or_null, 0 ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING|MAY_BE_NULL, NULL) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_string_or_stdclass, 0, 1, stdClass, MAY_BE_STRING) - ZEND_ARG_INFO(0, param) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_obj_stdclass_or_string, 0, 1, stdClass, MAY_BE_STRING) + ZEND_ARG_OBJ_TYPE_MASK(0, param, stdClass, MAY_BE_STRING|MAY_BE_NULL, NULL) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_string_or_stdclass_or_null, 0, 1, stdClass, MAY_BE_STRING|MAY_BE_NULL) - ZEND_ARG_INFO(0, param) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_obj_stdclass_or_string_or_null, 0, 1, stdClass, MAY_BE_STRING|MAY_BE_NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, param, stdClass, MAY_BE_STRING|MAY_BE_NULL, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_number_or_string, 0, 1, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_DOUBLE) @@ -463,8 +463,8 @@ static ZEND_FUNCTION(zend_resource_slow_zpp); static ZEND_FUNCTION(zend_resource_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); -static ZEND_FUNCTION(zend_string_or_stdclass); -static ZEND_FUNCTION(zend_string_or_stdclass_or_null); +static ZEND_FUNCTION(zend_obj_stdclass_or_string); +static ZEND_FUNCTION(zend_obj_stdclass_or_string_or_null); static ZEND_FUNCTION(zend_number_or_string); static ZEND_FUNCTION(zend_number_or_string_or_null); static ZEND_FUNCTION(zend_iterable); @@ -637,8 +637,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_resource_or_null_slow_zpp, arginfo_zend_resource_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) - ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) - ZEND_FE(zend_string_or_stdclass_or_null, arginfo_zend_string_or_stdclass_or_null) + ZEND_FE(zend_obj_stdclass_or_string, arginfo_zend_obj_stdclass_or_string) + ZEND_FE(zend_obj_stdclass_or_string_or_null, arginfo_zend_obj_stdclass_or_string_or_null) ZEND_FE(zend_number_or_string, arginfo_zend_number_or_string) ZEND_FE(zend_number_or_string_or_null, arginfo_zend_number_or_string_or_null) ZEND_FE(zend_iterable, arginfo_zend_iterable) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index 318d4b57d2c3..1f56d2673d45 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 3ec17c7386ee9bd519b64b65443ea90d6546a9a3 */ + * Stub hash: 01451f7b0c0e673c67e06a79f102f14229c67737 */ -#ifndef ZEND_TEST_DECL_3ec17c7386ee9bd519b64b65443ea90d6546a9a3_H -#define ZEND_TEST_DECL_3ec17c7386ee9bd519b64b65443ea90d6546a9a3_H +#ifndef ZEND_TEST_DECL_01451f7b0c0e673c67e06a79f102f14229c67737_H +#define ZEND_TEST_DECL_01451f7b0c0e673c67e06a79f102f14229c67737_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_3ec17c7386ee9bd519b64b65443ea90d6546a9a3_H */ +#endif /* ZEND_TEST_DECL_01451f7b0c0e673c67e06a79f102f14229c67737_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index 1262bfa25612..54d8ba2c0abd 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 3ec17c7386ee9bd519b64b65443ea90d6546a9a3 + * Stub hash: 01451f7b0c0e673c67e06a79f102f14229c67737 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -131,9 +131,9 @@ ZEND_END_ARG_INFO() #define arginfo_zend_string_or_object_or_null arginfo_zend_bool -#define arginfo_zend_string_or_stdclass arginfo_zend_bool +#define arginfo_zend_obj_stdclass_or_string arginfo_zend_bool -#define arginfo_zend_string_or_stdclass_or_null arginfo_zend_bool +#define arginfo_zend_obj_stdclass_or_string_or_null arginfo_zend_bool #define arginfo_zend_number_or_string arginfo_zend_bool @@ -392,8 +392,8 @@ static ZEND_FUNCTION(zend_resource_slow_zpp); static ZEND_FUNCTION(zend_resource_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); -static ZEND_FUNCTION(zend_string_or_stdclass); -static ZEND_FUNCTION(zend_string_or_stdclass_or_null); +static ZEND_FUNCTION(zend_obj_stdclass_or_string); +static ZEND_FUNCTION(zend_obj_stdclass_or_string_or_null); static ZEND_FUNCTION(zend_number_or_string); static ZEND_FUNCTION(zend_number_or_string_or_null); static ZEND_FUNCTION(zend_iterable); @@ -538,8 +538,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_resource_or_null_slow_zpp, arginfo_zend_resource_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) - ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) - ZEND_FE(zend_string_or_stdclass_or_null, arginfo_zend_string_or_stdclass_or_null) + ZEND_FE(zend_obj_stdclass_or_string, arginfo_zend_obj_stdclass_or_string) + ZEND_FE(zend_obj_stdclass_or_string_or_null, arginfo_zend_obj_stdclass_or_string_or_null) ZEND_FE(zend_number_or_string, arginfo_zend_number_or_string) ZEND_FE(zend_number_or_string_or_null, arginfo_zend_number_or_string_or_null) ZEND_FE(zend_iterable, arginfo_zend_iterable) diff --git a/ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt b/ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt new file mode 100644 index 000000000000..8a216dadbc40 --- /dev/null +++ b/ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt @@ -0,0 +1,71 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS_OR_STR() and Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_stdclass_or_string($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_stdclass_or_string_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, null given +NULL +Using false: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, false given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, false given +Using true: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, true given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, true given +Using 42: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, int given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, int given +Using 73.5: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, float given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, float given +Using 'string': +string(6) "string" +string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, array given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, S given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, S given +Using STDOUT: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, resource given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, resource given diff --git a/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt b/ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt similarity index 58% rename from ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt rename to ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt index 428bef0baa6a..be0dcbc74969 100644 --- a/ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt +++ b/ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt @@ -1,5 +1,5 @@ --TEST-- -Test Z_PARAM_OBJ_OF_CLASS_OR_STR() and Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL +Test Z_PARAM_OBJ_OF_CLASS_OR_STR() and Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL (weak_mode) --EXTENSIONS-- zend_test --FILE-- @@ -10,12 +10,12 @@ $types = require 'types.inc'; foreach ($types as $name => $type) { echo "Using $name:\n"; try { - var_dump(zend_string_or_stdclass($type)); + var_dump(zend_obj_stdclass_or_string($type)); } catch (Throwable $e) { echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { - var_dump(zend_string_or_stdclass_or_null($type)); + var_dump(zend_obj_stdclass_or_string_or_null($type)); } catch (Throwable $e) { echo $e::class, ': ', $e->getMessage(), PHP_EOL; } @@ -25,7 +25,7 @@ foreach ($types as $name => $type) { --EXPECTF-- Using null: -Deprecated: zend_string_or_stdclass(): Passing null to parameter #1 ($param) of type string is deprecated in %s on line %d +Deprecated: zend_obj_stdclass_or_string(): Passing null to parameter #1 ($param) of type stdClass|string|null is deprecated in %s on line %d string(0) "" NULL Using false: @@ -56,8 +56,8 @@ Using anon class name: string(%d) "class@anonymous%s" string(%d) "class@anonymous%s" Using []: -TypeError: zend_string_or_stdclass(): Argument #1 ($param) must be of type stdClass|string, array given -TypeError: zend_string_or_stdclass_or_null(): Argument #1 ($param) must be of type stdClass|string|null, array given +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, array given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, array given Using new stdClass(): object(stdClass)#2 (0) { } @@ -67,5 +67,5 @@ Using new S(): string(7) "S class" string(7) "S class" Using STDOUT: -TypeError: zend_string_or_stdclass(): Argument #1 ($param) must be of type stdClass|string, resource given -TypeError: zend_string_or_stdclass_or_null(): Argument #1 ($param) must be of type stdClass|string|null, resource given +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, resource given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, resource given From 6e723f29b7e62c43f188e3c7bf446158e36d3346 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 13 Aug 2026 13:24:25 +0100 Subject: [PATCH 22/23] zend_test: add Z_PARAM_OBJ_OF_CLASS_OR_LONG ZPP specifier test --- ext/zend_test/test.c | 35 ++++++++ ext/zend_test/test.stub.php | 3 + ext/zend_test/test_arginfo.h | 14 +++- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 10 ++- .../obj_of_class_or_int_zpp_strict_mode.phpt | 71 +++++++++++++++++ .../obj_of_class_or_int_zpp_weak_mode.phpt | 79 +++++++++++++++++++ 7 files changed, 214 insertions(+), 6 deletions(-) create mode 100644 ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt create mode 100644 ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 49af88e35474..82bfa8d38e33 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -691,6 +691,41 @@ static ZEND_FUNCTION(zend_obj_stdclass_or_string_or_null) } } +static ZEND_FUNCTION(zend_obj_stdclass_or_int) +{ + zend_long l; + zend_object *object; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OF_CLASS_OR_LONG(object, zend_standard_class_def, l) + ZEND_PARSE_PARAMETERS_END(); + + if (object) { + RETURN_OBJ_COPY(object); + } else { + RETURN_LONG(l); + } +} + +static ZEND_FUNCTION(zend_obj_stdclass_or_int_or_null) +{ + zend_long l; + zend_object *object; + bool is_null; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OF_CLASS_OR_LONG_OR_NULL(object, zend_standard_class_def, l, is_null) + ZEND_PARSE_PARAMETERS_END(); + + if (is_null) { + RETURN_NULL(); + } else if (object) { + RETURN_OBJ_COPY(object); + } else { + RETURN_LONG(l); + } +} + static ZEND_FUNCTION(zend_resource) { zval *v; diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 738f8ec1e25d..3c09668bddb1 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -371,6 +371,9 @@ function zend_string_or_object_or_null(object|string|null $param): object|string function zend_obj_stdclass_or_string(stdClass|string|null $param): stdClass|string {} function zend_obj_stdclass_or_string_or_null(stdClass|string|null $param): stdClass|string|null {} + function zend_obj_stdclass_or_int(stdClass|int|null $param): stdClass|int {} + function zend_obj_stdclass_or_int_or_null(stdClass|int|null $param): stdClass|int|null {} + function zend_number_or_string(string|int|float $param): string|int|float {} function zend_number_or_string_or_null(string|int|float|null $param): string|int|float|null {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index f5e4057578e2..93fdadb7f6b2 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 01451f7b0c0e673c67e06a79f102f14229c67737 + * Stub hash: 4d728e740122add9d4c91f5c1abb5f5017690636 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -179,6 +179,14 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_obj_stdclass_or_string_ ZEND_ARG_OBJ_TYPE_MASK(0, param, stdClass, MAY_BE_STRING|MAY_BE_NULL, NULL) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_obj_stdclass_or_int, 0, 1, stdClass, MAY_BE_LONG) + ZEND_ARG_OBJ_TYPE_MASK(0, param, stdClass, MAY_BE_LONG|MAY_BE_NULL, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_obj_stdclass_or_int_or_null, 0, 1, stdClass, MAY_BE_LONG|MAY_BE_NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, param, stdClass, MAY_BE_LONG|MAY_BE_NULL, NULL) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_number_or_string, 0, 1, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_DOUBLE) ZEND_ARG_TYPE_MASK(0, param, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_DOUBLE, NULL) ZEND_END_ARG_INFO() @@ -465,6 +473,8 @@ static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_obj_stdclass_or_string); static ZEND_FUNCTION(zend_obj_stdclass_or_string_or_null); +static ZEND_FUNCTION(zend_obj_stdclass_or_int); +static ZEND_FUNCTION(zend_obj_stdclass_or_int_or_null); static ZEND_FUNCTION(zend_number_or_string); static ZEND_FUNCTION(zend_number_or_string_or_null); static ZEND_FUNCTION(zend_iterable); @@ -639,6 +649,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_obj_stdclass_or_string, arginfo_zend_obj_stdclass_or_string) ZEND_FE(zend_obj_stdclass_or_string_or_null, arginfo_zend_obj_stdclass_or_string_or_null) + ZEND_FE(zend_obj_stdclass_or_int, arginfo_zend_obj_stdclass_or_int) + ZEND_FE(zend_obj_stdclass_or_int_or_null, arginfo_zend_obj_stdclass_or_int_or_null) ZEND_FE(zend_number_or_string, arginfo_zend_number_or_string) ZEND_FE(zend_number_or_string_or_null, arginfo_zend_number_or_string_or_null) ZEND_FE(zend_iterable, arginfo_zend_iterable) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index 1f56d2673d45..7e41dc18eabb 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 01451f7b0c0e673c67e06a79f102f14229c67737 */ + * Stub hash: 4d728e740122add9d4c91f5c1abb5f5017690636 */ -#ifndef ZEND_TEST_DECL_01451f7b0c0e673c67e06a79f102f14229c67737_H -#define ZEND_TEST_DECL_01451f7b0c0e673c67e06a79f102f14229c67737_H +#ifndef ZEND_TEST_DECL_4d728e740122add9d4c91f5c1abb5f5017690636_H +#define ZEND_TEST_DECL_4d728e740122add9d4c91f5c1abb5f5017690636_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_01451f7b0c0e673c67e06a79f102f14229c67737_H */ +#endif /* ZEND_TEST_DECL_4d728e740122add9d4c91f5c1abb5f5017690636_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index 54d8ba2c0abd..479a678df778 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: 01451f7b0c0e673c67e06a79f102f14229c67737 + * Stub hash: 4d728e740122add9d4c91f5c1abb5f5017690636 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -135,6 +135,10 @@ ZEND_END_ARG_INFO() #define arginfo_zend_obj_stdclass_or_string_or_null arginfo_zend_bool +#define arginfo_zend_obj_stdclass_or_int arginfo_zend_bool + +#define arginfo_zend_obj_stdclass_or_int_or_null arginfo_zend_bool + #define arginfo_zend_number_or_string arginfo_zend_bool #define arginfo_zend_number_or_string_or_null arginfo_zend_bool @@ -394,6 +398,8 @@ static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); static ZEND_FUNCTION(zend_obj_stdclass_or_string); static ZEND_FUNCTION(zend_obj_stdclass_or_string_or_null); +static ZEND_FUNCTION(zend_obj_stdclass_or_int); +static ZEND_FUNCTION(zend_obj_stdclass_or_int_or_null); static ZEND_FUNCTION(zend_number_or_string); static ZEND_FUNCTION(zend_number_or_string_or_null); static ZEND_FUNCTION(zend_iterable); @@ -540,6 +546,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) ZEND_FE(zend_obj_stdclass_or_string, arginfo_zend_obj_stdclass_or_string) ZEND_FE(zend_obj_stdclass_or_string_or_null, arginfo_zend_obj_stdclass_or_string_or_null) + ZEND_FE(zend_obj_stdclass_or_int, arginfo_zend_obj_stdclass_or_int) + ZEND_FE(zend_obj_stdclass_or_int_or_null, arginfo_zend_obj_stdclass_or_int_or_null) ZEND_FE(zend_number_or_string, arginfo_zend_number_or_string) ZEND_FE(zend_number_or_string_or_null, arginfo_zend_number_or_string_or_null) ZEND_FE(zend_iterable, arginfo_zend_iterable) diff --git a/ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt b/ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt new file mode 100644 index 000000000000..360160d4845b --- /dev/null +++ b/ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt @@ -0,0 +1,71 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS_OR_LONG() and Z_PARAM_OBJ_OF_CLASS_OR_LONG_OR_NULL() (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_stdclass_or_int($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_stdclass_or_int_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, null given +NULL +Using false: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, false given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, false given +Using true: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, true given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, true given +Using 42: +int(42) +int(42) +Using 73.5: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, float given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, float given +Using 'string': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using '15': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using '56.7': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using 'stdClass': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using anon class name: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using []: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, array given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, S given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, S given +Using STDOUT: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, resource given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, resource given diff --git a/ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt b/ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt new file mode 100644 index 000000000000..6322c56ddf6a --- /dev/null +++ b/ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS_OR_LONG() and Z_PARAM_OBJ_OF_CLASS_OR_LONG_OR_NULL() (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_stdclass_or_int($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_stdclass_or_int_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_obj_stdclass_or_int(): Passing null to parameter #1 ($param) of type stdClass|int|null is deprecated in %s on line %d +int(0) +NULL +Using false: +int(0) +int(0) +Using true: +int(1) +int(1) +Using 42: +int(42) +int(42) +Using 73.5: + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) +Using 'string': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using '15': +int(15) +int(15) +Using '56.7': + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) +Using 'stdClass': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using anon class name: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using []: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, array given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, S given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, S given +Using STDOUT: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, resource given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, resource given From edaab1a6dd4a5e78ad022f7a47b23d6ef038fbf1 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 13 Aug 2026 13:42:38 +0100 Subject: [PATCH 23/23] Move ZPP tests to Zend/ --- .../tests/zpp/bool_zpp_specifier_strict_mode.phpt | 0 .../tests/zpp/bool_zpp_specifier_weak_mode.phpt | 0 .../tests/zpp/class-string_zpp_specifier_strict_mode.phpt | 0 .../tests/zpp/class-string_zpp_specifier_weak_mode.phpt | 0 .../tests/zpp/float_zpp_specifier_strict_mode.phpt | 0 .../tests/zpp/float_zpp_specifier_weak_mode.phpt | 0 .../tests/zpp/int_zpp_specifier_strict_mode.phpt | 0 .../zend_test => Zend}/tests/zpp/int_zpp_specifier_weak_mode.phpt | 0 {ext/zend_test => Zend}/tests/zpp/iterable_or_null.phpt | 0 .../tests/zpp/number_or_str_zpp_strict_mode.phpt | 0 .../zend_test => Zend}/tests/zpp/number_or_str_zpp_weak_mode.phpt | 0 .../tests/zpp/number_zpp_specifier_strict_mode.phpt | 0 .../tests/zpp/number_zpp_specifier_weak_mode.phpt | 0 .../tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt | 0 .../tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt | 0 .../tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt | 0 .../tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt | 0 .../tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt | 0 .../tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt | 0 .../tests/zpp/obj_or_class_name_zpp_strict_mode.phpt | 0 .../tests/zpp/obj_or_class_name_zpp_weak_mode.phpt | 0 {ext/zend_test => Zend}/tests/zpp/obj_or_str_zpp_strict_mode.phpt | 0 {ext/zend_test => Zend}/tests/zpp/obj_or_str_zpp_weak_mode.phpt | 0 .../tests/zpp/obj_zpp_specifier_strict_mode.phpt | 0 .../zend_test => Zend}/tests/zpp/obj_zpp_specifier_weak_mode.phpt | 0 .../tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt | 0 .../tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt | 0 .../tests/zpp/object_zpp_specifier_strict_mode.phpt | 0 .../tests/zpp/object_zpp_specifier_weak_mode.phpt | 0 .../tests/zpp/resource_zpp_specifier_strict_mode.phpt | 0 .../tests/zpp/resource_zpp_specifier_weak_mode.phpt | 0 {ext/zend_test => Zend}/tests/zpp/types.inc | 0 32 files changed, 0 insertions(+), 0 deletions(-) rename {ext/zend_test => Zend}/tests/zpp/bool_zpp_specifier_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/bool_zpp_specifier_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/class-string_zpp_specifier_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/class-string_zpp_specifier_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/float_zpp_specifier_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/float_zpp_specifier_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/int_zpp_specifier_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/int_zpp_specifier_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/iterable_or_null.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/number_or_str_zpp_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/number_or_str_zpp_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/number_zpp_specifier_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/number_zpp_specifier_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_or_str_zpp_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_or_str_zpp_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_zpp_specifier_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/obj_zpp_specifier_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/object_zpp_specifier_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/object_zpp_specifier_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/resource_zpp_specifier_strict_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/resource_zpp_specifier_weak_mode.phpt (100%) rename {ext/zend_test => Zend}/tests/zpp/types.inc (100%) diff --git a/ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/bool_zpp_specifier_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt rename to Zend/tests/zpp/bool_zpp_specifier_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/bool_zpp_specifier_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt rename to Zend/tests/zpp/bool_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/class-string_zpp_specifier_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt rename to Zend/tests/zpp/class-string_zpp_specifier_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/class-string_zpp_specifier_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt rename to Zend/tests/zpp/class-string_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/float_zpp_specifier_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt rename to Zend/tests/zpp/float_zpp_specifier_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/float_zpp_specifier_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt rename to Zend/tests/zpp/float_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/int_zpp_specifier_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt rename to Zend/tests/zpp/int_zpp_specifier_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/int_zpp_specifier_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt rename to Zend/tests/zpp/int_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/iterable_or_null.phpt b/Zend/tests/zpp/iterable_or_null.phpt similarity index 100% rename from ext/zend_test/tests/zpp/iterable_or_null.phpt rename to Zend/tests/zpp/iterable_or_null.phpt diff --git a/ext/zend_test/tests/zpp/number_or_str_zpp_strict_mode.phpt b/Zend/tests/zpp/number_or_str_zpp_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/number_or_str_zpp_strict_mode.phpt rename to Zend/tests/zpp/number_or_str_zpp_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/number_or_str_zpp_weak_mode.phpt b/Zend/tests/zpp/number_or_str_zpp_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/number_or_str_zpp_weak_mode.phpt rename to Zend/tests/zpp/number_or_str_zpp_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/number_zpp_specifier_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt rename to Zend/tests/zpp/number_zpp_specifier_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/number_zpp_specifier_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt rename to Zend/tests/zpp/number_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt b/Zend/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt rename to Zend/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt b/Zend/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt rename to Zend/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt b/Zend/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt rename to Zend/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt b/Zend/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt rename to Zend/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt rename to Zend/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt rename to Zend/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt b/Zend/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt rename to Zend/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt b/Zend/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt rename to Zend/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_or_str_zpp_strict_mode.phpt b/Zend/tests/zpp/obj_or_str_zpp_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_or_str_zpp_strict_mode.phpt rename to Zend/tests/zpp/obj_or_str_zpp_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_or_str_zpp_weak_mode.phpt b/Zend/tests/zpp/obj_or_str_zpp_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_or_str_zpp_weak_mode.phpt rename to Zend/tests/zpp/obj_or_str_zpp_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/obj_zpp_specifier_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_zpp_specifier_strict_mode.phpt rename to Zend/tests/zpp/obj_zpp_specifier_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/obj_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/obj_zpp_specifier_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/obj_zpp_specifier_weak_mode.phpt rename to Zend/tests/zpp/obj_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt rename to Zend/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt rename to Zend/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/object_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/object_zpp_specifier_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/object_zpp_specifier_strict_mode.phpt rename to Zend/tests/zpp/object_zpp_specifier_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/object_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/object_zpp_specifier_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/object_zpp_specifier_weak_mode.phpt rename to Zend/tests/zpp/object_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/resource_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/resource_zpp_specifier_strict_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/resource_zpp_specifier_strict_mode.phpt rename to Zend/tests/zpp/resource_zpp_specifier_strict_mode.phpt diff --git a/ext/zend_test/tests/zpp/resource_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/resource_zpp_specifier_weak_mode.phpt similarity index 100% rename from ext/zend_test/tests/zpp/resource_zpp_specifier_weak_mode.phpt rename to Zend/tests/zpp/resource_zpp_specifier_weak_mode.phpt diff --git a/ext/zend_test/tests/zpp/types.inc b/Zend/tests/zpp/types.inc similarity index 100% rename from ext/zend_test/tests/zpp/types.inc rename to Zend/tests/zpp/types.inc