From 308a24111074e1b8880d929339e36d85e7b2df8c Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Fri, 14 Aug 2026 16:06:35 +0100 Subject: [PATCH 1/7] Zend: write tests for some ZPP specifiers (#23192) This adds dedicated tests for ZPP specifiers with dedicated functions defined in ext/zend_test rather than using whatever function might be suitable, as it may get refactored. This covers the ZPP specifiers for "slow" and fast ZPP, including nullable, for: - `bool` - `int` - `float` - `int|float` - `int|float|string` (Fast ZPP only) - `resource` - `object` - `object|string` (Fast ZPP only) - Object of a class - Object of class OR int (Fast ZPP only) - Object of class OR string (Fast ZPP only) - Class name - Object OR class name Missing specifiers that are relagated to later are: - `array` - `array|object` - `array|int` - `array|string` - `callable` - `string` (including "path" checking for null bytes) - `string|int` - Enum - Zval - Variadics --- Zend/Optimizer/zend_func_infos.h | 4 + Zend/tests/number_or_str_zpp.phpt | 74 -- Zend/tests/str_or_obj_of_class_zpp.phpt | 70 -- Zend/tests/str_or_obj_zpp.phpt | 53 -- .../zpp/bool_zpp_specifier_strict_mode.phpt | 184 +++++ .../zpp/bool_zpp_specifier_weak_mode.phpt | 190 +++++ ...lass-string_zpp_specifier_strict_mode.phpt | 192 +++++ .../class-string_zpp_specifier_weak_mode.phpt | 194 +++++ .../zpp/float_zpp_specifier_strict_mode.phpt | 184 +++++ .../zpp/float_zpp_specifier_weak_mode.phpt | 190 +++++ .../zpp/int_zpp_specifier_strict_mode.phpt | 184 +++++ .../zpp/int_zpp_specifier_weak_mode.phpt | 222 ++++++ Zend/tests/{ => zpp}/iterable_or_null.phpt | 0 .../zpp/number_or_str_zpp_strict_mode.phpt | 69 ++ .../zpp/number_or_str_zpp_weak_mode.phpt | 69 ++ .../zpp/number_zpp_specifier_strict_mode.phpt | 184 +++++ .../zpp/number_zpp_specifier_weak_mode.phpt | 190 +++++ .../obj_of_class_or_int_zpp_strict_mode.phpt | 71 ++ .../obj_of_class_or_int_zpp_weak_mode.phpt | 79 +++ .../obj_of_class_or_str_zpp_strict_mode.phpt | 71 ++ .../obj_of_class_or_str_zpp_weak_mode.phpt | 71 ++ ...bj_of_class_zpp_specifier_strict_mode.phpt | 192 +++++ .../obj_of_class_zpp_specifier_weak_mode.phpt | 190 +++++ .../obj_or_class_name_zpp_strict_mode.phpt | 69 ++ .../zpp/obj_or_class_name_zpp_weak_mode.phpt | 67 ++ .../tests/zpp/obj_or_str_zpp_strict_mode.phpt | 73 ++ Zend/tests/zpp/obj_or_str_zpp_weak_mode.phpt | 73 ++ .../zpp/obj_zpp_specifier_strict_mode.phpt | 116 +++ .../zpp/obj_zpp_specifier_weak_mode.phpt | 114 +++ ...ct_of_class_zpp_specifier_strict_mode.phpt | 192 +++++ ...ject_of_class_zpp_specifier_weak_mode.phpt | 190 +++++ .../zpp/object_zpp_specifier_strict_mode.phpt | 200 ++++++ .../zpp/object_zpp_specifier_weak_mode.phpt | 198 ++++++ .../resource_zpp_specifier_strict_mode.phpt | 184 +++++ .../zpp/resource_zpp_specifier_weak_mode.phpt | 182 +++++ Zend/tests/zpp/types.inc | 26 + ext/zend_test/test.c | 662 ++++++++++++++++-- ext/zend_test/test.stub.php | 73 +- ext/zend_test/test_arginfo.h | 216 +++++- ext/zend_test/test_decl.h | 8 +- ext/zend_test/test_legacy_arginfo.h | 182 ++++- ...lass-string_zpp_specifier_strict_mode.phpt | 49 -- .../class-string_zpp_specifier_weak_mode.phpt | 48 -- 43 files changed, 5454 insertions(+), 395 deletions(-) delete mode 100644 Zend/tests/number_or_str_zpp.phpt delete mode 100644 Zend/tests/str_or_obj_of_class_zpp.phpt delete mode 100644 Zend/tests/str_or_obj_zpp.phpt create mode 100644 Zend/tests/zpp/bool_zpp_specifier_strict_mode.phpt create mode 100644 Zend/tests/zpp/bool_zpp_specifier_weak_mode.phpt create mode 100644 Zend/tests/zpp/class-string_zpp_specifier_strict_mode.phpt create mode 100644 Zend/tests/zpp/class-string_zpp_specifier_weak_mode.phpt create mode 100644 Zend/tests/zpp/float_zpp_specifier_strict_mode.phpt create mode 100644 Zend/tests/zpp/float_zpp_specifier_weak_mode.phpt create mode 100644 Zend/tests/zpp/int_zpp_specifier_strict_mode.phpt create mode 100644 Zend/tests/zpp/int_zpp_specifier_weak_mode.phpt rename Zend/tests/{ => zpp}/iterable_or_null.phpt (100%) create mode 100644 Zend/tests/zpp/number_or_str_zpp_strict_mode.phpt create mode 100644 Zend/tests/zpp/number_or_str_zpp_weak_mode.phpt create mode 100644 Zend/tests/zpp/number_zpp_specifier_strict_mode.phpt create mode 100644 Zend/tests/zpp/number_zpp_specifier_weak_mode.phpt create mode 100644 Zend/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt create mode 100644 Zend/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt create mode 100644 Zend/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt create mode 100644 Zend/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt create mode 100644 Zend/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt create mode 100644 Zend/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt create mode 100644 Zend/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt create mode 100644 Zend/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt create mode 100644 Zend/tests/zpp/obj_or_str_zpp_strict_mode.phpt create mode 100644 Zend/tests/zpp/obj_or_str_zpp_weak_mode.phpt create mode 100644 Zend/tests/zpp/obj_zpp_specifier_strict_mode.phpt create mode 100644 Zend/tests/zpp/obj_zpp_specifier_weak_mode.phpt create mode 100644 Zend/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt create mode 100644 Zend/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt create mode 100644 Zend/tests/zpp/object_zpp_specifier_strict_mode.phpt create mode 100644 Zend/tests/zpp/object_zpp_specifier_weak_mode.phpt create mode 100644 Zend/tests/zpp/resource_zpp_specifier_strict_mode.phpt create mode 100644 Zend/tests/zpp/resource_zpp_specifier_weak_mode.phpt create mode 100644 Zend/tests/zpp/types.inc delete mode 100644 ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt delete mode 100644 ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 88d012149beb..cfe758db7961 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -615,6 +615,10 @@ static const func_info_t func_infos[] = { F1("serialize", MAY_BE_STRING), F1("xml_error_string", MAY_BE_STRING|MAY_BE_NULL), F1("xml_parser_get_option", MAY_BE_STRING|MAY_BE_LONG|MAY_BE_BOOL), + FN("zend_resource", MAY_BE_RESOURCE), + FN("zend_resource_or_null", MAY_BE_RESOURCE|MAY_BE_NULL), + FN("zend_resource_slow_zpp", MAY_BE_RESOURCE), + FN("zend_resource_or_null_slow_zpp", MAY_BE_RESOURCE|MAY_BE_NULL), FN("zend_test_create_throwing_resource", MAY_BE_RESOURCE), FN("zip_open", MAY_BE_RESOURCE|MAY_BE_LONG|MAY_BE_FALSE), FN("zip_read", MAY_BE_RESOURCE|MAY_BE_FALSE), diff --git a/Zend/tests/number_or_str_zpp.phpt b/Zend/tests/number_or_str_zpp.phpt deleted file mode 100644 index 6ee47ec6f63d..000000000000 --- a/Zend/tests/number_or_str_zpp.phpt +++ /dev/null @@ -1,74 +0,0 @@ ---TEST-- -Test Z_PARAM_NUMBER_OR_STR() and Z_PARAM_NUMBER_OR_STR_OR_NULL ---EXTENSIONS-- -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"; -} - -?> ---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(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 diff --git a/Zend/tests/str_or_obj_of_class_zpp.phpt b/Zend/tests/str_or_obj_of_class_zpp.phpt deleted file mode 100644 index dec9bee69d5c..000000000000 --- a/Zend/tests/str_or_obj_of_class_zpp.phpt +++ /dev/null @@ -1,70 +0,0 @@ ---TEST-- -Test Z_PARAM_OBJ_OF_CLASS_OR_STR() and Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL ---EXTENSIONS-- -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"; -} - -?> ---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) "" -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 diff --git a/Zend/tests/str_or_obj_zpp.phpt b/Zend/tests/str_or_obj_zpp.phpt deleted file mode 100644 index 3c71bde5fd3a..000000000000 --- a/Zend/tests/str_or_obj_zpp.phpt +++ /dev/null @@ -1,53 +0,0 @@ ---TEST-- -Test Z_PARAM_OBJ_OR_STR() and Z_PARAM_OBJ_OR_STR_OR_NULL ---EXTENSIONS-- -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"; -} - -?> ---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) "" -object(stdClass)#1 (0) { -} -object(Foo)#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(Foo)#2 (0) { -} -zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, array given diff --git a/Zend/tests/zpp/bool_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/bool_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..49e056213e3a --- /dev/null +++ b/Zend/tests/zpp/bool_zpp_specifier_strict_mode.phpt @@ -0,0 +1,184 @@ +--TEST-- +Test bool ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_bool($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_bool($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, null given +NULL +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, null given +NULL +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, null given +NULL +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, null given +NULL +Using false: +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +Using true: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using 42: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, int given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, int given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, int given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, int given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, int given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, int given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, int given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, int given +Using 73.5: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, float given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, float given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, float given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, float given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, float given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, float given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, float given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, float given +Using 'string': +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +Using '15': +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +Using '56.7': +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +Using 'stdClass': +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +Using anon class name: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given +Using []: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, array given +Using new stdClass(): +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, stdClass given +Using new S(): +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, S given +Using STDOUT: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, resource given diff --git a/Zend/tests/zpp/bool_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/bool_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..705487f8ba73 --- /dev/null +++ b/Zend/tests/zpp/bool_zpp_specifier_weak_mode.phpt @@ -0,0 +1,190 @@ +--TEST-- +Test bool ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_bool($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_bool($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_bool_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_bool(): Passing null to parameter #1 ($param) of type bool is deprecated in %s on line %d +bool(false) +NULL + +Deprecated: zend_bool_slow_zpp(): Passing null to parameter #1 ($param) of type bool is deprecated in %s on line %d +bool(false) +NULL + +Deprecated: zend_bool(): Passing null to parameter #1 ($param) of type bool is deprecated in %s on line %d +bool(false) +NULL + +Deprecated: zend_bool_slow_zpp(): Passing null to parameter #1 ($param) of type bool is deprecated in %s on line %d +bool(false) +NULL +Using false: +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +Using true: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using 42: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using 73.5: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using 'string': +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using '15': +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using '56.7': +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using 'stdClass': +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using anon class name: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Using []: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, array given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, array given +Using new stdClass(): +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, stdClass given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, stdClass given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, stdClass given +Using new S(): +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, S given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, S given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, S given +Using STDOUT: +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, resource given +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, resource given +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, resource given diff --git a/Zend/tests/zpp/class-string_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/class-string_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..bdc48e27d4ad --- /dev/null +++ b/Zend/tests/zpp/class-string_zpp_specifier_strict_mode.phpt @@ -0,0 +1,192 @@ +--TEST-- +Test class string ZPP specifier +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_class_name($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_class_name($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, null given +NULL +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +NULL +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, null given +NULL +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +NULL +Using false: +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, false given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, false given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, false given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, false given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, given +Using true: +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, true given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, true given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 1 given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, true given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, true given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 1 given +Using 42: +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, int given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, int given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 42 given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, int given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, int given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 42 given +Using 73.5: +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, float given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, float given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 73.5 given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, float given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, float given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 73.5 given +Using 'string': +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, string given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, string given +Using '15': +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 15 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 15 given +Using '56.7': +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 56.7 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 56.7 given +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, array given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Array given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, array given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Array given +Using new stdClass(): +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, stdClass given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, stdClass given +Error: Object of class stdClass could not be converted to string +Error: Object of class stdClass could not be converted to string +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, stdClass given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, stdClass given +Error: Object of class stdClass could not be converted to string +Error: Object of class stdClass could not be converted to string +Using new S(): +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, S given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, S given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, S class given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, S given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, S given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, S class given +Using STDOUT: +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, resource given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, resource given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Resource id #2 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Resource id #2 given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, resource given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, resource given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Resource id #2 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Resource id #2 given diff --git a/Zend/tests/zpp/class-string_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/class-string_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..9341ecbb4102 --- /dev/null +++ b/Zend/tests/zpp/class-string_zpp_specifier_weak_mode.phpt @@ -0,0 +1,194 @@ +--TEST-- +Test class string ZPP specifier +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_class_name($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_class_name($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_class_name_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_class_name(): Passing null to parameter #1 ($param) of type string is deprecated in %s on line %d +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, given +NULL +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +NULL + +Deprecated: zend_class_name(): Passing null to parameter #1 ($param) of type string is deprecated in %s on line %d +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, given +NULL +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +NULL +Using false: +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, given +Using true: +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 1 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 1 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 1 given +Using 42: +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 42 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 42 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 42 given +Using 73.5: +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 73.5 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 73.5 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 73.5 given +Using 'string': +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, string given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, string given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, string given +Using '15': +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 15 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 15 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 15 given +Using '56.7': +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 56.7 given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, 56.7 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, 56.7 given +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, array given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Array given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, array given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Array given + +Warning: Array to string conversion in %s on line %d +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Array given +Using new stdClass(): +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, stdClass given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, stdClass given +Error: Object of class stdClass could not be converted to string +Error: Object of class stdClass could not be converted to string +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, stdClass given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, stdClass given +Error: Object of class stdClass could not be converted to string +Error: Object of class stdClass could not be converted to string +Using new S(): +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, S class given +TypeError: zend_class_name(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, S class given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, S class given +Using STDOUT: +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, resource given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, resource given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Resource id #2 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Resource id #2 given +TypeError: zend_class_name(): Argument #1 ($param) must be of type string, resource given +TypeError: zend_class_name_or_null(): Argument #1 ($param) must be of type ?string, resource given +TypeError: zend_class_name_slow_zpp(): Argument #1 ($param) must be a valid class name, Resource id #2 given +TypeError: zend_class_name_or_null_slow_zpp(): Argument #1 ($param) must be a valid class name or null, Resource id #2 given diff --git a/Zend/tests/zpp/float_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/float_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..2d316737b7cd --- /dev/null +++ b/Zend/tests/zpp/float_zpp_specifier_strict_mode.phpt @@ -0,0 +1,184 @@ +--TEST-- +Test float ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_float($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_float($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_float(): Argument #1 ($param) must be of type float, null given +NULL +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, null given +NULL +TypeError: zend_float(): Argument #1 ($param) must be of type float, null given +NULL +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, null given +NULL +Using false: +TypeError: zend_float(): Argument #1 ($param) must be of type float, false given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, false given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, false given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, false given +TypeError: zend_float(): Argument #1 ($param) must be of type float, false given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, false given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, false given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, false given +Using true: +TypeError: zend_float(): Argument #1 ($param) must be of type float, true given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, true given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, true given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, true given +TypeError: zend_float(): Argument #1 ($param) must be of type float, true given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, true given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, true given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, true given +Using 42: +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +Using 73.5: +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +Using 'string': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using '15': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using '56.7': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using 'stdClass': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using anon class name: +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using []: +TypeError: zend_float(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, array given +Using new stdClass(): +TypeError: zend_float(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, stdClass given +Using new S(): +TypeError: zend_float(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, S given +Using STDOUT: +TypeError: zend_float(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, resource given diff --git a/Zend/tests/zpp/float_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/float_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..1520e8055bd3 --- /dev/null +++ b/Zend/tests/zpp/float_zpp_specifier_weak_mode.phpt @@ -0,0 +1,190 @@ +--TEST-- +Test float ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_float($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_float($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_float_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_float(): Passing null to parameter #1 ($param) of type float is deprecated in %s on line %d +float(0) +NULL + +Deprecated: zend_float_slow_zpp(): Passing null to parameter #1 ($param) of type float is deprecated in %s on line %d +float(0) +NULL + +Deprecated: zend_float(): Passing null to parameter #1 ($param) of type float is deprecated in %s on line %d +float(0) +NULL + +Deprecated: zend_float_slow_zpp(): Passing null to parameter #1 ($param) of type float is deprecated in %s on line %d +float(0) +NULL +Using false: +float(0) +float(0) +float(0) +float(0) +float(0) +float(0) +float(0) +float(0) +Using true: +float(1) +float(1) +float(1) +float(1) +float(1) +float(1) +float(1) +float(1) +Using 42: +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +float(42) +Using 73.5: +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +Using 'string': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using '15': +float(15) +float(15) +float(15) +float(15) +float(15) +float(15) +float(15) +float(15) +Using '56.7': +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +Using 'stdClass': +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using anon class name: +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, string given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, string given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, string given +Using []: +TypeError: zend_float(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, array given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, array given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, array given +Using new stdClass(): +TypeError: zend_float(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, stdClass given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, stdClass given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, stdClass given +Using new S(): +TypeError: zend_float(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, S given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, S given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, S given +Using STDOUT: +TypeError: zend_float(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null(): Argument #1 ($param) must be of type ?float, resource given +TypeError: zend_float_slow_zpp(): Argument #1 ($param) must be of type float, resource given +TypeError: zend_float_or_null_slow_zpp(): Argument #1 ($param) must be of type ?float, resource given diff --git a/Zend/tests/zpp/int_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/int_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..58585c3656cd --- /dev/null +++ b/Zend/tests/zpp/int_zpp_specifier_strict_mode.phpt @@ -0,0 +1,184 @@ +--TEST-- +Test int ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_int($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_int($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_int(): Argument #1 ($param) must be of type int, null given +NULL +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, null given +NULL +TypeError: zend_int(): Argument #1 ($param) must be of type int, null given +NULL +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, null given +NULL +Using false: +TypeError: zend_int(): Argument #1 ($param) must be of type int, false given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, false given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, false given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, false given +TypeError: zend_int(): Argument #1 ($param) must be of type int, false given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, false given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, false given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, false given +Using true: +TypeError: zend_int(): Argument #1 ($param) must be of type int, true given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, true given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, true given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, true given +TypeError: zend_int(): Argument #1 ($param) must be of type int, true given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, true given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, true given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, true given +Using 42: +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +Using 73.5: +TypeError: zend_int(): Argument #1 ($param) must be of type int, float given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, float given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, float given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, float given +TypeError: zend_int(): Argument #1 ($param) must be of type int, float given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, float given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, float given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, float given +Using 'string': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using '15': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using '56.7': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using 'stdClass': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using anon class name: +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using []: +TypeError: zend_int(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, array given +Using new stdClass(): +TypeError: zend_int(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, stdClass given +Using new S(): +TypeError: zend_int(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, S given +Using STDOUT: +TypeError: zend_int(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, resource given diff --git a/Zend/tests/zpp/int_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/int_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..9258d6864355 --- /dev/null +++ b/Zend/tests/zpp/int_zpp_specifier_weak_mode.phpt @@ -0,0 +1,222 @@ +--TEST-- +Test int ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_int($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_int($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_int_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_int(): Passing null to parameter #1 ($param) of type int is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_int_slow_zpp(): Passing null to parameter #1 ($param) of type int is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_int(): Passing null to parameter #1 ($param) of type int is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_int_slow_zpp(): Passing null to parameter #1 ($param) of type int is deprecated in %s on line %d +int(0) +NULL +Using false: +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +Using true: +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +Using 42: +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +Using 73.5: + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) +Using 'string': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using '15': +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +Using '56.7': + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) +Using 'stdClass': +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using anon class name: +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, string given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, string given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, string given +Using []: +TypeError: zend_int(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, array given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, array given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, array given +Using new stdClass(): +TypeError: zend_int(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, stdClass given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, stdClass given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, stdClass given +Using new S(): +TypeError: zend_int(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, S given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, S given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, S given +Using STDOUT: +TypeError: zend_int(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null(): Argument #1 ($param) must be of type ?int, resource given +TypeError: zend_int_slow_zpp(): Argument #1 ($param) must be of type int, resource given +TypeError: zend_int_or_null_slow_zpp(): Argument #1 ($param) must be of type ?int, resource given diff --git a/Zend/tests/iterable_or_null.phpt b/Zend/tests/zpp/iterable_or_null.phpt similarity index 100% rename from Zend/tests/iterable_or_null.phpt rename to Zend/tests/zpp/iterable_or_null.phpt diff --git a/Zend/tests/zpp/number_or_str_zpp_strict_mode.phpt b/Zend/tests/zpp/number_or_str_zpp_strict_mode.phpt new file mode 100644 index 000000000000..15c616c37099 --- /dev/null +++ b/Zend/tests/zpp/number_or_str_zpp_strict_mode.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test Z_PARAM_NUMBER_OR_STR() and Z_PARAM_NUMBER_OR_STR_OR_NULL (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_number_or_string($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_string_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, null given +NULL +Using false: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, false given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, false given +Using true: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, true given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, true given +Using 42: +int(42) +int(42) +Using 73.5: +float(73.5) +float(73.5) +Using 'string': +string(6) "string" +string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, array given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, array given +Using new stdClass(): +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, stdClass given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, stdClass given +Using new S(): +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, S given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, S given +Using STDOUT: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, resource given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, resource given diff --git a/Zend/tests/zpp/number_or_str_zpp_weak_mode.phpt b/Zend/tests/zpp/number_or_str_zpp_weak_mode.phpt new file mode 100644 index 000000000000..f0a8985297fe --- /dev/null +++ b/Zend/tests/zpp/number_or_str_zpp_weak_mode.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test Z_PARAM_NUMBER_OR_STR() and Z_PARAM_NUMBER_OR_STR_OR_NULL (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_number_or_string($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_string_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +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) +NULL +Using false: +int(0) +int(0) +Using true: +int(1) +int(1) +Using 42: +int(42) +int(42) +Using 73.5: +float(73.5) +float(73.5) +Using 'string': +string(6) "string" +string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, array given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, array given +Using new stdClass(): +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, stdClass given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, stdClass given +Using new S(): +string(7) "S class" +string(7) "S class" +Using STDOUT: +TypeError: zend_number_or_string(): Argument #1 ($param) must be of type string|int|float, resource given +TypeError: zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, resource given diff --git a/Zend/tests/zpp/number_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/number_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..a91dd9f7b287 --- /dev/null +++ b/Zend/tests/zpp/number_zpp_specifier_strict_mode.phpt @@ -0,0 +1,184 @@ +--TEST-- +Test number ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_number($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_number($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, null given +NULL +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, null given +NULL +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, null given +NULL +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, null given +NULL +Using false: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, false given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, false given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, false given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, false given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, false given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, false given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, false given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, false given +Using true: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, true given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, true given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, true given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, true given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, true given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, true given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, true given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, true given +Using 42: +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +Using 73.5: +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +Using 'string': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using '15': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using '56.7': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using 'stdClass': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using anon class name: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using []: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, array given +Using new stdClass(): +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, stdClass given +Using new S(): +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, S given +Using STDOUT: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, resource given diff --git a/Zend/tests/zpp/number_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/number_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..2cdc710405ab --- /dev/null +++ b/Zend/tests/zpp/number_zpp_specifier_weak_mode.phpt @@ -0,0 +1,190 @@ +--TEST-- +Test number ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_number($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_number($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_number_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_number(): Passing null to parameter #1 ($param) of type int|float is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_number_slow_zpp(): Passing null to parameter #1 ($param) of type int|float is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_number(): Passing null to parameter #1 ($param) of type int|float is deprecated in %s on line %d +int(0) +NULL + +Deprecated: zend_number_slow_zpp(): Passing null to parameter #1 ($param) of type int|float is deprecated in %s on line %d +int(0) +NULL +Using false: +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +Using true: +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +Using 42: +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +int(42) +Using 73.5: +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +float(73.5) +Using 'string': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using '15': +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +int(15) +Using '56.7': +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +float(56.7) +Using 'stdClass': +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using anon class name: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, string given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, string given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, string given +Using []: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, array given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, array given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, array given +Using new stdClass(): +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, stdClass given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, stdClass given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, stdClass given +Using new S(): +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, S given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, S given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, S given +Using STDOUT: +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null(): Argument #1 ($param) must be of type int|float|null, resource given +TypeError: zend_number_slow_zpp(): Argument #1 ($param) must be of type int|float, resource given +TypeError: zend_number_or_null_slow_zpp(): Argument #1 ($param) must be of type int|float|null, resource given diff --git a/Zend/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt b/Zend/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt new file mode 100644 index 000000000000..360160d4845b --- /dev/null +++ b/Zend/tests/zpp/obj_of_class_or_int_zpp_strict_mode.phpt @@ -0,0 +1,71 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS_OR_LONG() and Z_PARAM_OBJ_OF_CLASS_OR_LONG_OR_NULL() (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_stdclass_or_int($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_stdclass_or_int_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, null given +NULL +Using false: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, false given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, false given +Using true: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, true given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, true given +Using 42: +int(42) +int(42) +Using 73.5: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, float given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, float given +Using 'string': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using '15': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using '56.7': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using 'stdClass': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using anon class name: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using []: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, array given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, S given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, S given +Using STDOUT: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, resource given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, resource given diff --git a/Zend/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt b/Zend/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt new file mode 100644 index 000000000000..6322c56ddf6a --- /dev/null +++ b/Zend/tests/zpp/obj_of_class_or_int_zpp_weak_mode.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS_OR_LONG() and Z_PARAM_OBJ_OF_CLASS_OR_LONG_OR_NULL() (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_stdclass_or_int($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_stdclass_or_int_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_obj_stdclass_or_int(): Passing null to parameter #1 ($param) of type stdClass|int|null is deprecated in %s on line %d +int(0) +NULL +Using false: +int(0) +int(0) +Using true: +int(1) +int(1) +Using 42: +int(42) +int(42) +Using 73.5: + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) + +Deprecated: Implicit conversion from float 73.5 to int loses precision in %s on line %d +int(73) +Using 'string': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using '15': +int(15) +int(15) +Using '56.7': + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) + +Deprecated: Implicit conversion from float-string "56.7" to int loses precision in %s on line %d +int(56) +Using 'stdClass': +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using anon class name: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given +Using []: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, array given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, S given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, S given +Using STDOUT: +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, resource given +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, resource given diff --git a/Zend/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt b/Zend/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt new file mode 100644 index 000000000000..8a216dadbc40 --- /dev/null +++ b/Zend/tests/zpp/obj_of_class_or_str_zpp_strict_mode.phpt @@ -0,0 +1,71 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS_OR_STR() and Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_stdclass_or_string($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_stdclass_or_string_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, null given +NULL +Using false: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, false given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, false given +Using true: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, true given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, true given +Using 42: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, int given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, int given +Using 73.5: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, float given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, float given +Using 'string': +string(6) "string" +string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, array given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, S given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, S given +Using STDOUT: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, resource given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, resource given diff --git a/Zend/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt b/Zend/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt new file mode 100644 index 000000000000..be0dcbc74969 --- /dev/null +++ b/Zend/tests/zpp/obj_of_class_or_str_zpp_weak_mode.phpt @@ -0,0 +1,71 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS_OR_STR() and Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_stdclass_or_string($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_stdclass_or_string_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_obj_stdclass_or_string(): Passing null to parameter #1 ($param) of type stdClass|string|null is deprecated in %s on line %d +string(0) "" +NULL +Using false: +string(0) "" +string(0) "" +Using true: +string(1) "1" +string(1) "1" +Using 42: +string(2) "42" +string(2) "42" +Using 73.5: +string(4) "73.5" +string(4) "73.5" +Using 'string': +string(6) "string" +string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, array given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +string(7) "S class" +string(7) "S class" +Using STDOUT: +TypeError: zend_obj_stdclass_or_string(): Argument #1 ($param) must be of type stdClass|string, resource given +TypeError: zend_obj_stdclass_or_string_or_null(): Argument #1 ($param) must be of type stdClass|string|null, resource given diff --git a/Zend/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..b337a74d6a8e --- /dev/null +++ b/Zend/tests/zpp/obj_of_class_zpp_specifier_strict_mode.phpt @@ -0,0 +1,192 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS() and Z_PARAM_OBJ_OF_CLASS_OR_NULL() (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object_sdtClass($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object_sdtClass($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +Using false: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +Using true: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +Using 42: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +Using 73.5: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +Using 'string': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '15': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '56.7': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using 'stdClass': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using anon class name: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using []: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +Using STDOUT: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given diff --git a/Zend/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..cbd0d6ffeee7 --- /dev/null +++ b/Zend/tests/zpp/obj_of_class_zpp_specifier_weak_mode.phpt @@ -0,0 +1,190 @@ +--TEST-- +Test Z_PARAM_OBJ_OF_CLASS() and Z_PARAM_OBJ_OF_CLASS_OR_NULL() (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object_sdtClass($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object_sdtClass($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +Using false: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +Using true: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +Using 42: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +Using 73.5: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +Using 'string': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '15': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '56.7': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using 'stdClass': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using anon class name: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using []: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +Using STDOUT: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given diff --git a/Zend/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt b/Zend/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt new file mode 100644 index 000000000000..9bdfd66ae4ee --- /dev/null +++ b/Zend/tests/zpp/obj_or_class_name_zpp_strict_mode.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test Z_PARAM_OBJ_OR_CLASS_NAME() and Z_PARAM_OBJ_OR_CLASS_NAME_OR_NULL (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_or_class_name($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_class_name_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, null given +NULL +Using false: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, false given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, false given +Using true: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, true given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, true given +Using 42: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, int given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, int given +Using 73.5: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, float given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, float given +Using 'string': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using '15': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using '56.7': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, array given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, array given +Using new stdClass(): +string(8) "stdClass" +string(8) "stdClass" +Using new S(): +string(1) "S" +string(1) "S" +Using STDOUT: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, resource given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, resource given diff --git a/Zend/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt b/Zend/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt new file mode 100644 index 000000000000..c14250a14f9e --- /dev/null +++ b/Zend/tests/zpp/obj_or_class_name_zpp_weak_mode.phpt @@ -0,0 +1,67 @@ +--TEST-- +Test Z_PARAM_OBJ_OR_CLASS_NAME() and Z_PARAM_OBJ_OR_CLASS_NAME_OR_NULL (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj_or_class_name($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_class_name_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, null given +NULL +Using false: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, false given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, false given +Using true: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, true given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, true given +Using 42: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, int given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, int given +Using 73.5: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, float given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, float given +Using 'string': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using '15': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using '56.7': +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, string given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, string given +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, array given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, array given +Using new stdClass(): +string(8) "stdClass" +string(8) "stdClass" +Using new S(): +string(1) "S" +string(1) "S" +Using STDOUT: +TypeError: zend_obj_or_class_name(): Argument #1 ($param) must be an object or a valid class name, resource given +TypeError: zend_obj_or_class_name_or_null(): Argument #1 ($param) must be an object, a valid class name, or null, resource given diff --git a/Zend/tests/zpp/obj_or_str_zpp_strict_mode.phpt b/Zend/tests/zpp/obj_or_str_zpp_strict_mode.phpt new file mode 100644 index 000000000000..9614acdee272 --- /dev/null +++ b/Zend/tests/zpp/obj_or_str_zpp_strict_mode.phpt @@ -0,0 +1,73 @@ +--TEST-- +Test Z_PARAM_OBJ_OR_STR() and Z_PARAM_OBJ_OR_STR_OR_NULL (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_string_or_object($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_string_or_object_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, null given +NULL +Using false: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, false given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, false given +Using true: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, true given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, true given +Using 42: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, int given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, int given +Using 73.5: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, float given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, float given +Using 'string': +string(6) "string" +string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, array given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, resource given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, resource given diff --git a/Zend/tests/zpp/obj_or_str_zpp_weak_mode.phpt b/Zend/tests/zpp/obj_or_str_zpp_weak_mode.phpt new file mode 100644 index 000000000000..76198926ffe8 --- /dev/null +++ b/Zend/tests/zpp/obj_or_str_zpp_weak_mode.phpt @@ -0,0 +1,73 @@ +--TEST-- +Test Z_PARAM_OBJ_OR_STR() and Z_PARAM_OBJ_OR_STR_OR_NULL (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_string_or_object($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_string_or_object_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECTF-- +Using null: + +Deprecated: zend_string_or_object(): Passing null to parameter #1 ($param) of type object|string is deprecated in %s on line %d +string(0) "" +NULL +Using false: +string(0) "" +string(0) "" +Using true: +string(1) "1" +string(1) "1" +Using 42: +string(2) "42" +string(2) "42" +Using 73.5: +string(4) "73.5" +string(4) "73.5" +Using 'string': +string(6) "string" +string(6) "string" +Using '15': +string(2) "15" +string(2) "15" +Using '56.7': +string(4) "56.7" +string(4) "56.7" +Using 'stdClass': +string(8) "stdClass" +string(8) "stdClass" +Using anon class name: +string(%d) "class@anonymous%s" +string(%d) "class@anonymous%s" +Using []: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, array given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_string_or_object(): Argument #1 ($param) must be of type object|string, resource given +TypeError: zend_string_or_object_or_null(): Argument #1 ($param) must be of type object|string|null, resource given diff --git a/Zend/tests/zpp/obj_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/obj_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..fecfb294bb45 --- /dev/null +++ b/Zend/tests/zpp/obj_zpp_specifier_strict_mode.phpt @@ -0,0 +1,116 @@ +--TEST-- +Test Z_PARAM_OBJ() and Z_PARAM_OBJ_OR_NULL (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_obj($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_obj(): Argument #1 ($param) must be of type object, null given +NULL +Using false: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, false given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, false given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, false given +Using true: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, true given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, true given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, true given +Using 42: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, int given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, int given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, int given +Using 73.5: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, float given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, float given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, float given +Using 'string': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using '15': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using '56.7': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using 'stdClass': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using anon class name: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using []: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, array given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, array given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, resource given diff --git a/Zend/tests/zpp/obj_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/obj_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..0557f1f03f37 --- /dev/null +++ b/Zend/tests/zpp/obj_zpp_specifier_weak_mode.phpt @@ -0,0 +1,114 @@ +--TEST-- +Test Z_PARAM_OBJ() and Z_PARAM_OBJ_OR_NULL (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_obj($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_obj($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_obj_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_obj(): Argument #1 ($param) must be of type object, null given +NULL +Using false: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, false given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, false given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, false given +Using true: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, true given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, true given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, true given +Using 42: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, int given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, int given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, int given +Using 73.5: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, float given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, float given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, float given +Using 'string': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using '15': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using '56.7': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using 'stdClass': +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using anon class name: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, string given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, string given +Using []: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, array given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, array given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_obj(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_obj(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_obj_or_null(): Argument #1 ($param) must be of type ?object, resource given diff --git a/Zend/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..94c31e1972fb --- /dev/null +++ b/Zend/tests/zpp/object_of_class_zpp_specifier_strict_mode.phpt @@ -0,0 +1,192 @@ +--TEST-- +Test object of class ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object_sdtClass($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object_sdtClass($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +Using false: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +Using true: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +Using 42: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +Using 73.5: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +Using 'string': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '15': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '56.7': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using 'stdClass': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using anon class name: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using []: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +Using STDOUT: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given diff --git a/Zend/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..b5ed5029645a --- /dev/null +++ b/Zend/tests/zpp/object_of_class_zpp_specifier_weak_mode.phpt @@ -0,0 +1,190 @@ +--TEST-- +Test object of class ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object_sdtClass($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object_sdtClass($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_sdtClass_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, null given +NULL +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, null given +NULL +Using false: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, false given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, false given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, false given +Using true: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, true given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, true given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, true given +Using 42: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, int given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, int given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, int given +Using 73.5: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, float given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, float given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, float given +Using 'string': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '15': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using '56.7': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using 'stdClass': +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using anon class name: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, string given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, string given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, string given +Using []: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, array given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, array given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, S given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, S given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, S given +Using STDOUT: +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null(): Argument #1 ($param) must be of type ?stdClass, resource given +TypeError: zend_object_sdtClass_slow_zpp(): Argument #1 ($param) must be of type stdClass, resource given +TypeError: zend_object_sdtClass_or_null_slow_zpp(): Argument #1 ($param) must be of type ?stdClass, resource given diff --git a/Zend/tests/zpp/object_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/object_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..c0f66a7846aa --- /dev/null +++ b/Zend/tests/zpp/object_zpp_specifier_strict_mode.phpt @@ -0,0 +1,200 @@ +--TEST-- +Test object ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, null given +NULL +Using false: +TypeError: zend_object(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, false given +Using true: +TypeError: zend_object(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, true given +Using 42: +TypeError: zend_object(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, int given +Using 73.5: +TypeError: zend_object(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, float given +Using 'string': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using '15': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using '56.7': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using 'stdClass': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using anon class name: +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using []: +TypeError: zend_object(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_object(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, resource given diff --git a/Zend/tests/zpp/object_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/object_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..d97078aaca46 --- /dev/null +++ b/Zend/tests/zpp/object_zpp_specifier_weak_mode.phpt @@ -0,0 +1,198 @@ +--TEST-- +Test object ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_object($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_object($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_object_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_object(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object(): Argument #1 ($param) must be of type object, null given +NULL +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, null given +NULL +Using false: +TypeError: zend_object(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, false given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, false given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, false given +Using true: +TypeError: zend_object(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, true given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, true given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, true given +Using 42: +TypeError: zend_object(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, int given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, int given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, int given +Using 73.5: +TypeError: zend_object(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, float given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, float given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, float given +Using 'string': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using '15': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using '56.7': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using 'stdClass': +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using anon class name: +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, string given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, string given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, string given +Using []: +TypeError: zend_object(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, array given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, array given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, array given +Using new stdClass(): +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +object(stdClass)#2 (0) { +} +Using new S(): +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +object(S)#3 (0) { +} +Using STDOUT: +TypeError: zend_object(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null(): Argument #1 ($param) must be of type ?object, resource given +TypeError: zend_object_slow_zpp(): Argument #1 ($param) must be of type object, resource given +TypeError: zend_object_or_null_slow_zpp(): Argument #1 ($param) must be of type ?object, resource given diff --git a/Zend/tests/zpp/resource_zpp_specifier_strict_mode.phpt b/Zend/tests/zpp/resource_zpp_specifier_strict_mode.phpt new file mode 100644 index 000000000000..3b3da48bdf5f --- /dev/null +++ b/Zend/tests/zpp/resource_zpp_specifier_strict_mode.phpt @@ -0,0 +1,184 @@ +--TEST-- +Test resource ZPP specifier (strict_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_resource($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_resource($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, null given +NULL +Using false: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, false given +Using true: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, true given +Using 42: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, int given +Using 73.5: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, float given +Using 'string': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using '15': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using '56.7': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using 'stdClass': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using anon class name: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using []: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, array given +Using new stdClass(): +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, stdClass given +Using new S(): +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, S given +Using STDOUT: +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) diff --git a/Zend/tests/zpp/resource_zpp_specifier_weak_mode.phpt b/Zend/tests/zpp/resource_zpp_specifier_weak_mode.phpt new file mode 100644 index 000000000000..04bc27cb01dc --- /dev/null +++ b/Zend/tests/zpp/resource_zpp_specifier_weak_mode.phpt @@ -0,0 +1,182 @@ +--TEST-- +Test resource ZPP specifier (weak_mode) +--EXTENSIONS-- +zend_test +--FILE-- + $type) { + echo "Using $name:\n"; + try { + var_dump(zend_resource($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null_slow_zpp($type)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + $ref =& $type; + try { + var_dump(zend_resource($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } + try { + var_dump(zend_resource_or_null_slow_zpp($ref)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +Using null: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, null given +NULL +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, null given +NULL +Using false: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, false given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, false given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, false given +Using true: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, true given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, true given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, true given +Using 42: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, int given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, int given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, int given +Using 73.5: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, float given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, float given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, float given +Using 'string': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using '15': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using '56.7': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using 'stdClass': +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using anon class name: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, string given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, string given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, string given +Using []: +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, array given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, array given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, array given +Using new stdClass(): +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, stdClass given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, stdClass given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, stdClass given +Using new S(): +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null(): Argument #1 ($param) must be of type resource or null, S given +TypeError: zend_resource_slow_zpp(): Argument #1 ($param) must be of type resource, S given +TypeError: zend_resource_or_null_slow_zpp(): Argument #1 ($param) must be of type resource or null, S given +Using STDOUT: +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) +resource(2) of type (stream) diff --git a/Zend/tests/zpp/types.inc b/Zend/tests/zpp/types.inc new file mode 100644 index 000000000000..43cac4a15602 --- /dev/null +++ b/Zend/tests/zpp/types.inc @@ -0,0 +1,26 @@ + null, + 'false' => false, + 'true' => true, + '42' => 42, + '73.5' => 73.5, + "'string'" => 'string', + "'15'" => '15', + "'56.7'" => '56.7', + "'stdClass'" => 'stdClass', + 'anon class name' => $anon::class, + '[]' => [], + 'new stdClass()' => new stdClass(), + 'new S()' => new S(), + 'STDOUT' => STDOUT, +]; diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index a880c09fc1ff..82bfa8d38e33 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -225,14 +225,445 @@ static ZEND_FUNCTION(zend_delref) RETURN_NULL(); } -/* Tests Z_PARAM_OBJ_OR_STR */ -static ZEND_FUNCTION(zend_string_or_object) +/* 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); +} + +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); +} + +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); +} + +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); +} + +static ZEND_FUNCTION(zend_object) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_or_null) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &v) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_or_null_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "o!", &v) == FAILURE) { + RETURN_THROWS(); + } + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_obj) +{ + zend_object *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_OBJ_COPY(v); +} + +static ZEND_FUNCTION(zend_obj_or_null) +{ + zend_object *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_OBJ_COPY(v); +} + +static ZEND_FUNCTION(zend_obj_or_class_name) +{ + zend_class_entry *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OR_CLASS_NAME(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_STR_COPY(v->name); +} + +static ZEND_FUNCTION(zend_obj_or_class_name_or_null) +{ + zend_class_entry *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OR_CLASS_NAME_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_STR_COPY(v->name); +} + +static ZEND_FUNCTION(zend_class_name) +{ + zend_class_entry *v = NULL; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_CLASS(v) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_STR_COPY(v->name); +} + +static ZEND_FUNCTION(zend_class_name_or_null) +{ + zend_class_entry *v = NULL; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_CLASS_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_STR_COPY(v->name); +} + +static ZEND_FUNCTION(zend_class_name_slow_zpp) +{ + zend_class_entry *v = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "C", &v) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_STR_COPY(v->name); +} + +static ZEND_FUNCTION(zend_class_name_or_null_slow_zpp) +{ + zend_class_entry *v = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "C!", &v) == FAILURE) { + RETURN_THROWS(); + } + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_STR_COPY(v->name); +} + +static ZEND_FUNCTION(zend_object_sdtClass) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(v, zend_standard_class_def) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_sdtClass_or_null) +{ + zval *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(v, zend_standard_class_def) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_sdtClass_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &v, zend_standard_class_def) == FAILURE) { + RETURN_THROWS(); + } + + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_object_sdtClass_or_null_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O!", &v, zend_standard_class_def) == FAILURE) { + RETURN_THROWS(); + } + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + +static ZEND_FUNCTION(zend_obj_sdtClass) +{ + zend_object *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OF_CLASS(v, zend_standard_class_def) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_OBJ_COPY(v); +} + +static ZEND_FUNCTION(zend_obj_sdtClass_or_null) +{ + zend_object *v; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OF_CLASS_OR_NULL(v, zend_standard_class_def) + ZEND_PARSE_PARAMETERS_END(); + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_OBJ_COPY(v); +} + +static ZEND_FUNCTION(zend_obj_stdclass_or_string) { zend_string *str; zend_object *object; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJ_OR_STR(object, str) + Z_PARAM_OBJ_OF_CLASS_OR_STR(object, zend_standard_class_def, str) ZEND_PARSE_PARAMETERS_END(); if (str) { @@ -242,14 +673,13 @@ static ZEND_FUNCTION(zend_string_or_object) } } -/* Tests Z_PARAM_OBJ_OR_STR_OR_NULL */ -static ZEND_FUNCTION(zend_string_or_object_or_null) +static ZEND_FUNCTION(zend_obj_stdclass_or_string_or_null) { zend_string *str; zend_object *object; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJ_OR_STR_OR_NULL(object, str) + Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL(object, zend_standard_class_def, str) ZEND_PARSE_PARAMETERS_END(); if (str) { @@ -261,66 +691,116 @@ static ZEND_FUNCTION(zend_string_or_object_or_null) } } -/* Tests Z_PARAM_OBJ_OF_CLASS_OR_STR */ -static ZEND_FUNCTION(zend_string_or_stdclass) +static ZEND_FUNCTION(zend_obj_stdclass_or_int) { - zend_string *str; + zend_long l; zend_object *object; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJ_OF_CLASS_OR_STR(object, zend_standard_class_def, str) + Z_PARAM_OBJ_OF_CLASS_OR_LONG(object, zend_standard_class_def, l) ZEND_PARSE_PARAMETERS_END(); - if (str) { - RETURN_STR_COPY(str); + if (object) { + RETURN_OBJ_COPY(object); } else { + RETURN_LONG(l); + } +} + +static ZEND_FUNCTION(zend_obj_stdclass_or_int_or_null) +{ + zend_long l; + zend_object *object; + bool is_null; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OF_CLASS_OR_LONG_OR_NULL(object, zend_standard_class_def, l, is_null) + ZEND_PARSE_PARAMETERS_END(); + + if (is_null) { + RETURN_NULL(); + } else if (object) { RETURN_OBJ_COPY(object); + } else { + RETURN_LONG(l); } } -static ZEND_FUNCTION(zend_test_compile_string) +static ZEND_FUNCTION(zend_resource) { - zend_string *source_string = NULL; - zend_string *filename = NULL; - zend_long position = ZEND_COMPILE_POSITION_AT_OPEN_TAG; + zval *v; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(source_string) - Z_PARAM_PATH_STR(filename) - Z_PARAM_LONG(position) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_RESOURCE(v) ZEND_PARSE_PARAMETERS_END(); - zend_op_array *op_array = NULL; + RETURN_COPY(v); +} - op_array = compile_string(source_string, ZSTR_VAL(filename), position); +static ZEND_FUNCTION(zend_resource_or_null) +{ + zval *v; - if (op_array) { - zval retval; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_RESOURCE_OR_NULL(v) + ZEND_PARSE_PARAMETERS_END(); - 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(); + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} - destroy_op_array(op_array); - efree_size(op_array, sizeof(zend_op_array)); +static ZEND_FUNCTION(zend_resource_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &v) == FAILURE) { + RETURN_THROWS(); } - return; + RETURN_COPY(v); } -/* Tests Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL */ -static ZEND_FUNCTION(zend_string_or_stdclass_or_null) +static ZEND_FUNCTION(zend_resource_or_null_slow_zpp) +{ + zval *v; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "r!", &v) == FAILURE) { + RETURN_THROWS(); + } + + if (v == NULL) { + RETURN_NULL(); + } + RETURN_COPY(v); +} + +/* Tests Z_PARAM_OBJ_OR_STR */ +static ZEND_FUNCTION(zend_string_or_object) { zend_string *str; zend_object *object; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL(object, zend_standard_class_def, str) + Z_PARAM_OBJ_OR_STR(object, str) + ZEND_PARSE_PARAMETERS_END(); + + if (str) { + RETURN_STR_COPY(str); + } else { + RETURN_OBJ_COPY(object); + } +} + +/* Tests Z_PARAM_OBJ_OR_STR_OR_NULL */ +static ZEND_FUNCTION(zend_string_or_object_or_null) +{ + zend_string *str; + zend_object *object; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ_OR_STR_OR_NULL(object, str) ZEND_PARSE_PARAMETERS_END(); if (str) { @@ -376,6 +856,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 +986,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) { diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 7c96ea176a88..3c09668bddb1 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -299,15 +299,80 @@ 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_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_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_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_object(object $param): object {} + function zend_object_or_null(object|null $param): object|null {} + function zend_object_slow_zpp(object $param): object {} + function zend_object_or_null_slow_zpp(object|null $param): object|null {} + + function zend_obj(object $param): object {} + function zend_obj_or_null(object|null $param): object|null {} + + function zend_obj_or_class_name(object|string $param): string {} + function zend_obj_or_class_name_or_null(object|string|null $param): string|null {} + + function zend_class_name(string $param): string {} + function zend_class_name_or_null(string|null $param): string|null {} + function zend_class_name_slow_zpp(string $param): string {} + function zend_class_name_or_null_slow_zpp(string|null $param): string|null {} + + function zend_object_sdtClass(stdClass $param): stdClass {} + function zend_object_sdtClass_or_null(stdClass|null $param): stdClass|null {} + function zend_object_sdtClass_slow_zpp(stdClass $param): stdClass {} + function zend_object_sdtClass_or_null_slow_zpp(stdClass|null $param): stdClass|null {} + + function zend_obj_sdtClass(stdClass $param): stdClass {} + function zend_obj_sdtClass_or_null(stdClass|null $param): stdClass|null {} + + /** + * @param resource $param + * @return resource + */ + function zend_resource($param) {} + /** + * @param resource|null $param + * @return resource|null + */ + function zend_resource_or_null($param) {} + /** + * @param resource $param + * @return resource + */ + function zend_resource_slow_zpp($param) {} + /** + * @param resource|null $param + * @return resource|null + */ + function zend_resource_or_null_slow_zpp($param) {} + function zend_string_or_object(object|string $param): object|string {} function zend_string_or_object_or_null(object|string|null $param): object|string|null {} - /** @param stdClass|string $param */ - function zend_string_or_stdclass($param): stdClass|string {} + function zend_obj_stdclass_or_string(stdClass|string|null $param): stdClass|string {} + function zend_obj_stdclass_or_string_or_null(stdClass|string|null $param): stdClass|string|null {} - /** @param stdClass|string|null $param */ - function zend_string_or_stdclass_or_null($param): stdClass|string|null {} + function zend_obj_stdclass_or_int(stdClass|int|null $param): stdClass|int {} + function zend_obj_stdclass_or_int_or_null(stdClass|int|null $param): stdClass|int|null {} function zend_number_or_string(string|int|float $param): string|int|float {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index b2e342382db7..93fdadb7f6b2 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a221a3df3815679d61fd546ba120fd3a374fe71f + * Stub hash: 4d728e740122add9d4c91f5c1abb5f5017690636 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) @@ -53,6 +53,116 @@ 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_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_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_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_INFO_EX(arginfo_zend_object, 0, 1, IS_OBJECT, 0) + ZEND_ARG_TYPE_INFO(0, param, IS_OBJECT, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_object_or_null, 0, 1, IS_OBJECT, 1) + ZEND_ARG_TYPE_INFO(0, param, IS_OBJECT, 1) +ZEND_END_ARG_INFO() + +#define arginfo_zend_object_slow_zpp arginfo_zend_object + +#define arginfo_zend_object_or_null_slow_zpp arginfo_zend_object_or_null + +#define arginfo_zend_obj arginfo_zend_object + +#define arginfo_zend_obj_or_null arginfo_zend_object_or_null + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_obj_or_class_name, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_obj_or_class_name_or_null, 0, 1, IS_STRING, 1) + ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING|MAY_BE_NULL, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_class_name, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, param, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_class_name_or_null, 0, 1, IS_STRING, 1) + ZEND_ARG_TYPE_INFO(0, param, IS_STRING, 1) +ZEND_END_ARG_INFO() + +#define arginfo_zend_class_name_slow_zpp arginfo_zend_class_name + +#define arginfo_zend_class_name_or_null_slow_zpp arginfo_zend_class_name_or_null + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_zend_object_sdtClass, 0, 1, stdClass, 0) + ZEND_ARG_OBJ_INFO(0, param, stdClass, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_zend_object_sdtClass_or_null, 0, 1, stdClass, 1) + ZEND_ARG_OBJ_INFO(0, param, stdClass, 1) +ZEND_END_ARG_INFO() + +#define arginfo_zend_object_sdtClass_slow_zpp arginfo_zend_object_sdtClass + +#define arginfo_zend_object_sdtClass_or_null_slow_zpp arginfo_zend_object_sdtClass_or_null + +#define arginfo_zend_obj_sdtClass arginfo_zend_object_sdtClass + +#define arginfo_zend_obj_sdtClass_or_null arginfo_zend_object_sdtClass_or_null + +ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_resource, 0, 0, 1) + ZEND_ARG_INFO(0, param) +ZEND_END_ARG_INFO() + +#define arginfo_zend_resource_or_null arginfo_zend_resource + +#define arginfo_zend_resource_slow_zpp arginfo_zend_resource + +#define arginfo_zend_resource_or_null_slow_zpp arginfo_zend_resource + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_string_or_object, 0, 1, MAY_BE_OBJECT|MAY_BE_STRING) ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() @@ -61,12 +171,20 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_string_or_object_or_null, 0 ZEND_ARG_TYPE_MASK(0, param, MAY_BE_OBJECT|MAY_BE_STRING|MAY_BE_NULL, NULL) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_string_or_stdclass, 0, 1, stdClass, MAY_BE_STRING) - ZEND_ARG_INFO(0, param) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_obj_stdclass_or_string, 0, 1, stdClass, MAY_BE_STRING) + ZEND_ARG_OBJ_TYPE_MASK(0, param, stdClass, MAY_BE_STRING|MAY_BE_NULL, NULL) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_string_or_stdclass_or_null, 0, 1, stdClass, MAY_BE_STRING|MAY_BE_NULL) - ZEND_ARG_INFO(0, param) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_obj_stdclass_or_string_or_null, 0, 1, stdClass, MAY_BE_STRING|MAY_BE_NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, param, stdClass, MAY_BE_STRING|MAY_BE_NULL, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_obj_stdclass_or_int, 0, 1, stdClass, MAY_BE_LONG) + ZEND_ARG_OBJ_TYPE_MASK(0, param, stdClass, MAY_BE_LONG|MAY_BE_NULL, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_zend_obj_stdclass_or_int_or_null, 0, 1, stdClass, MAY_BE_LONG|MAY_BE_NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, param, stdClass, MAY_BE_LONG|MAY_BE_NULL, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zend_number_or_string, 0, 1, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_DOUBLE) @@ -313,10 +431,50 @@ 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_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_number); +static ZEND_FUNCTION(zend_number_or_null); +static ZEND_FUNCTION(zend_number_slow_zpp); +static ZEND_FUNCTION(zend_number_or_null_slow_zpp); +static ZEND_FUNCTION(zend_object); +static ZEND_FUNCTION(zend_object_or_null); +static ZEND_FUNCTION(zend_object_slow_zpp); +static ZEND_FUNCTION(zend_object_or_null_slow_zpp); +static ZEND_FUNCTION(zend_obj); +static ZEND_FUNCTION(zend_obj_or_null); +static ZEND_FUNCTION(zend_obj_or_class_name); +static ZEND_FUNCTION(zend_obj_or_class_name_or_null); +static ZEND_FUNCTION(zend_class_name); +static ZEND_FUNCTION(zend_class_name_or_null); +static ZEND_FUNCTION(zend_class_name_slow_zpp); +static ZEND_FUNCTION(zend_class_name_or_null_slow_zpp); +static ZEND_FUNCTION(zend_object_sdtClass); +static ZEND_FUNCTION(zend_object_sdtClass_or_null); +static ZEND_FUNCTION(zend_object_sdtClass_slow_zpp); +static ZEND_FUNCTION(zend_object_sdtClass_or_null_slow_zpp); +static ZEND_FUNCTION(zend_obj_sdtClass); +static ZEND_FUNCTION(zend_obj_sdtClass_or_null); +static ZEND_FUNCTION(zend_resource); +static ZEND_FUNCTION(zend_resource_or_null); +static ZEND_FUNCTION(zend_resource_slow_zpp); +static ZEND_FUNCTION(zend_resource_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); -static ZEND_FUNCTION(zend_string_or_stdclass); -static ZEND_FUNCTION(zend_string_or_stdclass_or_null); +static ZEND_FUNCTION(zend_obj_stdclass_or_string); +static ZEND_FUNCTION(zend_obj_stdclass_or_string_or_null); +static ZEND_FUNCTION(zend_obj_stdclass_or_int); +static ZEND_FUNCTION(zend_obj_stdclass_or_int_or_null); static ZEND_FUNCTION(zend_number_or_string); static ZEND_FUNCTION(zend_number_or_string_or_null); static ZEND_FUNCTION(zend_iterable); @@ -449,10 +607,50 @@ 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_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_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_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_object, arginfo_zend_object) + ZEND_FE(zend_object_or_null, arginfo_zend_object_or_null) + ZEND_FE(zend_object_slow_zpp, arginfo_zend_object_slow_zpp) + ZEND_FE(zend_object_or_null_slow_zpp, arginfo_zend_object_or_null_slow_zpp) + ZEND_FE(zend_obj, arginfo_zend_obj) + ZEND_FE(zend_obj_or_null, arginfo_zend_obj_or_null) + ZEND_FE(zend_obj_or_class_name, arginfo_zend_obj_or_class_name) + ZEND_FE(zend_obj_or_class_name_or_null, arginfo_zend_obj_or_class_name_or_null) + ZEND_FE(zend_class_name, arginfo_zend_class_name) + ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) + ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) + ZEND_FE(zend_class_name_or_null_slow_zpp, arginfo_zend_class_name_or_null_slow_zpp) + ZEND_FE(zend_object_sdtClass, arginfo_zend_object_sdtClass) + ZEND_FE(zend_object_sdtClass_or_null, arginfo_zend_object_sdtClass_or_null) + ZEND_FE(zend_object_sdtClass_slow_zpp, arginfo_zend_object_sdtClass_slow_zpp) + ZEND_FE(zend_object_sdtClass_or_null_slow_zpp, arginfo_zend_object_sdtClass_or_null_slow_zpp) + ZEND_FE(zend_obj_sdtClass, arginfo_zend_obj_sdtClass) + ZEND_FE(zend_obj_sdtClass_or_null, arginfo_zend_obj_sdtClass_or_null) + ZEND_FE(zend_resource, arginfo_zend_resource) + ZEND_FE(zend_resource_or_null, arginfo_zend_resource_or_null) + ZEND_FE(zend_resource_slow_zpp, arginfo_zend_resource_slow_zpp) + ZEND_FE(zend_resource_or_null_slow_zpp, arginfo_zend_resource_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) - ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) - ZEND_FE(zend_string_or_stdclass_or_null, arginfo_zend_string_or_stdclass_or_null) + ZEND_FE(zend_obj_stdclass_or_string, arginfo_zend_obj_stdclass_or_string) + ZEND_FE(zend_obj_stdclass_or_string_or_null, arginfo_zend_obj_stdclass_or_string_or_null) + ZEND_FE(zend_obj_stdclass_or_int, arginfo_zend_obj_stdclass_or_int) + ZEND_FE(zend_obj_stdclass_or_int_or_null, arginfo_zend_obj_stdclass_or_int_or_null) ZEND_FE(zend_number_or_string, arginfo_zend_number_or_string) ZEND_FE(zend_number_or_string_or_null, arginfo_zend_number_or_string_or_null) ZEND_FE(zend_iterable, arginfo_zend_iterable) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index ea6a2c94fbdf..7e41dc18eabb 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a221a3df3815679d61fd546ba120fd3a374fe71f */ + * Stub hash: 4d728e740122add9d4c91f5c1abb5f5017690636 */ -#ifndef ZEND_TEST_DECL_a221a3df3815679d61fd546ba120fd3a374fe71f_H -#define ZEND_TEST_DECL_a221a3df3815679d61fd546ba120fd3a374fe71f_H +#ifndef ZEND_TEST_DECL_4d728e740122add9d4c91f5c1abb5f5017690636_H +#define ZEND_TEST_DECL_4d728e740122add9d4c91f5c1abb5f5017690636_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_a221a3df3815679d61fd546ba120fd3a374fe71f_H */ +#endif /* ZEND_TEST_DECL_4d728e740122add9d4c91f5c1abb5f5017690636_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index 05014c80fd5d..479a678df778 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a221a3df3815679d61fd546ba120fd3a374fe71f + * Stub hash: 4d728e740122add9d4c91f5c1abb5f5017690636 * Has decl header: yes */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, 0) @@ -49,19 +49,99 @@ 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_int arginfo_zend_bool -#define arginfo_zend_number_or_string_or_null arginfo_zend_string_or_object +#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_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_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_object arginfo_zend_bool + +#define arginfo_zend_object_or_null arginfo_zend_bool + +#define arginfo_zend_object_slow_zpp arginfo_zend_bool + +#define arginfo_zend_object_or_null_slow_zpp arginfo_zend_bool + +#define arginfo_zend_obj arginfo_zend_bool + +#define arginfo_zend_obj_or_null arginfo_zend_bool + +#define arginfo_zend_obj_or_class_name arginfo_zend_bool + +#define arginfo_zend_obj_or_class_name_or_null arginfo_zend_bool + +#define arginfo_zend_class_name arginfo_zend_bool + +#define arginfo_zend_class_name_or_null arginfo_zend_bool + +#define arginfo_zend_class_name_slow_zpp arginfo_zend_bool + +#define arginfo_zend_class_name_or_null_slow_zpp arginfo_zend_bool + +#define arginfo_zend_object_sdtClass arginfo_zend_bool + +#define arginfo_zend_object_sdtClass_or_null arginfo_zend_bool + +#define arginfo_zend_object_sdtClass_slow_zpp arginfo_zend_bool + +#define arginfo_zend_object_sdtClass_or_null_slow_zpp arginfo_zend_bool + +#define arginfo_zend_obj_sdtClass arginfo_zend_bool + +#define arginfo_zend_obj_sdtClass_or_null arginfo_zend_bool + +#define arginfo_zend_resource arginfo_zend_bool + +#define arginfo_zend_resource_or_null arginfo_zend_bool + +#define arginfo_zend_resource_slow_zpp arginfo_zend_bool + +#define arginfo_zend_resource_or_null_slow_zpp arginfo_zend_bool + +#define arginfo_zend_string_or_object arginfo_zend_bool + +#define arginfo_zend_string_or_object_or_null arginfo_zend_bool + +#define arginfo_zend_obj_stdclass_or_string arginfo_zend_bool + +#define arginfo_zend_obj_stdclass_or_string_or_null arginfo_zend_bool + +#define arginfo_zend_obj_stdclass_or_int arginfo_zend_bool + +#define arginfo_zend_obj_stdclass_or_int_or_null arginfo_zend_bool + +#define arginfo_zend_number_or_string arginfo_zend_bool + +#define arginfo_zend_number_or_string_or_null arginfo_zend_bool ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_iterable, 0, 0, 1) ZEND_ARG_INFO(0, arg1) @@ -276,10 +356,50 @@ 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_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_number); +static ZEND_FUNCTION(zend_number_or_null); +static ZEND_FUNCTION(zend_number_slow_zpp); +static ZEND_FUNCTION(zend_number_or_null_slow_zpp); +static ZEND_FUNCTION(zend_object); +static ZEND_FUNCTION(zend_object_or_null); +static ZEND_FUNCTION(zend_object_slow_zpp); +static ZEND_FUNCTION(zend_object_or_null_slow_zpp); +static ZEND_FUNCTION(zend_obj); +static ZEND_FUNCTION(zend_obj_or_null); +static ZEND_FUNCTION(zend_obj_or_class_name); +static ZEND_FUNCTION(zend_obj_or_class_name_or_null); +static ZEND_FUNCTION(zend_class_name); +static ZEND_FUNCTION(zend_class_name_or_null); +static ZEND_FUNCTION(zend_class_name_slow_zpp); +static ZEND_FUNCTION(zend_class_name_or_null_slow_zpp); +static ZEND_FUNCTION(zend_object_sdtClass); +static ZEND_FUNCTION(zend_object_sdtClass_or_null); +static ZEND_FUNCTION(zend_object_sdtClass_slow_zpp); +static ZEND_FUNCTION(zend_object_sdtClass_or_null_slow_zpp); +static ZEND_FUNCTION(zend_obj_sdtClass); +static ZEND_FUNCTION(zend_obj_sdtClass_or_null); +static ZEND_FUNCTION(zend_resource); +static ZEND_FUNCTION(zend_resource_or_null); +static ZEND_FUNCTION(zend_resource_slow_zpp); +static ZEND_FUNCTION(zend_resource_or_null_slow_zpp); static ZEND_FUNCTION(zend_string_or_object); static ZEND_FUNCTION(zend_string_or_object_or_null); -static ZEND_FUNCTION(zend_string_or_stdclass); -static ZEND_FUNCTION(zend_string_or_stdclass_or_null); +static ZEND_FUNCTION(zend_obj_stdclass_or_string); +static ZEND_FUNCTION(zend_obj_stdclass_or_string_or_null); +static ZEND_FUNCTION(zend_obj_stdclass_or_int); +static ZEND_FUNCTION(zend_obj_stdclass_or_int_or_null); static ZEND_FUNCTION(zend_number_or_string); static ZEND_FUNCTION(zend_number_or_string_or_null); static ZEND_FUNCTION(zend_iterable); @@ -384,10 +504,50 @@ 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_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_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_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_object, arginfo_zend_object) + ZEND_FE(zend_object_or_null, arginfo_zend_object_or_null) + ZEND_FE(zend_object_slow_zpp, arginfo_zend_object_slow_zpp) + ZEND_FE(zend_object_or_null_slow_zpp, arginfo_zend_object_or_null_slow_zpp) + ZEND_FE(zend_obj, arginfo_zend_obj) + ZEND_FE(zend_obj_or_null, arginfo_zend_obj_or_null) + ZEND_FE(zend_obj_or_class_name, arginfo_zend_obj_or_class_name) + ZEND_FE(zend_obj_or_class_name_or_null, arginfo_zend_obj_or_class_name_or_null) + ZEND_FE(zend_class_name, arginfo_zend_class_name) + ZEND_FE(zend_class_name_or_null, arginfo_zend_class_name_or_null) + ZEND_FE(zend_class_name_slow_zpp, arginfo_zend_class_name_slow_zpp) + ZEND_FE(zend_class_name_or_null_slow_zpp, arginfo_zend_class_name_or_null_slow_zpp) + ZEND_FE(zend_object_sdtClass, arginfo_zend_object_sdtClass) + ZEND_FE(zend_object_sdtClass_or_null, arginfo_zend_object_sdtClass_or_null) + ZEND_FE(zend_object_sdtClass_slow_zpp, arginfo_zend_object_sdtClass_slow_zpp) + ZEND_FE(zend_object_sdtClass_or_null_slow_zpp, arginfo_zend_object_sdtClass_or_null_slow_zpp) + ZEND_FE(zend_obj_sdtClass, arginfo_zend_obj_sdtClass) + ZEND_FE(zend_obj_sdtClass_or_null, arginfo_zend_obj_sdtClass_or_null) + ZEND_FE(zend_resource, arginfo_zend_resource) + ZEND_FE(zend_resource_or_null, arginfo_zend_resource_or_null) + ZEND_FE(zend_resource_slow_zpp, arginfo_zend_resource_slow_zpp) + ZEND_FE(zend_resource_or_null_slow_zpp, arginfo_zend_resource_or_null_slow_zpp) ZEND_FE(zend_string_or_object, arginfo_zend_string_or_object) ZEND_FE(zend_string_or_object_or_null, arginfo_zend_string_or_object_or_null) - ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass) - ZEND_FE(zend_string_or_stdclass_or_null, arginfo_zend_string_or_stdclass_or_null) + ZEND_FE(zend_obj_stdclass_or_string, arginfo_zend_obj_stdclass_or_string) + ZEND_FE(zend_obj_stdclass_or_string_or_null, arginfo_zend_obj_stdclass_or_string_or_null) + ZEND_FE(zend_obj_stdclass_or_int, arginfo_zend_obj_stdclass_or_int) + ZEND_FE(zend_obj_stdclass_or_int_or_null, arginfo_zend_obj_stdclass_or_int_or_null) ZEND_FE(zend_number_or_string, arginfo_zend_number_or_string) ZEND_FE(zend_number_or_string_or_null, arginfo_zend_number_or_string_or_null) ZEND_FE(zend_iterable, arginfo_zend_iterable) diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt deleted file mode 100644 index a72d504a2db3..000000000000 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_strict_mode.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -Test class string ZPP specifier ---EXTENSIONS-- -zend_test ---FILE-- -getMessage(), PHP_EOL; - } -} - -?> ---EXPECT-- -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, null given -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, false given -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, true given -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 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 -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, resource given diff --git a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt b/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt deleted file mode 100644 index 2110ecc4a0e4..000000000000 --- a/ext/zend_test/tests/zpp/class-string_zpp_specifier_weak_mode.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -Test class string ZPP specifier ---EXTENSIONS-- -zend_test ---FILE-- -getMessage(), PHP_EOL; - } -} - -?> ---EXPECTF-- -Deprecated: zend_object_init_with_constructor(): Passing null to parameter #1 ($class) of type string is deprecated in %s on line %d -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, given -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, given -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be a valid class name, 1 given -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 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 -TypeError: zend_object_init_with_constructor(): Argument #1 ($class) must be of type string, resource given From 9f92639ade053f033587e90e6964390f99f4738f Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Fri, 14 Aug 2026 16:13:07 +0100 Subject: [PATCH 2/7] soap: call_user_function API doesn't care about the function table (#22941) --- ext/soap/soap.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 4fade198d020..402708bb3095 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1643,11 +1643,7 @@ PHP_METHOD(SoapServer, handle) if (zend_hash_find_ptr_lc(function_table, Z_STR(h->function_name)) != NULL || ((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) && zend_hash_str_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1))) { - if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) { - call_status = call_user_function(NULL, soap_obj, &h->function_name, &h->retval, h->num_params, h->parameters); - } else { - call_status = call_user_function(EG(function_table), NULL, &h->function_name, &h->retval, h->num_params, h->parameters); - } + call_status = call_user_function(NULL, soap_obj, &h->function_name, &h->retval, h->num_params, h->parameters); if (call_status != SUCCESS) { php_error_docref(NULL, E_WARNING, "Function '%s' call failed", Z_STRVAL(h->function_name)); return; @@ -1681,16 +1677,12 @@ PHP_METHOD(SoapServer, handle) if (zend_hash_find_ptr_lc(function_table, Z_STR(function_name)) != NULL || ((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) && zend_hash_str_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1))) { - if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) { - call_status = call_user_function(NULL, soap_obj, &function_name, &retval, num_params, params); - if (service->type == SOAP_CLASS) { - if (service->soap_class.persistence != SOAP_PERSISTENCE_SESSION) { - zval_ptr_dtor(soap_obj); - soap_obj = NULL; - } + call_status = call_user_function(NULL, soap_obj, &function_name, &retval, num_params, params); + if (service->type == SOAP_CLASS) { + if (service->soap_class.persistence != SOAP_PERSISTENCE_SESSION) { + zval_ptr_dtor(soap_obj); + soap_obj = NULL; } - } else { - call_status = call_user_function(EG(function_table), NULL, &function_name, &retval, num_params, params); } } else { php_error(E_ERROR, "Function '%s' doesn't exist", Z_STRVAL(function_name)); From fa317bf0e963fae92d6b4fd9366bc4249920602f Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Sat, 15 Aug 2026 01:02:07 +0900 Subject: [PATCH 3/7] sapi/lsapi: fix returns uninitialized value (#23281) --- NEWS | 3 +++ sapi/litespeed/lsapi_main.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 1f1aab1cd076..ecb4d105e917 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,9 @@ PHP NEWS . Fixed ZipArchive::extractTo() and ZipArchive::getFrom*() reporting success on corrupted entries. (David Carlier) +- SAPI: + . Fixed returns uninitialized value on LiteSpeed lsapi SAPI (Go Kudo) + 27 Aug 2026, PHP 8.4.25 - Core: diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index e6dc68954f4e..5d1e37a2b64e 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -1443,7 +1443,7 @@ void setArgv0( int argc, char * argv[] ) #include int main( int argc, char * argv[] ) { - int ret; + int ret = 0; int bindFd; char * php_ini_path = NULL; From 2263c3aed2ce793a490f409519791106b511868b Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Sat, 15 Aug 2026 01:03:29 +0900 Subject: [PATCH 4/7] [ci skip] update NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index c21dfad8e195..b62200e4c06a 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,8 @@ PHP NEWS . Fixed bug GH-17787 (ZipArchive stream stops reading early when the archive is freed while the stream is still open). (Eyüp Can Akman) +- SAPI: + . Fixed returns uninitialized value on LiteSpeed lsapi SAPI (Go Kudo) 27 Aug 2026, PHP 8.5.10 From 26d682cc9a7e42829dfa9725dd63933abe86cd65 Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Sat, 15 Aug 2026 01:04:37 +0900 Subject: [PATCH 5/7] [ci skip] update NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index e44eae1fae80..b7259e81f681 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,9 @@ PHP NEWS . Fixed bug GH-17787 (ZipArchive stream stops reading early when the archive is freed while the stream is still open). (Eyüp Can Akman) +- SAPI: + . Fixed returns uninitialized value on LiteSpeed lsapi SAPI (Go Kudo) + 13 Aug 2026, PHP 8.6.0beta1 - Core: From aa23306d8bed6cc5678900de590ba539d3a1fca0 Mon Sep 17 00:00:00 2001 From: Weilin Du Date: Sat, 15 Aug 2026 01:14:55 +0800 Subject: [PATCH 6/7] [skip ci] UPGRADING: Update gmp_powm_sec() requirement details Clarified the requirement for gmp_powm_sec() regarding Windows builds using MPIR. So we stay consistent with the description of gmp_prevprime(). --- UPGRADING | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UPGRADING b/UPGRADING index 5d1f69f63b58..390012a80702 100644 --- a/UPGRADING +++ b/UPGRADING @@ -335,7 +335,8 @@ PHP 8.6 UPGRADE NOTES - GMP: . Added gmp_powm_sec() for side-channel quiet modular exponentiation. - Requires GNU MP 5.0.0 or later. + Requires GNU MP 5.0.0 or later; it is not available on official Windows + builds using MPIR. . Added gmp_prevprime() to get the largest prime smaller than the given number. The optional $definitely_prime output parameter indicates whether the returned number is definitely prime, as opposed to probably prime. From 5332ab0c291361abe3d12db21dd55e5dc7baa829 Mon Sep 17 00:00:00 2001 From: Weilin Du Date: Sat, 15 Aug 2026 03:00:26 +0800 Subject: [PATCH 7/7] ext/phar: only `.phar` extensions in file names trigger automatic archive detection (#23260) Fixed Phar archives being automatically detected when ".phar" only occurs in a directory name or is not a filename extension in an included file's path. --- NEWS | 5 ++ UPGRADING | 6 +++ ext/phar/phar.c | 22 +++++++- ext/phar/tests/include_file_extension.phpt | 58 ++++++++++++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 ext/phar/tests/include_file_extension.phpt diff --git a/NEWS b/NEWS index b7259e81f681..1bba6a7b6c22 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,11 @@ PHP NEWS left busy for the next fetch, and rows delivered from a result another statement took over. (KentarouTakeda) +- Phar: + . Fixed Phar archives being automatically detected when ".phar" only occurs + in a directory name or is not a filename extension in an included file's + path. (Weilin Du) + - Readline: . Fixed class constant completion in the interactive shell. (Weilin Du) diff --git a/UPGRADING b/UPGRADING index 390012a80702..1cc6d66f3757 100644 --- a/UPGRADING +++ b/UPGRADING @@ -52,6 +52,12 @@ PHP 8.6 UPGRADE NOTES . imagesetstyle(), imagefilter() and imagecrop() filter their array arguments types / values and raise a TypeError / ValueError accordingly. +- Phar: + . Files are only automatically interpreted as Phar archives when included + if ".phar" occurs as an extension in the filename component of their + paths. Previously, it could occur in a directory name or as part of an + extension such as ".pharma". + - GMP: . GMP power and shift operators now throw ValueError when GMP right operands are outside the unsigned long range, instead of silently truncating them. diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 9f0ccc627279..af3a4992d6d5 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -3167,6 +3167,26 @@ static size_t phar_zend_stream_fsizer(void *handle) /* {{{ */ zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type); +static bool phar_has_marker_in_filename(const zend_string *filename) +{ + const char *path = ZSTR_VAL(filename); + const char *basename = zend_memrchr(path, '/', ZSTR_LEN(filename)); +#ifdef PHP_WIN32 + const char *backslash = zend_memrchr(path, '\\', ZSTR_LEN(filename)); + if (backslash && (!basename || backslash > basename)) { + basename = backslash; + } +#endif + const char *marker = basename ? basename + 1 : path; + while ((marker = strstr(marker, ".phar"))) { + marker += sizeof(".phar") - 1; + if (*marker == '\0' || *marker == '.') { + return true; + } + } + return false; +} + static zend_string *phar_resolve_path(zend_string *filename) { zend_string *ret = phar_find_in_include_path(filename); @@ -3186,7 +3206,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) if (!file_handle || !file_handle->filename) { return phar_orig_compile_file(file_handle, type); } - if (strstr(ZSTR_VAL(file_handle->filename), ".phar") && !strstr(ZSTR_VAL(file_handle->filename), "://")) { + if (phar_has_marker_in_filename(file_handle->filename) && !strstr(ZSTR_VAL(file_handle->filename), "://")) { if (SUCCESS == phar_open_from_filename(ZSTR_VAL(file_handle->filename), ZSTR_LEN(file_handle->filename), NULL, 0, &phar, NULL)) { if (phar->is_zip || phar->is_tar) { zend_file_handle f; diff --git a/ext/phar/tests/include_file_extension.phpt b/ext/phar/tests/include_file_extension.phpt new file mode 100644 index 000000000000..2e95c0dc324b --- /dev/null +++ b/ext/phar/tests/include_file_extension.phpt @@ -0,0 +1,58 @@ +--TEST-- +Phar: only .phar extensions in file names trigger automatic archive detection +--EXTENSIONS-- +phar +zlib +--INI-- +phar.readonly=0 +phar.require_hash=0 +--FILE-- + $target) { + $source = $base . ".source-$i.phar.zip"; + $constant = "PHAR_STUB_EXECUTED_$i"; + + $phar = new Phar($source); + $phar->addFromString('payload', 'payload'); + $phar->setStub("compressFiles(Phar::GZ); + unset($phar); + + rename($source, $target); + + ob_start(); + include $target; + ob_end_clean(); + + var_dump(defined($constant)); +} +?> +--CLEAN-- + +--EXPECT-- +bool(true) +bool(false) +bool(false) +bool(true)