From 7fa34ddd57919d2845a271100f63f68ba4f905f5 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 22:42:46 +0100 Subject: [PATCH 1/9] 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 cd28be3a925574ef1902d24dee8a47fbd27f6421 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 22:43:49 +0100 Subject: [PATCH 2/9] 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 174c9baa2714c7d8401ed4a6bbdd9622f0dcfbd6 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:34:55 +0100 Subject: [PATCH 3/9] 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: Sun, 9 Aug 2026 23:40:15 +0100 Subject: [PATCH 4/9] zend_test: use generic types file for other ZPP tests --- .../tests/zpp/number_or_str_zpp.phpt | 85 ++++++------------- .../tests/zpp/str_or_obj_of_class_zpp.phpt | 83 +++++++----------- ext/zend_test/tests/zpp/str_or_obj_zpp.phpt | 64 +++++++------- 3 files changed, 88 insertions(+), 144 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..de78e5add52a 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,41 @@ 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 $type) { + 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) - 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 int(0) +int(0) +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 +int(42) +int(42) +float(73.5) +float(73.5) +string(6) "string" +string(6) "string" +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 +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 +string(7) "S class" +string(7) "S class" +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..39b69e8b758a 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,43 @@ 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 $type) { + 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" - Deprecated: zend_string_or_stdclass(): Passing null to parameter #1 ($param) of type string is deprecated in %s on line %d string(0) "" +NULL +string(0) "" +string(0) "" +string(1) "1" +string(1) "1" +string(2) "42" +string(2) "42" +string(4) "73.5" +string(4) "73.5" +string(6) "string" +string(6) "string" +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 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 +string(7) "S class" +string(7) "S class" +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..0085095e75b2 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,45 @@ 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 $type) { + 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" - 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 +string(0) "" +string(0) "" +string(1) "1" +string(1) "1" +string(2) "42" +string(2) "42" +string(4) "73.5" +string(4) "73.5" +string(6) "string" +string(6) "string" +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 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) { +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 +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 c31cace3396b4fc773db44ee59e5b04f37285f0e Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:43:16 +0100 Subject: [PATCH 5/9] zend_test: add numeric strings --- .../tests/zpp/class-string_zpp_specifier_strict_mode.phpt | 2 ++ .../tests/zpp/class-string_zpp_specifier_weak_mode.phpt | 2 ++ ext/zend_test/tests/zpp/number_or_str_zpp.phpt | 4 ++++ ext/zend_test/tests/zpp/str_or_obj_of_class_zpp.phpt | 4 ++++ ext/zend_test/tests/zpp/str_or_obj_zpp.phpt | 4 ++++ ext/zend_test/tests/zpp/types.inc | 2 ++ 6 files changed, 18 insertions(+) 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..e3e17311132a 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 @@ -26,6 +26,8 @@ TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, int given TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, float given TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, string given +TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 15 given +TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 56.7 given TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, array given TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, stdClass given TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, S 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..33a4231bdcce 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 @@ -25,6 +25,8 @@ TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a v TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 42 given TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 73.5 given TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, string given +TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 15 given +TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 56.7 given TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, array given TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, stdClass given TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, S class 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 de78e5add52a..67035933536a 100644 --- a/ext/zend_test/tests/zpp/number_or_str_zpp.phpt +++ b/ext/zend_test/tests/zpp/number_or_str_zpp.phpt @@ -35,6 +35,10 @@ float(73.5) float(73.5) string(6) "string" string(6) "string" +string(2) "15" +string(2) "15" +string(4) "56.7" +string(4) "56.7" 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 TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, stdClass 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 39b69e8b758a..cb0f6025de61 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 @@ -35,6 +35,10 @@ string(4) "73.5" string(4) "73.5" string(6) "string" string(6) "string" +string(2) "15" +string(2) "15" +string(4) "56.7" +string(4) "56.7" 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 object(stdClass)#1 (0) { 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 0085095e75b2..449925b95031 100644 --- a/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt +++ b/ext/zend_test/tests/zpp/str_or_obj_zpp.phpt @@ -35,6 +35,10 @@ string(4) "73.5" string(4) "73.5" string(6) "string" string(6) "string" +string(2) "15" +string(2) "15" +string(4) "56.7" +string(4) "56.7" 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 object(stdClass)#1 (0) { diff --git a/ext/zend_test/tests/zpp/types.inc b/ext/zend_test/tests/zpp/types.inc index e3918a8d2e20..ea78437baf19 100644 --- a/ext/zend_test/tests/zpp/types.inc +++ b/ext/zend_test/tests/zpp/types.inc @@ -13,6 +13,8 @@ return [ 42, 73.5, 'string', + '15', + '56.7', [], new stdClass(), new S(), From b2ce869fd65c345d8c1b8089863f97b257affe44 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 22:56:39 +0100 Subject: [PATCH 6/9] 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 | 153 +++++++++++++++++ .../zpp/bool_zpp_specifier_weak_mode.phpt | 158 ++++++++++++++++++ 7 files changed, 416 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..74d7c3749e9d --- /dev/null +++ b/ext/zend_test/tests/zpp/bool_zpp_specifier_strict_mode.phpt @@ -0,0 +1,153 @@ +--TEST-- +Test bool ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- +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-- +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 +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +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 +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 +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 +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 +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 +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 +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 +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 +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..55822ef721e4 --- /dev/null +++ b/ext/zend_test/tests/zpp/bool_zpp_specifier_weak_mode.phpt @@ -0,0 +1,158 @@ +--TEST-- +Test bool ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- +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-- +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 +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +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 +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 +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 +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 8f9684dc2bb425f770a3091b9c9c7b91065c8e30 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:01:55 +0100 Subject: [PATCH 7/9] 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 | 153 ++++++++++++++ .../zpp/int_zpp_specifier_weak_mode.phpt | 190 ++++++++++++++++++ 7 files changed, 442 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..bb903fc3ce59 --- /dev/null +++ b/ext/zend_test/tests/zpp/int_zpp_specifier_strict_mode.phpt @@ -0,0 +1,153 @@ +--TEST-- +Test int ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- +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-- +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 +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 +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 +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +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 +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 +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 +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 +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 +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 +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 +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..0bdfb5426f98 --- /dev/null +++ b/ext/zend_test/tests/zpp/int_zpp_specifier_weak_mode.phpt @@ -0,0 +1,190 @@ +--TEST-- +Test int ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- +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-- +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 +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) + +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) +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 +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) + +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) +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 +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 +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 +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 de479d45a4e04c7f596ce983cc866e46f554e938 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:11:33 +0100 Subject: [PATCH 8/9] 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 | 153 +++++++++++++++++ .../zpp/float_zpp_specifier_weak_mode.phpt | 158 ++++++++++++++++++ 7 files changed, 410 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..9b8e62c4464a --- /dev/null +++ b/ext/zend_test/tests/zpp/float_zpp_specifier_strict_mode.phpt @@ -0,0 +1,153 @@ +--TEST-- +Test float ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- +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-- +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 +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 +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 +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +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 +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 +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 +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 +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 +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 +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..f3736cc483b6 --- /dev/null +++ b/ext/zend_test/tests/zpp/float_zpp_specifier_weak_mode.phpt @@ -0,0 +1,158 @@ +--TEST-- +Test float ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- +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-- +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 +float(0) +float(0) +float(0) +float(0) +float(0) +float(0) +float(0) +float(0) +float(1) +float(1) +float(1) +float(1) +float(1) +float(1) +float(1) +float(1) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +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 +float(15) +float(15) +float(15) +float(15) +float(15) +float(15) +float(15) +float(15) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +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 +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 +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 +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 b9a5e1e8fb6c36a03f525a26a3112be9d51ded62 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 9 Aug 2026 23:25:59 +0100 Subject: [PATCH 9/9] 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 | 153 +++++++++++++++++ .../zpp/number_zpp_specifier_weak_mode.phpt | 158 ++++++++++++++++++ 7 files changed, 408 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..6f1d40dd1acf --- /dev/null +++ b/ext/zend_test/tests/zpp/number_zpp_specifier_strict_mode.phpt @@ -0,0 +1,153 @@ +--TEST-- +Test bool ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- +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-- +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 +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 +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 +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +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 +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 +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 +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 +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 +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 +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..a5443b2df313 --- /dev/null +++ b/ext/zend_test/tests/zpp/number_zpp_specifier_weak_mode.phpt @@ -0,0 +1,158 @@ +--TEST-- +Test bool ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- +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-- +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 +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +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 +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +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 +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 +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 +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