From 42c87517450a736f83875b1153d436418292310b Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 19 Jun 2025 15:00:31 +0200 Subject: [PATCH 1/7] Zend/zend_execute: make some functions private --- Zend/zend_execute.c | 12 ++++++------ Zend/zend_execute.h | 7 ------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 5d8d9f4caeb86..b1fb4b1d7451e 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -815,7 +815,7 @@ static bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask, } #endif -ZEND_API bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool strict, bool is_internal_arg) +static bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool strict, bool is_internal_arg) { if (UNEXPECTED(strict)) { /* SSTH Exception: IS_LONG may be accepted as IS_DOUBLE (converted) */ @@ -836,7 +836,7 @@ ZEND_API bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool s return zend_verify_weak_scalar_type_hint(type_mask, arg); } -ZEND_COLD zend_never_inline void zend_verify_class_constant_type_error(const zend_class_constant *c, const zend_string *name, const zval *constant) +static ZEND_COLD zend_never_inline void zend_verify_class_constant_type_error(const zend_class_constant *c, const zend_string *name, const zval *constant) { zend_string *type_str = zend_type_to_string(c->type); @@ -846,7 +846,7 @@ ZEND_COLD zend_never_inline void zend_verify_class_constant_type_error(const zen zend_string_release(type_str); } -ZEND_COLD zend_never_inline void zend_verify_property_type_error(const zend_property_info *info, const zval *property) +static ZEND_COLD zend_never_inline void zend_verify_property_type_error(const zend_property_info *info, const zval *property) { zend_string *type_str; @@ -864,7 +864,7 @@ ZEND_COLD zend_never_inline void zend_verify_property_type_error(const zend_prop zend_string_release(type_str); } -ZEND_COLD zend_never_inline void zend_magic_get_property_type_inconsistency_error(const zend_property_info *info, const zval *property) +static ZEND_COLD zend_never_inline void zend_magic_get_property_type_inconsistency_error(const zend_property_info *info, const zval *property) { /* we _may_ land here in case reading already errored and runtime cache thus has not been updated (i.e. it contains a valid but unrelated info) */ if (EG(exception)) { @@ -3778,7 +3778,7 @@ ZEND_API zval* ZEND_FASTCALL zend_fetch_static_property(zend_execute_data *ex, i return result; } -ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(const zend_property_info *prop1, const zend_property_info *prop2, const zval *zv) { +static ZEND_COLD void zend_throw_ref_type_error_type(const zend_property_info *prop1, const zend_property_info *prop2, const zval *zv) { zend_string *type1_str = zend_type_to_string(prop1->type); zend_string *type2_str = zend_type_to_string(prop2->type); zend_type_error("Reference with value of type %s held by property %s::$%s of type %s is not compatible with property %s::$%s of type %s", @@ -3794,7 +3794,7 @@ ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(const zend_property_info zend_string_release(type2_str); } -ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(const zend_property_info *prop, const zval *zv) { +static ZEND_COLD void zend_throw_ref_type_error_zval(const zend_property_info *prop, const zval *zv) { zend_string *type_str = zend_type_to_string(prop->type); zend_type_error("Cannot assign %s to reference held by property %s::$%s of type %s", zend_zval_value_name(zv), diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index cf15c9e3b2db5..4a84ad3b92735 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -80,8 +80,6 @@ typedef enum { ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref_ex(const zend_property_info *prop_info, zval *orig_val, bool strict, zend_verify_prop_assignable_by_ref_context context); ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref(const zend_property_info *prop_info, zval *orig_val, bool strict); -ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(const zend_property_info *prop, const zval *zv); -ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(const zend_property_info *prop1, const zend_property_info *prop2, const zval *zv); ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval); ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset); ZEND_API ZEND_COLD void zend_wrong_string_offset_error(void); @@ -99,7 +97,6 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_cannot_add_element(void); ZEND_API bool ZEND_FASTCALL zend_asymmetric_property_has_set_access(const zend_property_info *prop_info); ZEND_API ZEND_COLD void ZEND_FASTCALL zend_asymmetric_visibility_property_modification_error(const zend_property_info *prop_info, const char *operation); -ZEND_API bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool strict, bool is_internal_arg); ZEND_API ZEND_COLD void zend_verify_arg_error( const zend_function *zf, const zend_arg_info *arg_info, uint32_t arg_num, const zval *value); ZEND_API ZEND_COLD void zend_verify_return_error( @@ -577,13 +574,9 @@ ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *cal #define ZEND_CLASS_HAS_TYPE_HINTS(ce) ((bool)(ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS)) #define ZEND_CLASS_HAS_READONLY_PROPS(ce) ((bool)(ce->ce_flags & ZEND_ACC_HAS_READONLY_PROPS)) - ZEND_API bool zend_verify_class_constant_type(const zend_class_constant *c, const zend_string *name, zval *constant); -ZEND_COLD void zend_verify_class_constant_type_error(const zend_class_constant *c, const zend_string *name, const zval *constant); ZEND_API bool zend_verify_property_type(const zend_property_info *info, zval *property, bool strict); -ZEND_COLD void zend_verify_property_type_error(const zend_property_info *info, const zval *property); -ZEND_COLD void zend_magic_get_property_type_inconsistency_error(const zend_property_info *info, const zval *property); #define ZEND_REF_ADD_TYPE_SOURCE(ref, source) \ zend_ref_add_type_source(&ZEND_REF_TYPE_SOURCES(ref), source) From 2997d007100e32fe1660e84d137bdcb9a1c6d15d Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 19 Jun 2025 12:59:49 +0200 Subject: [PATCH 2/7] Deprecate type juggling to/from bool for function context --- Zend/tests/017.phpt | 2 - Zend/tests/arrow_functions/007.phpt | 4 +- .../backtrace/debug_backtrace_options.phpt | 142 +------------- Zend/tests/bug36513.phpt | 2 +- Zend/tests/bug39944.phpt | 4 +- Zend/tests/bug79022.phpt | 4 +- .../call_user_func_strict_arginfo_check.phpt | 4 +- Zend/tests/class_alias/class_alias_007.phpt | 2 +- Zend/tests/dynamic_call/bug47880.phpt | 2 +- Zend/tests/exit/exit_values.phpt | 10 +- Zend/tests/number_or_str_zpp.phpt | 8 + Zend/tests/property_hooks/recursion.phpt | 4 +- .../false_no_coercion_on_overload.phpt | 3 +- .../true_no_coercion_on_overload.phpt | 3 +- .../tests/type_declarations/scalar_basic.phpt | 33 +++- .../scalar_return_basic_64bit.phpt | 15 ++ .../scalar_weak_reference.phpt | 4 +- .../union_types/type_checking_weak.phpt | 124 ++++++------ .../weak_bool/from_bool.phpt | 97 ++++++++++ .../type_declarations/weak_bool/to_bool.phpt | 70 +++++++ Zend/zend_API.c | 177 +++++++++++++++++- Zend/zend_execute.c | 44 ++--- Zend/zend_execute.h | 2 +- Zend/zend_vm_def.h | 2 +- Zend/zend_vm_execute.h | 10 +- ext/opcache/jit/zend_jit_helpers.c | 4 +- ext/phar/phar/clicommand.inc | 2 +- ext/phar/phar/phar.php | 4 +- ext/phar/phar/pharcommand.inc | 2 +- 29 files changed, 509 insertions(+), 275 deletions(-) create mode 100644 Zend/tests/type_declarations/weak_bool/from_bool.phpt create mode 100644 Zend/tests/type_declarations/weak_bool/to_bool.phpt diff --git a/Zend/tests/017.phpt b/Zend/tests/017.phpt index 619365cbce17f..1c4407c69ef63 100644 --- a/Zend/tests/017.phpt +++ b/Zend/tests/017.phpt @@ -28,7 +28,6 @@ var_dump(count(get_defined_functions())); var_dump(gettype(get_declared_interfaces())); var_dump(count(get_declared_interfaces())); -var_dump(get_extension_funcs(true)); var_dump(gettype(get_extension_funcs("standard"))); var_dump(count(get_extension_funcs("standard"))); var_dump(gettype(get_extension_funcs("zend"))); @@ -51,7 +50,6 @@ string(5) "array" int(%d) string(5) "array" int(%d) -bool(false) string(5) "array" int(%d) string(5) "array" diff --git a/Zend/tests/arrow_functions/007.phpt b/Zend/tests/arrow_functions/007.phpt index 66b03b84c2e93..d5cdf7b106e38 100644 --- a/Zend/tests/arrow_functions/007.phpt +++ b/Zend/tests/arrow_functions/007.phpt @@ -12,7 +12,7 @@ try { } try { - assert((fn&(int... $args): ?bool => $args[0])(false)); + assert((fn&(int... $args): ?int => $args[0])(0)); } catch (AssertionError $e) { echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL; } @@ -20,4 +20,4 @@ try { ?> --EXPECT-- assert(): assert((fn() => false)()) failed -assert(): assert((fn&(int ...$args): ?bool => $args[0])(false)) failed +assert(): assert((fn&(int ...$args): ?int => $args[0])(0)) failed diff --git a/Zend/tests/backtrace/debug_backtrace_options.phpt b/Zend/tests/backtrace/debug_backtrace_options.phpt index 460bbe3936ff7..955dcc7038481 100644 --- a/Zend/tests/backtrace/debug_backtrace_options.phpt +++ b/Zend/tests/backtrace/debug_backtrace_options.phpt @@ -16,10 +16,6 @@ function doit($a, $b, $how) { echo "==default\n"; $how(); - echo "==true\n"; - $how(true); - echo "==false\n"; - $how(false); echo "==DEBUG_BACKTRACE_PROVIDE_OBJECT\n"; $how(DEBUG_BACKTRACE_PROVIDE_OBJECT); echo "==DEBUG_BACKTRACE_IGNORE_ARGS\n"; @@ -48,14 +44,6 @@ foo::statCall("doit", "backtrace_print"); #0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...') #1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...') #2 %sdebug_backtrace_options.php(%d): foo::statCall('doit', 'debug_print_bac...') -==true -#0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...') -#1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...') -#2 %sdebug_backtrace_options.php(%d): foo::statCall('doit', 'debug_print_bac...') -==false -#0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...') -#1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...') -#2 %sdebug_backtrace_options.php(%d): foo::statCall('doit', 'debug_print_bac...') ==DEBUG_BACKTRACE_PROVIDE_OBJECT #0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...') #1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...') @@ -130,130 +118,6 @@ Array ) -) -==true -Array -( - [0] => Array - ( - [file] => %sdebug_backtrace_options.php - [line] => 17 - [function] => backtrace_print - [args] => Array - ( - [0] => 1 - ) - - ) - - [1] => Array - ( - [file] => %sdebug_backtrace_options.php - [line] => %d - [function] => doit - [args] => Array - ( - [0] => a - [1] => b - [2] => backtrace_print - ) - - ) - - [2] => Array - ( - [file] => %sdebug_backtrace_options.php - [line] => %d - [function] => doCall - [class] => foo - [object] => foo Object - ( - ) - - [type] => -> - [args] => Array - ( - [0] => doit - [1] => backtrace_print - ) - - ) - - [3] => Array - ( - [file] => %sdebug_backtrace_options.php - [line] => %d - [function] => statCall - [class] => foo - [type] => :: - [args] => Array - ( - [0] => doit - [1] => backtrace_print - ) - - ) - -) -==false -Array -( - [0] => Array - ( - [file] => %sdebug_backtrace_options.php - [line] => 19 - [function] => backtrace_print - [args] => Array - ( - [0] => - ) - - ) - - [1] => Array - ( - [file] => %sdebug_backtrace_options.php - [line] => %d - [function] => doit - [args] => Array - ( - [0] => a - [1] => b - [2] => backtrace_print - ) - - ) - - [2] => Array - ( - [file] => %sdebug_backtrace_options.php - [line] => %d - [function] => doCall - [class] => foo - [type] => -> - [args] => Array - ( - [0] => doit - [1] => backtrace_print - ) - - ) - - [3] => Array - ( - [file] => %sdebug_backtrace_options.php - [line] => %d - [function] => statCall - [class] => foo - [type] => :: - [args] => Array - ( - [0] => doit - [1] => backtrace_print - ) - - ) - ) ==DEBUG_BACKTRACE_PROVIDE_OBJECT Array @@ -261,7 +125,7 @@ Array [0] => Array ( [file] => %sdebug_backtrace_options.php - [line] => 21 + [line] => 17 [function] => backtrace_print [args] => Array ( @@ -325,7 +189,7 @@ Array [0] => Array ( [file] => %sdebug_backtrace_options.php - [line] => 23 + [line] => 19 [function] => backtrace_print ) @@ -361,7 +225,7 @@ Array [0] => Array ( [file] => %sdebug_backtrace_options.php - [line] => 25 + [line] => 21 [function] => backtrace_print ) diff --git a/Zend/tests/bug36513.phpt b/Zend/tests/bug36513.phpt index f7b813b6f7847..f43052ca9e575 100644 --- a/Zend/tests/bug36513.phpt +++ b/Zend/tests/bug36513.phpt @@ -3,7 +3,7 @@ Bug #36513 (comment will be output in last line) --FILE-- Add("xx1"); $objRefTest->Add("xx2"); $objRefTest->Add("xx3"); -echo "objRefTest->getArray() = " . print_r($objRefTest->getArray(), 1); +echo "objRefTest->getArray() = " . print_r($objRefTest->getArray(), true); ?> --EXPECT-- intTheValue = 10 diff --git a/Zend/tests/bug79022.phpt b/Zend/tests/bug79022.phpt index 904195518ee55..cd63bf729cfd7 100644 --- a/Zend/tests/bug79022.phpt +++ b/Zend/tests/bug79022.phpt @@ -3,7 +3,7 @@ Bug #79022 (class_exists returns True for classes that are not ready to be used) --FILE-- --EXPECT-- -int(0) +int(2) diff --git a/Zend/tests/class_alias/class_alias_007.phpt b/Zend/tests/class_alias/class_alias_007.phpt index eb953dc15c95f..a315b52d38fc8 100644 --- a/Zend/tests/class_alias/class_alias_007.phpt +++ b/Zend/tests/class_alias/class_alias_007.phpt @@ -7,7 +7,7 @@ spl_autoload_register(function ($a) { class foo { } }); -class_alias('foo', 'bar', 1); +class_alias('foo', 'bar', true); var_dump(new foo, new bar); diff --git a/Zend/tests/dynamic_call/bug47880.phpt b/Zend/tests/dynamic_call/bug47880.phpt index bf2022c8094d8..8c363a5b5b229 100644 --- a/Zend/tests/dynamic_call/bug47880.phpt +++ b/Zend/tests/dynamic_call/bug47880.phpt @@ -4,7 +4,7 @@ Bug #47880 (crashes in call_user_func_array()) prop2)); var_dump($test); ?> ---EXPECT-- +--EXPECTF-- int(40) bool(true) + +Deprecated: Test::$prop2::get(): Returning type bool which is implicitly converted to type int is deprecated in %s on line %d bool(true) object(Test)#1 (1) { ["prop"]=> diff --git a/Zend/tests/type_declarations/literal_types/false_no_coercion_on_overload.phpt b/Zend/tests/type_declarations/literal_types/false_no_coercion_on_overload.phpt index 726245705ffc5..87194889df654 100644 --- a/Zend/tests/type_declarations/literal_types/false_no_coercion_on_overload.phpt +++ b/Zend/tests/type_declarations/literal_types/false_no_coercion_on_overload.phpt @@ -26,6 +26,7 @@ try { } ?> ---EXPECT-- +--EXPECTF-- +Deprecated: P::foo(): Returning type int which is implicitly converted to type bool is deprecated in %s on line %d bool(false) C::foo(): Return value must be of type array|false, int returned diff --git a/Zend/tests/type_declarations/literal_types/true_no_coercion_on_overload.phpt b/Zend/tests/type_declarations/literal_types/true_no_coercion_on_overload.phpt index 7eebe1e3571f0..0be5e720784a9 100644 --- a/Zend/tests/type_declarations/literal_types/true_no_coercion_on_overload.phpt +++ b/Zend/tests/type_declarations/literal_types/true_no_coercion_on_overload.phpt @@ -26,6 +26,7 @@ try { } ?> ---EXPECT-- +--EXPECTF-- +Deprecated: P::foo(): Returning type int which is implicitly converted to type bool is deprecated in %s on line %d bool(true) C::foo(): Return value must be of type array|true, int returned diff --git a/Zend/tests/type_declarations/scalar_basic.phpt b/Zend/tests/type_declarations/scalar_basic.phpt index 6b2cf736edbf9..3e90c9e81ee1a 100644 --- a/Zend/tests/type_declarations/scalar_basic.phpt +++ b/Zend/tests/type_declarations/scalar_basic.phpt @@ -72,7 +72,7 @@ int(1) int(1) *** Trying float(1.5) -E_DEPRECATED: Implicit conversion from float 1.5 to int loses precision on line 14 +E_DEPRECATED: Implicit conversion from float 1.5 to int loses precision on line %d int(1) *** Trying string(2) "1a" @@ -91,9 +91,11 @@ int(%d) *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, float given, called in %s on line %d *** Trying bool(true) +E_DEPRECATED: {closure:%s:%d}(): Passing bool to parameter #1 ($i) of type int is deprecated on line %d int(1) *** Trying bool(false) +E_DEPRECATED: {closure:%s:%d}(): Passing bool to parameter #1 ($i) of type int is deprecated on line %d int(0) *** Trying NULL @@ -103,11 +105,11 @@ int(0) } *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, array given, called in %s on line %d -*** Trying object(stdClass)#%s (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#%s (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, StringCapable given, called in %s on line %d @@ -144,9 +146,11 @@ float(%s) float(NAN) *** Trying bool(true) +E_DEPRECATED: {closure:%s:%d}(): Passing bool to parameter #1 ($f) of type float is deprecated on line %d float(1) *** Trying bool(false) +E_DEPRECATED: {closure:%s:%d}(): Passing bool to parameter #1 ($f) of type float is deprecated on line %d float(0) *** Trying NULL @@ -156,11 +160,11 @@ float(0) } *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, array given, called in %s on line %d -*** Trying object(stdClass)#%s (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#%s (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, StringCapable given, called in %s on line %d @@ -197,9 +201,11 @@ string(%d) "%d" string(3) "NAN" *** Trying bool(true) +E_DEPRECATED: {closure:%s:%d}(): Passing bool to parameter #1 ($s) of type string is deprecated on line %d string(1) "1" *** Trying bool(false) +E_DEPRECATED: {closure:%s:%d}(): Passing bool to parameter #1 ($s) of type string is deprecated on line %d string(0) "" *** Trying NULL @@ -209,11 +215,11 @@ string(0) "" } *** Caught {closure:%s:%d}(): Argument #1 ($s) must be of type string, array given, called in %s on line %d -*** Trying object(stdClass)#%s (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($s) must be of type string, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#%s (0) { +*** Trying object(StringCapable)#%d (0) { } string(6) "foobar" @@ -223,30 +229,39 @@ string(6) "foobar" Testing 'bool' type: *** Trying int(1) +E_DEPRECATED: {closure:%s:%d}(): Passing int to parameter #1 ($b) of type bool is deprecated on line %d bool(true) *** Trying string(1) "1" +E_DEPRECATED: {closure:%s:%d}(): Passing string to parameter #1 ($b) of type bool is deprecated on line %d bool(true) *** Trying float(1) +E_DEPRECATED: {closure:%s:%d}(): Passing float to parameter #1 ($b) of type bool is deprecated on line %d bool(true) *** Trying float(1.5) +E_DEPRECATED: {closure:%s:%d}(): Passing float to parameter #1 ($b) of type bool is deprecated on line %d bool(true) *** Trying string(2) "1a" +E_DEPRECATED: {closure:%s:%d}(): Passing string to parameter #1 ($b) of type bool is deprecated on line %d bool(true) *** Trying string(1) "a" +E_DEPRECATED: {closure:%s:%d}(): Passing string to parameter #1 ($b) of type bool is deprecated on line %d bool(true) *** Trying string(0) "" +E_DEPRECATED: {closure:%s:%d}(): Passing string to parameter #1 ($b) of type bool is deprecated on line %d bool(false) *** Trying int(%d) +E_DEPRECATED: {closure:%s:%d}(): Passing int to parameter #1 ($b) of type bool is deprecated on line %d bool(true) *** Trying float(NAN) +E_DEPRECATED: {closure:%s:%d}(): Passing float to parameter #1 ($b) of type bool is deprecated on line %d bool(true) *** Trying bool(true) @@ -262,11 +277,11 @@ bool(false) } *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, array given, called in %s on line %d -*** Trying object(stdClass)#%s (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#%s (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, StringCapable given, called in %s on line %d diff --git a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt index 0a32dd3f16f23..8a677fec42477 100644 --- a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt +++ b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt @@ -84,8 +84,10 @@ int(9223372036854775807) *** Trying float(NAN) *** Caught {closure:%s:%d}(): Return value must be of type int, float returned in %s on line %d *** Trying bool(true) +E_DEPRECATED: {closure:%s:%d}(): Returning type bool which is implicitly converted to type int is deprecated on line %d int(1) *** Trying bool(false) +E_DEPRECATED: {closure:%s:%d}(): Returning type bool which is implicitly converted to type int is deprecated on line %d int(0) *** Trying NULL *** Caught {closure:%s:%d}(): Return value must be of type int, null returned in %s on line %d @@ -121,8 +123,10 @@ float(9.223372036854776E+18) *** Trying float(NAN) float(NAN) *** Trying bool(true) +E_DEPRECATED: {closure:%s:%d}(): Returning type bool which is implicitly converted to type float is deprecated on line %d float(1) *** Trying bool(false) +E_DEPRECATED: {closure:%s:%d}(): Returning type bool which is implicitly converted to type float is deprecated on line %d float(0) *** Trying NULL *** Caught {closure:%s:%d}(): Return value must be of type float, null returned in %s on line %d @@ -158,8 +162,10 @@ string(19) "9223372036854775807" *** Trying float(NAN) string(3) "NAN" *** Trying bool(true) +E_DEPRECATED: {closure:%s:%d}(): Returning type bool which is implicitly converted to type string is deprecated on line %d string(1) "1" *** Trying bool(false) +E_DEPRECATED: {closure:%s:%d}(): Returning type bool which is implicitly converted to type string is deprecated on line %d string(0) "" *** Trying NULL *** Caught {closure:%s:%d}(): Return value must be of type string, null returned in %s on line %d @@ -177,22 +183,31 @@ string(6) "foobar" Testing 'bool' type: *** Trying int(1) +E_DEPRECATED: {closure:%s:%d}(): Returning type int which is implicitly converted to type bool is deprecated on line %d bool(true) *** Trying string(1) "1" +E_DEPRECATED: {closure:%s:%d}(): Returning type string which is implicitly converted to type bool is deprecated on line %d bool(true) *** Trying float(1) +E_DEPRECATED: {closure:%s:%d}(): Returning type float which is implicitly converted to type bool is deprecated on line %d bool(true) *** Trying float(1.5) +E_DEPRECATED: {closure:%s:%d}(): Returning type float which is implicitly converted to type bool is deprecated on line %d bool(true) *** Trying string(2) "1a" +E_DEPRECATED: {closure:%s:%d}(): Returning type string which is implicitly converted to type bool is deprecated on line %d bool(true) *** Trying string(1) "a" +E_DEPRECATED: {closure:%s:%d}(): Returning type string which is implicitly converted to type bool is deprecated on line %d bool(true) *** Trying string(0) "" +E_DEPRECATED: {closure:%s:%d}(): Returning type string which is implicitly converted to type bool is deprecated on line %d bool(false) *** Trying int(9223372036854775807) +E_DEPRECATED: {closure:%s:%d}(): Returning type int which is implicitly converted to type bool is deprecated on line %d bool(true) *** Trying float(NAN) +E_DEPRECATED: {closure:%s:%d}(): Returning type float which is implicitly converted to type bool is deprecated on line %d bool(true) *** Trying bool(true) bool(true) diff --git a/Zend/tests/type_declarations/scalar_weak_reference.phpt b/Zend/tests/type_declarations/scalar_weak_reference.phpt index 74069689e6e6f..5247c46fa81ff 100644 --- a/Zend/tests/type_declarations/scalar_weak_reference.phpt +++ b/Zend/tests/type_declarations/scalar_weak_reference.phpt @@ -21,9 +21,11 @@ var_dump($x); to_bool($x); var_dump($x); ?> ---EXPECT-- +--EXPECTF-- float(1) int(1) float(1) string(1) "1" + +Deprecated: to_bool(): Passing string to parameter #1 ($x) of type bool is deprecated in %s on line %d bool(true) diff --git a/Zend/tests/type_declarations/union_types/type_checking_weak.phpt b/Zend/tests/type_declarations/union_types/type_checking_weak.phpt index 9031b002b2a09..03c8a7808d914 100644 --- a/Zend/tests/type_declarations/union_types/type_checking_weak.phpt +++ b/Zend/tests/type_declarations/union_types/type_checking_weak.phpt @@ -66,15 +66,15 @@ Type int|float: INF => INF "42" => 42 "42.0" => 42.0 -"42x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, string given -"x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, string given -"" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, string given -true => 1 -false => 0 -null => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, null given -[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, array given -new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, stdClass given -new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, WithToString given +"42x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, string given +"x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, string given +"" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, string given +true => 1 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type int|float is deprecated) +false => 0 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type int|float is deprecated) +null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, null given +[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, array given +new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, stdClass given +new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, WithToString given Type int|float|false: 42 => 42 @@ -82,15 +82,15 @@ Type int|float|false: INF => INF "42" => 42 "42.0" => 42.0 -"42x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, string given -"x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, string given -"" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, string given -true => 1 +"42x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, string given +"x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, string given +"" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, string given +true => 1 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type int|float|false is deprecated) false => false -null => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, null given -[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, array given -new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, stdClass given -new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, WithToString given +null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, null given +[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, array given +new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, stdClass given +new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, WithToString given Type int|float|bool: 42 => 42 @@ -98,31 +98,31 @@ Type int|float|bool: INF => INF "42" => 42 "42.0" => 42.0 -"42x" => true -"x" => true -"" => false +"42x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|float|bool is deprecated) +"x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|float|bool is deprecated) +"" => false ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|float|bool is deprecated) true => true false => false -null => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|bool, null given -[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|bool, array given -new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|bool, stdClass given -new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|bool, WithToString given +null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|bool, null given +[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|bool, array given +new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|bool, stdClass given +new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|bool, WithToString given Type int|bool: 42 => 42 42.0 => 42 -INF => true +INF => true ({%s(%d) : eval()'d code:1}(): Passing float to parameter #1 ($arg) of type int|bool is deprecated) "42" => 42 "42.0" => 42 -"42x" => true -"x" => true -"" => false +"42x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|bool is deprecated) +"x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|bool is deprecated) +"" => false ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|bool is deprecated) true => true false => false -null => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|bool, null given -[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|bool, array given -new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|bool, stdClass given -new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|bool, WithToString given +null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|bool, null given +[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|bool, array given +new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|bool, stdClass given +new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|bool, WithToString given Type int|string|null: 42 => 42 @@ -133,11 +133,11 @@ INF => "INF" "42x" => "42x" "x" => "x" "" => "" -true => 1 -false => 0 +true => 1 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type string|int|null is deprecated) +false => 0 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type string|int|null is deprecated) null => null -[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type string|int|null, array given -new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type string|int|null, stdClass given +[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type string|int|null, array given +new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type string|int|null, stdClass given new WithToString => "__toString()" Type string|bool: @@ -151,9 +151,9 @@ INF => "INF" "" => "" true => true false => false -null => {closure:%s:%d}(): Argument #1 ($arg) must be of type string|bool, null given -[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type string|bool, array given -new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type string|bool, stdClass given +null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type string|bool, null given +[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type string|bool, array given +new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type string|bool, stdClass given new WithToString => "__toString()" Type float|array: @@ -162,15 +162,15 @@ Type float|array: INF => INF "42" => 42.0 "42.0" => 42.0 -"42x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, string given -"x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, string given -"" => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, string given -true => 1.0 -false => 0.0 -null => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, null given +"42x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, string given +"x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, string given +"" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, string given +true => 1.0 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type array|float is deprecated) +false => 0.0 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type array|float is deprecated) +null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, null given [] => [] -new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, stdClass given -new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, WithToString given +new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, stdClass given +new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, WithToString given Type string|array: 42 => "42" @@ -181,25 +181,25 @@ INF => "INF" "42x" => "42x" "x" => "x" "" => "" -true => "1" -false => "" -null => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|string, null given +true => "1" ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type array|string is deprecated) +false => "" ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type array|string is deprecated) +null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|string, null given [] => [] -new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|string, stdClass given +new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|string, stdClass given new WithToString => "__toString()" Type bool|array: -42 => true -42.0 => true -INF => true -"42" => true -"42.0" => true -"42x" => true -"x" => true -"" => false +42 => true ({%s(%d) : eval()'d code:1}(): Passing int to parameter #1 ($arg) of type array|bool is deprecated) +42.0 => true ({%s(%d) : eval()'d code:1}(): Passing float to parameter #1 ($arg) of type array|bool is deprecated) +INF => true ({%s(%d) : eval()'d code:1}(): Passing float to parameter #1 ($arg) of type array|bool is deprecated) +"42" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) +"42.0" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) +"42x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) +"x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) +"" => false ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) true => true false => false -null => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|bool, null given +null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|bool, null given [] => [] -new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|bool, stdClass given -new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|bool, WithToString given +new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|bool, stdClass given +new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|bool, WithToString given diff --git a/Zend/tests/type_declarations/weak_bool/from_bool.phpt b/Zend/tests/type_declarations/weak_bool/from_bool.phpt new file mode 100644 index 0000000000000..d8fca2631cd62 --- /dev/null +++ b/Zend/tests/type_declarations/weak_bool/from_bool.phpt @@ -0,0 +1,97 @@ +--TEST-- +Check deprecation from bool type in weak mode +--FILE-- +v = true; +var_dump($o->v); + +echo "float:\n"; +function fpf(float $v) { + var_dump($v); +} + +function frf($v): float { + var_dump($v); + return $v; +} + +class CF { + public float $v; +} +$o = new CF(); + +fpf(true); +frf(true); +$o->v = true; +var_dump($o->v); + +echo "string:\n"; +function fps(string $v) { + var_dump($v); +} + +function frs($v): string { + var_dump($v); + return $v; +} + +class CS { + public string $v; +} +$o = new CS(); + +fps(true); +frs(true); +$o->v = true; +var_dump($o->v); + +?> +--EXPECTF-- +int: + +Deprecated: fpi(): Passing bool to parameter #1 ($v) of type int is deprecated in %s on line %d +int(1) +bool(true) + +Deprecated: fri(): Returning type bool which is implicitly converted to type int is deprecated in %s on line %d + +Deprecated: Assigning bool to typed property which is implicitly converted to type int is deprecated in %s on line %d +int(1) +float: + +Deprecated: fpf(): Passing bool to parameter #1 ($v) of type float is deprecated in %s on line %d +float(1) +bool(true) + +Deprecated: frf(): Returning type bool which is implicitly converted to type float is deprecated in %s on line %d + +Deprecated: Assigning bool to typed property which is implicitly converted to type float is deprecated in %s on line %d +float(1) +string: + +Deprecated: fps(): Passing bool to parameter #1 ($v) of type string is deprecated in %s on line %d +string(1) "1" +bool(true) + +Deprecated: frs(): Returning type bool which is implicitly converted to type string is deprecated in %s on line %d + +Deprecated: Assigning bool to typed property which is implicitly converted to type string is deprecated in %s on line %d +string(1) "1" diff --git a/Zend/tests/type_declarations/weak_bool/to_bool.phpt b/Zend/tests/type_declarations/weak_bool/to_bool.phpt new file mode 100644 index 0000000000000..5f8b905d87492 --- /dev/null +++ b/Zend/tests/type_declarations/weak_bool/to_bool.phpt @@ -0,0 +1,70 @@ +--TEST-- +Check deprecation to bool type in weak mode +--FILE-- +b = 42; +var_dump($o->b); + +echo "float:\n"; +foo(2.5); +bar(12.5); +$o->b = 12.5; +var_dump($o->b); + +echo "string:\n"; +foo("hello"); +bar("hello"); +$o->b = "hello"; +var_dump($o->b); + +?> +--EXPECTF-- +int: + +Deprecated: foo(): Passing int to parameter #1 ($b) of type bool is deprecated in %s on line %d +bool(true) +int(42) + +Deprecated: bar(): Returning type int which is implicitly converted to type bool is deprecated in %s on line %d + +Deprecated: Assigning int to type property which is implicitly converted to type bool is deprecated in %s on line %d +bool(true) +float: + +Deprecated: foo(): Passing float to parameter #1 ($b) of type bool is deprecated in %s on line %d +bool(true) +float(12.5) + +Deprecated: bar(): Returning type float which is implicitly converted to type bool is deprecated in %s on line %d + +Deprecated: Assigning float to type property which is implicitly converted to type bool is deprecated in %s on line %d +bool(true) +string: + +Deprecated: foo(): Passing string to parameter #1 ($b) of type bool is deprecated in %s on line %d +bool(true) +string(5) "hello" + +Deprecated: bar(): Returning type string which is implicitly converted to type bool is deprecated in %s on line %d + +Deprecated: Assigning string to type property which is implicitly converted to type bool is deprecated in %s on line %d +bool(true) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index e0006e7d7275f..7891e66436d25 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -523,12 +523,130 @@ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32 return !EG(exception); } +static ZEND_COLD bool zend_arg_from_bool_deprecated(const char *fallback_type, const uint32_t arg_num) { + /* Check arg_num is not (uint32_t)-1, as otherwise its called by + * zend_verify_weak_scalar_type_hint_no_sideeffect() */ + if (arg_num == (uint32_t)-1) { + return true; + } + /* Dealing with a class constant assignment should never happen */ + if (arg_num == (uint32_t)-3) { + ZEND_UNREACHABLE(); + return false; + } + + /* Dealing with a property */ + if (arg_num == (uint32_t)-2) { + /* Not enough info for a good error message */ + zend_error(E_DEPRECATED, + "Assigning bool to typed property which is implicitly converted to type %s is deprecated", + fallback_type + ); + return !EG(exception); + } + + zend_function *func = zend_active_function(); + zend_arg_info *arg_info = NULL; + zend_string *type_str = NULL; + if (arg_num != 0) { + uint32_t arg_offset = arg_num - 1; + if (arg_offset >= func->common.num_args) { + ZEND_ASSERT(func->common.fn_flags & ZEND_ACC_VARIADIC); + arg_offset = func->common.num_args; + } + arg_info = &func->common.arg_info[arg_offset]; + type_str = zend_type_to_string(arg_info->type); + } + zend_string *func_name = get_active_function_or_method_name(); + const char *type_param = type_str ? ZSTR_VAL(type_str) : fallback_type; + if (arg_num == 0) { + zend_error(E_DEPRECATED, + "%s(): Returning type bool which is implicitly converted to type %s is deprecated", + ZSTR_VAL(func_name), type_param + ); + } else { + const char *arg_name = get_active_function_arg_name(arg_num); + zend_error(E_DEPRECATED, + "%s(): Passing bool to parameter #%" PRIu32 "%s%s%s of type %s is deprecated", + ZSTR_VAL(func_name), arg_num, + arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "", + type_param + ); + } + zend_string_release(func_name); + if (type_str) { + zend_string_release(type_str); + } + return !EG(exception); +} + +static ZEND_COLD bool zend_arg_to_bool_deprecated(const zval *arg, uint32_t arg_num) { + /* Check arg_num is not (uint32_t)-1, as otherwise its called by + * zend_verify_weak_scalar_type_hint_no_sideeffect() */ + if (arg_num == (uint32_t)-1) { + return true; + } + /* Dealing with a class constant assignment should never happen */ + if (arg_num == (uint32_t)-3) { + ZEND_UNREACHABLE(); + return false; + } + + const char *type_arg = zend_zval_type_name(arg); + /* Dealing with a property */ + if (arg_num == (uint32_t)-2) { + /* Not enough info for a good error message */ + zend_error(E_DEPRECATED, + "Assigning %s to type property which is implicitly converted to type bool is deprecated", + type_arg + ); + return !EG(exception); + } + + zend_function *func = zend_active_function(); + zend_arg_info *arg_info = NULL; + zend_string *type_str = NULL; + if (arg_num != 0) { + uint32_t arg_offset = arg_num - 1; + if (arg_offset >= func->common.num_args) { + ZEND_ASSERT(func->common.fn_flags & ZEND_ACC_VARIADIC); + arg_offset = func->common.num_args; + } + arg_info = &func->common.arg_info[arg_offset]; + type_str = zend_type_to_string(arg_info->type); + } + zend_string *func_name = get_active_function_or_method_name(); + const char *type_param = type_str ? ZSTR_VAL(type_str) : "bool"; + if (arg_num == 0) { + zend_error(E_DEPRECATED, + "%s(): Returning type %s which is implicitly converted to type %s is deprecated", + ZSTR_VAL(func_name), type_arg, type_param + ); + } else { + const char *arg_name = get_active_function_arg_name(arg_num); + zend_error(E_DEPRECATED, + "%s(): Passing %s to parameter #%" PRIu32 "%s%s%s of type %s is deprecated", + ZSTR_VAL(func_name), type_arg, arg_num, + arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "", + type_param + ); + } + zend_string_release(func_name); + if (type_str) { + zend_string_release(type_str); + } + return !EG(exception); +} + ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(const zval *arg, bool *dest, uint32_t arg_num) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) { if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("bool", arg_num)) { return 0; } + if (UNEXPECTED(!zend_arg_to_bool_deprecated(arg, arg_num))) { + return 0; + } *dest = zend_is_true(arg); } else { return 0; @@ -611,11 +729,21 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(const zval *arg, zend_long return 0; } } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) { - if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("int", arg_num)) { - return 0; + if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) { + if (UNEXPECTED(!zend_null_arg_deprecated("int", arg_num))) { + return 0; + } + } else { + ZEND_ASSERT(Z_TYPE_P(arg) == IS_FALSE); + if (UNEXPECTED(!zend_arg_from_bool_deprecated("int", arg_num))) { + return 0; + } } *dest = 0; } else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) { + if (UNEXPECTED(!zend_arg_from_bool_deprecated("int", arg_num))) { + return 0; + } *dest = 1; } else { return 0; @@ -660,11 +788,21 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(const zval *arg, double * return 0; } } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) { - if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("float", arg_num)) { - return 0; + if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) { + if (UNEXPECTED(!zend_null_arg_deprecated("int", arg_num))) { + return 0; + } + } else { + ZEND_ASSERT(Z_TYPE_P(arg) == IS_FALSE); + if (UNEXPECTED(!zend_arg_from_bool_deprecated("float", arg_num))) { + return 0; + } } *dest = 0.0; } else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) { + if (UNEXPECTED(!zend_arg_from_bool_deprecated("float", arg_num))) { + return 0; + } *dest = 1.0; } else { return 0; @@ -704,11 +842,21 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest, u } zend_string_release(str); } else if (Z_TYPE_P(arg) < IS_TRUE) { - if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("int|float", arg_num)) { - return 0; + if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) { + if (UNEXPECTED(!zend_null_arg_deprecated("int", arg_num))) { + return 0; + } + } else { + ZEND_ASSERT(Z_TYPE_P(arg) == IS_FALSE); + if (UNEXPECTED(!zend_arg_from_bool_deprecated("int|float", arg_num))) { + return 0; + } } ZVAL_LONG(arg, 0); } else if (Z_TYPE_P(arg) == IS_TRUE) { + if (UNEXPECTED(!zend_arg_from_bool_deprecated("int|float", arg_num))) { + return 0; + } ZVAL_LONG(arg, 1); } else { return 0; @@ -725,11 +873,21 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_or_str_slow(zval *arg, zval ** return false; } if (Z_TYPE_P(arg) < IS_TRUE) { - if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("string|int|float", arg_num)) { - return false; + if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) { + if (UNEXPECTED(!zend_null_arg_deprecated("int", arg_num))) { + return 0; + } + } else { + ZEND_ASSERT(Z_TYPE_P(arg) == IS_FALSE); + if (UNEXPECTED(!zend_arg_from_bool_deprecated("string|int|float", arg_num))) { + return 0; + } } ZVAL_LONG(arg, 0); } else if (Z_TYPE_P(arg) == IS_TRUE) { + if (UNEXPECTED(!zend_arg_from_bool_deprecated("string|int|float", arg_num))) { + return 0; + } ZVAL_LONG(arg, 1); } else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) { zend_object *zobj = Z_OBJ_P(arg); @@ -753,6 +911,9 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **des if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) { if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("string", arg_num)) { return 0; + } else if (UNEXPECTED((Z_TYPE_P(arg) == IS_TRUE || Z_TYPE_P(arg) == IS_FALSE) + && !zend_arg_from_bool_deprecated("string", arg_num))) { + return 0; } convert_to_string(arg); *dest = Z_STR_P(arg); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index b1fb4b1d7451e..5ec5818fffcb0 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -730,7 +730,7 @@ ZEND_API ZEND_COLD void zend_verify_arg_error( zend_string_release(need_msg); } -static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg) +static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg, uint32_t arg_num) { zend_long lval; double dval; @@ -753,7 +753,7 @@ static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg) ZVAL_DOUBLE(arg, dval); return 1; } - } else if (zend_parse_arg_long_weak(arg, &lval, 0)) { + } else if (zend_parse_arg_long_weak(arg, &lval, arg_num)) { zval_ptr_dtor(arg); ZVAL_LONG(arg, lval); return 1; @@ -761,16 +761,16 @@ static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg) return 0; } } - if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, 0)) { + if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, arg_num)) { zval_ptr_dtor(arg); ZVAL_DOUBLE(arg, dval); return 1; } - if ((type_mask & MAY_BE_STRING) && zend_parse_arg_str_weak(arg, &str, 0)) { + if ((type_mask & MAY_BE_STRING) && zend_parse_arg_str_weak(arg, &str, arg_num)) { /* on success "arg" is converted to IS_STRING */ return 1; } - if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval, 0)) { + if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval, arg_num)) { zval_ptr_dtor(arg); ZVAL_BOOL(arg, bval); return 1; @@ -815,7 +815,7 @@ static bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask, } #endif -static bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool strict, bool is_internal_arg) +static bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool strict, bool is_internal_arg, uint32_t arg_num) { if (UNEXPECTED(strict)) { /* SSTH Exception: IS_LONG may be accepted as IS_DOUBLE (converted) */ @@ -833,7 +833,7 @@ static bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool str return zend_verify_weak_scalar_type_hint_no_sideeffect(type_mask, arg); } #endif - return zend_verify_weak_scalar_type_hint(type_mask, arg); + return zend_verify_weak_scalar_type_hint(type_mask, arg, arg_num); } static ZEND_COLD zend_never_inline void zend_verify_class_constant_type_error(const zend_class_constant *c, const zend_string *name, const zval *constant) @@ -1051,7 +1051,7 @@ static zend_always_inline bool i_zend_check_property_type(const zend_property_in uint32_t type_mask = ZEND_TYPE_FULL_MASK(info->type); ZEND_ASSERT(!(type_mask & (MAY_BE_CALLABLE|MAY_BE_STATIC|MAY_BE_NEVER|MAY_BE_VOID))); - return zend_verify_scalar_type_hint(type_mask, property, strict, 0); + return zend_verify_scalar_type_hint(type_mask, property, strict, false, (uint32_t)-2); } static zend_always_inline bool i_zend_verify_property_type(const zend_property_info *info, zval *property, bool strict) @@ -1150,7 +1150,7 @@ static bool zend_check_intersection_type_from_list( } static zend_always_inline bool zend_check_type_slow( - const zend_type *type, zval *arg, const zend_reference *ref, + const zend_type *type, zval *arg, uint32_t arg_num, const zend_reference *ref, bool is_return_type, bool is_internal) { if (ZEND_TYPE_IS_COMPLEX(*type) && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) { @@ -1206,14 +1206,14 @@ static zend_always_inline bool zend_check_type_slow( return zend_verify_scalar_type_hint(type_mask, arg, is_return_type ? ZEND_RET_USES_STRICT_TYPES() : ZEND_ARG_USES_STRICT_TYPES(), - is_internal); + is_internal, arg_num); /* Special handling for IS_VOID is not necessary (for return types), * because this case is already checked at compile-time. */ } static zend_always_inline bool zend_check_type( - const zend_type *type, zval *arg, zend_class_entry *scope, + const zend_type *type, zval *arg, uint32_t arg_num, zend_class_entry *scope, bool is_return_type, bool is_internal) { const zend_reference *ref = NULL; @@ -1228,14 +1228,14 @@ static zend_always_inline bool zend_check_type( return 1; } - return zend_check_type_slow(type, arg, ref, is_return_type, is_internal); + return zend_check_type_slow(type, arg, arg_num, ref, is_return_type, is_internal); } ZEND_API bool zend_check_user_type_slow( - const zend_type *type, zval *arg, const zend_reference *ref, bool is_return_type) + const zend_type *type, zval *arg, uint32_t arg_num, const zend_reference *ref, bool is_return_type) { return zend_check_type_slow( - type, arg, ref, is_return_type, /* is_internal */ false); + type, arg, arg_num, ref, is_return_type, /* is_internal */ false); } static zend_always_inline bool zend_verify_recv_arg_type(const zend_function *zf, uint32_t arg_num, zval *arg) @@ -1246,7 +1246,7 @@ static zend_always_inline bool zend_verify_recv_arg_type(const zend_function *zf cur_arg_info = &zf->common.arg_info[arg_num-1]; if (ZEND_TYPE_IS_SET(cur_arg_info->type) - && UNEXPECTED(!zend_check_type(&cur_arg_info->type, arg, zf->common.scope, 0, 0))) { + && UNEXPECTED(!zend_check_type(&cur_arg_info->type, arg, arg_num, zf->common.scope, 0, 0))) { zend_verify_arg_error(zf, cur_arg_info, arg_num, arg); return 0; } @@ -1258,7 +1258,7 @@ static zend_always_inline bool zend_verify_variadic_arg_type( const zend_function *zf, const zend_arg_info *arg_info, uint32_t arg_num, zval *arg) { ZEND_ASSERT(ZEND_TYPE_IS_SET(arg_info->type)); - if (UNEXPECTED(!zend_check_type(&arg_info->type, arg, zf->common.scope, 0, 0))) { + if (UNEXPECTED(!zend_check_type(&arg_info->type, arg, arg_num, zf->common.scope, 0, 0))) { zend_verify_arg_error(zf, arg_info, arg_num, arg); return 0; } @@ -1283,7 +1283,7 @@ static zend_never_inline ZEND_ATTRIBUTE_UNUSED bool zend_verify_internal_arg_typ } if (ZEND_TYPE_IS_SET(cur_arg_info->type) - && UNEXPECTED(!zend_check_type(&cur_arg_info->type, arg, fbc->common.scope, 0, /* is_internal */ 1))) { + && UNEXPECTED(!zend_check_type(&cur_arg_info->type, arg, i+1, fbc->common.scope, false, /* is_internal */ true))) { return 0; } arg++; @@ -1489,7 +1489,7 @@ ZEND_API bool zend_verify_internal_return_type(const zend_function *zf, zval *re return 1; } - if (UNEXPECTED(!zend_check_type(&ret_info->type, ret, NULL, 1, /* is_internal */ 1))) { + if (UNEXPECTED(!zend_check_type(&ret_info->type, ret, 0, NULL, 1, /* is_internal */ 1))) { zend_verify_internal_return_error(zf, ret); return 0; } @@ -1518,7 +1518,7 @@ static zend_always_inline bool zend_check_class_constant_type(const zend_class_c uint32_t type_mask = ZEND_TYPE_FULL_MASK(c->type); ZEND_ASSERT(!(type_mask & (MAY_BE_CALLABLE|MAY_BE_NEVER|MAY_BE_VOID))); - return zend_verify_scalar_type_hint(type_mask, constant, true, false); + return zend_verify_scalar_type_hint(type_mask, constant, true, false, (uint32_t)-3); } ZEND_API bool zend_never_inline zend_verify_class_constant_type(const zend_class_constant *c, const zend_string *name, zval *constant) @@ -3888,7 +3888,7 @@ ZEND_API bool ZEND_FASTCALL zend_verify_ref_assignable_zval(zend_reference *ref, first_prop = prop; ZVAL_COPY(&coerced_value, zv); if (!zend_verify_weak_scalar_type_hint( - ZEND_TYPE_FULL_MASK(prop->type), &coerced_value)) { + ZEND_TYPE_FULL_MASK(prop->type), &coerced_value, (uint32_t)-2)) { goto type_error; } } else if (Z_ISUNDEF(coerced_value)) { @@ -3898,7 +3898,7 @@ ZEND_API bool ZEND_FASTCALL zend_verify_ref_assignable_zval(zend_reference *ref, } else { zval tmp; ZVAL_COPY(&tmp, zv); - if (!zend_verify_weak_scalar_type_hint(ZEND_TYPE_FULL_MASK(prop->type), &tmp)) { + if (!zend_verify_weak_scalar_type_hint(ZEND_TYPE_FULL_MASK(prop->type), &tmp, (uint32_t)-2)) { zval_ptr_dtor(&tmp); goto type_error; } @@ -3999,7 +3999,7 @@ ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref_ex(const zend_pro * the value is simply illegal for the type, or because or a conflicting coercion. */ zval tmp; ZVAL_COPY(&tmp, val); - if (zend_verify_weak_scalar_type_hint(ZEND_TYPE_FULL_MASK(prop_info->type), &tmp)) { + if (zend_verify_weak_scalar_type_hint(ZEND_TYPE_FULL_MASK(prop_info->type), &tmp, (uint32_t)-2)) { const zend_property_info *ref_prop = ZEND_REF_FIRST_SOURCE(Z_REF_P(orig_val)); zend_throw_ref_type_error_type(ref_prop, prop_info, val); zval_ptr_dtor(&tmp); diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 4a84ad3b92735..402c1bcd1a4db 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -105,7 +105,7 @@ ZEND_API ZEND_COLD void zend_verify_never_error( const zend_function *zf); ZEND_API bool zend_verify_ref_array_assignable(zend_reference *ref); ZEND_API bool zend_check_user_type_slow( - const zend_type *type, zval *arg, const zend_reference *ref, bool is_return_type); + const zend_type *type, zval *arg, uint32_t arg_num, const zend_reference *ref, bool is_return_type); #if ZEND_DEBUG ZEND_API bool zend_internal_call_should_throw(const zend_function *fbc, zend_execute_data *call); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 617e114dd05db..8e5c2dd58ab62 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4481,7 +4481,7 @@ ZEND_VM_COLD_CONST_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV } SAVE_OPLINE(); - if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, ref, 1, 0))) { + if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, 0, ref, 1, 0))) { zend_verify_return_error(EX(func), retval_ptr); HANDLE_EXCEPTION(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 791e4b4e88437..bdd6a51411e40 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -10898,7 +10898,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYP } SAVE_OPLINE(); - if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, ref, 1, 0))) { + if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, 0, ref, 1, 0))) { zend_verify_return_error(EX(func), retval_ptr); HANDLE_EXCEPTION(); } @@ -21672,7 +21672,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_TMP_UN } SAVE_OPLINE(); - if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, ref, 1, 0))) { + if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, 0, ref, 1, 0))) { zend_verify_return_error(EX(func), retval_ptr); HANDLE_EXCEPTION(); } @@ -30121,7 +30121,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_VAR_UN } SAVE_OPLINE(); - if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, ref, 1, 0))) { + if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, 0, ref, 1, 0))) { zend_verify_return_error(EX(func), retval_ptr); HANDLE_EXCEPTION(); } @@ -37928,7 +37928,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_UNUSED } SAVE_OPLINE(); - if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, ref, 1, 0))) { + if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, 0, ref, 1, 0))) { zend_verify_return_error(EX(func), retval_ptr); HANDLE_EXCEPTION(); } @@ -50689,7 +50689,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_CV_UNU } SAVE_OPLINE(); - if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, ref, 1, 0))) { + if (UNEXPECTED(!zend_check_type_slow(&ret_info->type, retval_ptr, 0, ref, 1, 0))) { zend_verify_return_error(EX(func), retval_ptr); HANDLE_EXCEPTION(); } diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index b20afffa47df0..f9bef10f977ec 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -1901,7 +1901,7 @@ static bool ZEND_FASTCALL zend_jit_verify_arg_slow(zval *arg, zend_arg_info *arg zend_execute_data *execute_data = EG(current_execute_data); const zend_op *opline = EX(opline); bool ret = zend_check_user_type_slow( - &arg_info->type, arg, /* ref */ NULL, /* is_return_type */ false); + &arg_info->type, arg, opline->op1.num, /* ref */ NULL, /* is_return_type */ false); if (UNEXPECTED(!ret)) { zend_verify_arg_error(EX(func), arg_info, opline->op1.num, arg); return 0; @@ -1918,7 +1918,7 @@ static void ZEND_FASTCALL zend_jit_verify_return_slow(zval *arg, const zend_op_a } } if (UNEXPECTED(!zend_check_user_type_slow( - &arg_info->type, arg, /* ref */ NULL, /* is_return_type */ true))) { + &arg_info->type, arg, /* arg_num */ 0, /* ref */ NULL, /* is_return_type */ true))) { zend_verify_return_error((zend_function*)op_array, arg); } } diff --git a/ext/phar/phar/clicommand.inc b/ext/phar/phar/clicommand.inc index 0b84bd6030b4f..9656ce0c8cdb3 100644 --- a/ext/phar/phar/clicommand.inc +++ b/ext/phar/phar/clicommand.inc @@ -40,7 +40,7 @@ abstract class CLICommand if (isset($this->cmds[$command]['arg'])) { $this->args = call_user_func(array($this, $this->cmds[$command]['arg'])); $i = 1; - $missing = false; + $missing = ''; while (++$i < $argc) { if ($argv[$i][0] == '-') { if (strlen($argv[$i]) == 2 && isset($this->args[$argv[$i][1]])) { diff --git a/ext/phar/phar/phar.php b/ext/phar/phar/phar.php index 53aa76f60a0af..49d789809ef80 100755 --- a/ext/phar/phar/phar.php +++ b/ext/phar/phar/phar.php @@ -12,14 +12,14 @@ if (!extension_loaded('phar')) { - if (!class_exists('PHP_Archive', 0)) { + if (!class_exists('PHP_Archive', false)) { echo "Neither Extension Phar nor class PHP_Archive are available.\n"; exit(1); } if (!in_array('phar', stream_get_wrappers())) { stream_wrapper_register('phar', 'PHP_Archive'); } - if (!class_exists('Phar',0)) { + if (!class_exists('Phar', false)) { require 'phar://'.__FILE__.'/phar.inc'; } } diff --git a/ext/phar/phar/pharcommand.inc b/ext/phar/phar/pharcommand.inc index fee6c069ab085..6b943f2eb769e 100644 --- a/ext/phar/phar/pharcommand.inc +++ b/ext/phar/phar/pharcommand.inc @@ -523,7 +523,7 @@ class PharCommand extends CLICommand $s .= "if (!in_array('phar', stream_get_wrappers())) {\n"; $s .= "\tstream_wrapper_register('phar', 'PHP_Archive');\n"; $s .= "}\n"; - $s .= "if (!class_exists('Phar',0)) {\n"; + $s .= "if (!class_exists('Phar', false)) {\n"; $s .= "\tinclude 'phar://'.__FILE__.'/phar.inc';\n"; $s .= "}\n"; $s .= '?>'; From 673ee941176e616bc9885cf7e2a28b820aac366b Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 19 Jun 2025 16:35:50 +0200 Subject: [PATCH 3/7] more phar junk --- ext/phar/build_precommand.php | 2 +- ext/phar/shortarc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/phar/build_precommand.php b/ext/phar/build_precommand.php index c427ffbd5b12f..57b05faa22e9c 100755 --- a/ext/phar/build_precommand.php +++ b/ext/phar/build_precommand.php @@ -27,7 +27,7 @@ ); foreach($classes as $name) { - echo "if (!class_exists('$name', 0))\n{\n"; + echo "if (!class_exists('$name', false))\n{\n"; $f = file(dirname(__FILE__) . '/phar/' . strtolower($name) . '.inc'); unset($f[0]); $c = count($f); diff --git a/ext/phar/shortarc.php b/ext/phar/shortarc.php index 2d0d37d0dcc56..04065719648be 100644 --- a/ext/phar/shortarc.php +++ b/ext/phar/shortarc.php @@ -2,7 +2,7 @@ $web = '000'; -if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) { +if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', false)) { Phar::interceptFileFuncs(); set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path()); Phar::webPhar(null, $web); From fb9c9d85b53226fb779655e682f15c1208bf90cf Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 19 Jun 2025 16:56:39 +0200 Subject: [PATCH 4/7] fix some tests --- .../tests/streams/proc_open_bug69900.phpt | 4 +- ext/tidy/tests/019.phpt | 6 +- ext/xmlreader/tests/bug81521.phpt | 2 +- ext/xmlwriter/tests/bug39504.phpt | 2 +- ext/zlib/tests/gh16883.phpt | 4 +- ext/zlib/tests/gzfile_variation12.phpt | 104 ------------------ ext/zlib/tests/readgzfile_variation12.phpt | 52 --------- 7 files changed, 9 insertions(+), 165 deletions(-) delete mode 100644 ext/zlib/tests/gzfile_variation12.phpt delete mode 100644 ext/zlib/tests/readgzfile_variation12.phpt diff --git a/ext/standard/tests/streams/proc_open_bug69900.phpt b/ext/standard/tests/streams/proc_open_bug69900.phpt index 323fc4a079cc6..ab5303a94b591 100644 --- a/ext/standard/tests/streams/proc_open_bug69900.phpt +++ b/ext/standard/tests/streams/proc_open_bug69900.phpt @@ -32,9 +32,9 @@ for($i = 0; $i < 10; $i++){ fwrite($pipes[0], "hello$i\r\n"); fflush($pipes[0]); - $t0 = microtime(1); + $t0 = microtime(true); $s = fgets($pipes[1]); - $t1 = microtime(1); + $t1 = microtime(true); echo $s; diff --git a/ext/tidy/tests/019.phpt b/ext/tidy/tests/019.phpt index 9bf6cf6349a3f..1e1bb41d4f9be 100644 --- a/ext/tidy/tests/019.phpt +++ b/ext/tidy/tests/019.phpt @@ -13,17 +13,17 @@ tidy_repair_string($s, $s, $s); tidy_repair_string($l, $l, $l); try { - tidy_repair_file($s, $l, $l, $l); + tidy_repair_file($s, $l, $l); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } try { - tidy_repair_file($s, $s, $s, $s); + tidy_repair_file($s, $s, $s); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } -tidy_repair_file($l, $l, $l ,$l); // This doesn't emit any warning, TODO look into +tidy_repair_file($l, $l, $l); // This doesn't emit any warning, TODO look into echo "Done\n"; ?> diff --git a/ext/xmlreader/tests/bug81521.phpt b/ext/xmlreader/tests/bug81521.phpt index 2789a16e21bb2..12ea6c9f1127b 100644 --- a/ext/xmlreader/tests/bug81521.phpt +++ b/ext/xmlreader/tests/bug81521.phpt @@ -6,7 +6,7 @@ xmlreader setParserProperty(XMLReader::LOADDTD, 1)); + var_dump($reader->setParserProperty(XMLReader::LOADDTD, true)); } catch (Error $e) { echo $e->getMessage(), "\n"; } diff --git a/ext/xmlwriter/tests/bug39504.phpt b/ext/xmlwriter/tests/bug39504.phpt index 0cb509d37dd5b..35d05d5fecc78 100644 --- a/ext/xmlwriter/tests/bug39504.phpt +++ b/ext/xmlwriter/tests/bug39504.phpt @@ -19,7 +19,7 @@ $xw = new XMLWriter(); $xw->openMemory(); $xw->startDocument(NULL, "UTF-8"); $xw->startDtd("root"); -$xw->writeDtdEntity("c", "", 0, "-//W3C//TEXT copyright//EN", "http://www.w3.org/xmlspec/copyright.xml"); +$xw->writeDtdEntity("c", "", false, "-//W3C//TEXT copyright//EN", "http://www.w3.org/xmlspec/copyright.xml"); $xw->endDtd(); $xw->startElement("root"); $xw->endDocument(); diff --git a/ext/zlib/tests/gh16883.phpt b/ext/zlib/tests/gh16883.phpt index c3d81d4537938..8f22d1662278a 100644 --- a/ext/zlib/tests/gh16883.phpt +++ b/ext/zlib/tests/gh16883.phpt @@ -29,9 +29,9 @@ stream_context_set_default([ $f = gzopen('http://'.PHP_CLI_SERVER_HOSTNAME.':'.PHP_CLI_SERVER_PORT, 'r'); var_dump(stream_get_contents($f)); -var_dump(gzfile('http://'.PHP_CLI_SERVER_HOSTNAME.':'.PHP_CLI_SERVER_PORT, 'r')); +var_dump(gzfile('http://'.PHP_CLI_SERVER_HOSTNAME.':'.PHP_CLI_SERVER_PORT)); -var_dump(readgzfile('http://'.PHP_CLI_SERVER_HOSTNAME.':'.PHP_CLI_SERVER_PORT, 'r')); +var_dump(readgzfile('http://'.PHP_CLI_SERVER_HOSTNAME.':'.PHP_CLI_SERVER_PORT)); ?> --EXPECT-- diff --git a/ext/zlib/tests/gzfile_variation12.phpt b/ext/zlib/tests/gzfile_variation12.phpt deleted file mode 100644 index 6985442d6e583..0000000000000 --- a/ext/zlib/tests/gzfile_variation12.phpt +++ /dev/null @@ -1,104 +0,0 @@ ---TEST-- -Test function gzfile() by substituting argument 2 with int values. ---EXTENSIONS-- -zlib ---FILE-- - 0, - 'int 1' => 1, - 'int 12345' => 12345, - 'int -12345' => -2345, - ); - - -foreach ( $variation as $var ) { - var_dump(gzfile( $filename, $var ) ); -} -?> ---EXPECT-- -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} diff --git a/ext/zlib/tests/readgzfile_variation12.phpt b/ext/zlib/tests/readgzfile_variation12.phpt deleted file mode 100644 index 02c18fc41f8d1..0000000000000 --- a/ext/zlib/tests/readgzfile_variation12.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -Test function readgzfile() by substituting argument 2 with int values. ---EXTENSIONS-- -zlib ---FILE-- - 0, - 'int 1' => 1, - 'int 12345' => 12345, - 'int -12345' => -2345, - ); - - -foreach ( $variation as $var ) { - var_dump(readgzfile( $filename, $var ) ); -} -?> ---EXPECT-- -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) From 21a5cb648b6211e84a41d6b5f697d158a777ab6c Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 19 Jun 2025 17:00:41 +0200 Subject: [PATCH 5/7] More tests --- .../tests/strings/substr_replace.phpt | 82 +++++++++---------- ext/standard/tests/strings/wordwrap.phpt | 16 ++-- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/ext/standard/tests/strings/substr_replace.phpt b/ext/standard/tests/strings/substr_replace.phpt index 852c014b50242..009a69b5c8ff6 100644 --- a/ext/standard/tests/strings/substr_replace.phpt +++ b/ext/standard/tests/strings/substr_replace.phpt @@ -34,10 +34,10 @@ $str = "try this"; $repl = array("bala "); $start = 4; $len = 3; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).", ".var_export($start,1)."")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).", ".var_export($start, true)."")."\n"; var_dump(substr_replace($str, $repl, $start))."\n"; echo "\n"; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).", ".var_export($start,1)."")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).", ".var_export($start, true)."")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -51,22 +51,22 @@ $str = array("ala portokala"); $repl = array("bala "); $start = array(4); $len = array(3); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).", ".var_export($start,1)."")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).", ".var_export($start, true)."")."\n"; var_dump(substr_replace($str, $repl, $start))."\n"; echo "\n"; $len = array(3); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).", ".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).", ".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; $len = array(0); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).", ".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).", ".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; $len = array(-2); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).", ".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).", ".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -79,7 +79,7 @@ $str = array("ala portokala"); $repl = "bala "; $start = 4; $len = 3; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).")")."\n"; var_dump(substr_replace($str, $repl, $start))."\n"; echo "\n"; echo "\n"; @@ -90,7 +90,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = 4; $len = 3; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -100,7 +100,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = 4; $len = 3; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -109,7 +109,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = 4; $len = 0; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -119,7 +119,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = 4; $len = 0; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -127,7 +127,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = 4; $len = -2; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -137,7 +137,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = 4; $len = -2; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -153,7 +153,7 @@ $str = array("ala portokala"); $repl = "bala "; $start = array(4); $len = 3; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).")")."\n"; var_dump(substr_replace($str, $repl, $start))."\n"; echo "\n"; echo "\n"; @@ -164,7 +164,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4); $len = 3; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -174,7 +174,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4); $len = 3; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -183,7 +183,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4); $len = 0; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -193,7 +193,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4); $len = 0; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -201,7 +201,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4); $len = -2; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -211,7 +211,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4); $len = -2; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -228,7 +228,7 @@ $str = array("ala portokala"); $repl = "bala "; $start = array(4,2); $len = 3; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).")")."\n"; var_dump(substr_replace($str, $repl, $start))."\n"; echo "\n"; echo "\n"; @@ -239,7 +239,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4,2); $len = 3; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -249,7 +249,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4,2); $len = 3; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -258,7 +258,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4,2); $len = 0; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -268,7 +268,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4,2); $len = 0; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -276,7 +276,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4,2); $len = -2; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -286,7 +286,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4,2); $len = -2; -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -304,7 +304,7 @@ $str = array("ala portokala"); $repl = "bala "; $start = array(4,2); $len = array(3); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).")")."\n"; var_dump(substr_replace($str, $repl, $start))."\n"; echo "\n"; echo "\n"; @@ -315,7 +315,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4,2); $len = array(3); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -325,7 +325,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4,2); $len = array(3); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -334,7 +334,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4,2); $len = array(0); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -344,7 +344,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4,2); $len = array(0); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -352,7 +352,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4,2); $len = array(-2); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -362,7 +362,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4,2); $len = array(-2); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -379,7 +379,7 @@ $str = array("ala portokala"); $repl = "bala "; $start = array(4,2); $len = array(3,2); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).")")."\n"; var_dump(substr_replace($str, $repl, $start))."\n"; echo "\n"; echo "\n"; @@ -390,7 +390,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4,2); $len = array(3,2); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -400,7 +400,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4,2); $len = array(3,2); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -409,7 +409,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4,2); $len = array(0,0); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -419,7 +419,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4,2); $len = array(0,0); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; @@ -427,7 +427,7 @@ $str = array("ala portokala", "try this"); $repl = array("bala "); $start = array(4,2); $len = array(-2,-3); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; echo "\n"; @@ -437,7 +437,7 @@ $str = array("ala portokala", "try this"); $repl = "bala "; $start = array(4,2); $len = array(-2,-3); -echo str_replace("\n","","substr_replace(".var_export($str,1).", ".var_export($repl,1).",".var_export($start,1).", ".var_export($len,1).")")."\n"; +echo str_replace("\n","","substr_replace(".var_export($str, true).", ".var_export($repl, true).",".var_export($start, true).", ".var_export($len, true).")")."\n"; var_dump(substr_replace($str, $repl, $start, $len))."\n"; echo "\n"; diff --git a/ext/standard/tests/strings/wordwrap.phpt b/ext/standard/tests/strings/wordwrap.phpt index efa12bef18dd6..1116ca3bca561 100644 --- a/ext/standard/tests/strings/wordwrap.phpt +++ b/ext/standard/tests/strings/wordwrap.phpt @@ -14,17 +14,17 @@ var_dump("123ab 123ab123" === wordwrap("123 123ab123", 3, "ab")); var_dump("123ab123ab123" === wordwrap("123 123ab123", 5, "ab")); var_dump("123 123ab123" === wordwrap("123 123 123", 10, "ab")); -var_dump("123ab123ab123" === wordwrap("123ab123ab123", 3, "ab", 1)); -var_dump("123ab123ab123" === wordwrap("123ab123ab123", 5, "ab", 1)); -var_dump("123ab 12ab3ab123" === wordwrap("123 123ab123", 3, "ab", 1)); -var_dump("123 ab123ab123" === wordwrap("123 123ab123", 5, "ab", 1)); -var_dump("123 123ab 123" === wordwrap("123 123 123", 8, "ab", 1)); -var_dump("123 ab12345 ab123" === wordwrap("123 12345 123", 8, "ab", 1)); +var_dump("123ab123ab123" === wordwrap("123ab123ab123", 3, "ab", true)); +var_dump("123ab123ab123" === wordwrap("123ab123ab123", 5, "ab", true)); +var_dump("123ab 12ab3ab123" === wordwrap("123 123ab123", 3, "ab", true)); +var_dump("123 ab123ab123" === wordwrap("123 123ab123", 5, "ab", true)); +var_dump("123 123ab 123" === wordwrap("123 123 123", 8, "ab", true)); +var_dump("123 ab12345 ab123" === wordwrap("123 12345 123", 8, "ab", true)); var_dump("1ab2ab3ab4" === wordwrap("1234", 1, "ab", 1)); -var_dump("12345|12345|67890" === wordwrap("12345 1234567890", 5, "|", 1)); +var_dump("12345|12345|67890" === wordwrap("12345 1234567890", 5, "|", true)); -var_dump("123|==1234567890|==123" === wordwrap("123 1234567890 123", 10, "|==", 1)); +var_dump("123|==1234567890|==123" === wordwrap("123 1234567890 123", 10, "|==", true)); try { From f5e9d3f9fe36c97e97e6eb4916b6fa5f8265e434 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Fri, 20 Jun 2025 10:13:42 +0200 Subject: [PATCH 6/7] Fix --- .../union_types/type_checking_weak.phpt | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/Zend/tests/type_declarations/union_types/type_checking_weak.phpt b/Zend/tests/type_declarations/union_types/type_checking_weak.phpt index 03c8a7808d914..5893c962802a3 100644 --- a/Zend/tests/type_declarations/union_types/type_checking_weak.phpt +++ b/Zend/tests/type_declarations/union_types/type_checking_weak.phpt @@ -66,15 +66,15 @@ Type int|float: INF => INF "42" => 42 "42.0" => 42.0 -"42x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, string given -"x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, string given -"" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, string given -true => 1 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type int|float is deprecated) -false => 0 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type int|float is deprecated) -null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, null given -[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, array given -new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, stdClass given -new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float, WithToString given +"42x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, string given +"x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, string given +"" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, string given +true => 1 ({closure:%s:%d}(): Passing bool to parameter #1 ($arg) of type int|float is deprecated) +false => 0 ({closure:%s:%d}(): Passing bool to parameter #1 ($arg) of type int|float is deprecated) +null => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, null given +[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, array given +new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, stdClass given +new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float, WithToString given Type int|float|false: 42 => 42 @@ -82,15 +82,15 @@ Type int|float|false: INF => INF "42" => 42 "42.0" => 42.0 -"42x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, string given -"x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, string given -"" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, string given -true => 1 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type int|float|false is deprecated) +"42x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, string given +"x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, string given +"" => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, string given +true => 1 ({closure:%s:%d}(): Passing bool to parameter #1 ($arg) of type int|float|false is deprecated) false => false -null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, null given -[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, array given -new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, stdClass given -new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|false, WithToString given +null => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, null given +[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, array given +new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, stdClass given +new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|false, WithToString given Type int|float|bool: 42 => 42 @@ -98,31 +98,31 @@ Type int|float|bool: INF => INF "42" => 42 "42.0" => 42.0 -"42x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|float|bool is deprecated) -"x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|float|bool is deprecated) -"" => false ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|float|bool is deprecated) +"42x" => true ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type int|float|bool is deprecated) +"x" => true ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type int|float|bool is deprecated) +"" => false ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type int|float|bool is deprecated) true => true false => false -null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|bool, null given -[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|bool, array given -new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|bool, stdClass given -new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|float|bool, WithToString given +null => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|bool, null given +[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|bool, array given +new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|bool, stdClass given +new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|float|bool, WithToString given Type int|bool: 42 => 42 42.0 => 42 -INF => true ({%s(%d) : eval()'d code:1}(): Passing float to parameter #1 ($arg) of type int|bool is deprecated) +INF => true ({closure:%s:%d}(): Passing float to parameter #1 ($arg) of type int|bool is deprecated) "42" => 42 "42.0" => 42 -"42x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|bool is deprecated) -"x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|bool is deprecated) -"" => false ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type int|bool is deprecated) +"42x" => true ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type int|bool is deprecated) +"x" => true ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type int|bool is deprecated) +"" => false ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type int|bool is deprecated) true => true false => false -null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|bool, null given -[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|bool, array given -new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|bool, stdClass given -new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type int|bool, WithToString given +null => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|bool, null given +[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|bool, array given +new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|bool, stdClass given +new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type int|bool, WithToString given Type int|string|null: 42 => 42 @@ -133,11 +133,11 @@ INF => "INF" "42x" => "42x" "x" => "x" "" => "" -true => 1 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type string|int|null is deprecated) -false => 0 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type string|int|null is deprecated) +true => 1 ({closure:%s:%d}(): Passing bool to parameter #1 ($arg) of type string|int|null is deprecated) +false => 0 ({closure:%s:%d}(): Passing bool to parameter #1 ($arg) of type string|int|null is deprecated) null => null -[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type string|int|null, array given -new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type string|int|null, stdClass given +[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type string|int|null, array given +new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type string|int|null, stdClass given new WithToString => "__toString()" Type string|bool: @@ -151,9 +151,9 @@ INF => "INF" "" => "" true => true false => false -null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type string|bool, null given -[] => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type string|bool, array given -new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type string|bool, stdClass given +null => {closure:%s:%d}(): Argument #1 ($arg) must be of type string|bool, null given +[] => {closure:%s:%d}(): Argument #1 ($arg) must be of type string|bool, array given +new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type string|bool, stdClass given new WithToString => "__toString()" Type float|array: @@ -162,15 +162,15 @@ Type float|array: INF => INF "42" => 42.0 "42.0" => 42.0 -"42x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, string given -"x" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, string given -"" => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, string given -true => 1.0 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type array|float is deprecated) -false => 0.0 ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type array|float is deprecated) -null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, null given +"42x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, string given +"x" => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, string given +"" => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, string given +true => 1.0 ({closure:%s:%d}(): Passing bool to parameter #1 ($arg) of type array|float is deprecated) +false => 0.0 ({closure:%s:%d}(): Passing bool to parameter #1 ($arg) of type array|float is deprecated) +null => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, null given [] => [] -new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, stdClass given -new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|float, WithToString given +new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, stdClass given +new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|float, WithToString given Type string|array: 42 => "42" @@ -181,25 +181,25 @@ INF => "INF" "42x" => "42x" "x" => "x" "" => "" -true => "1" ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type array|string is deprecated) -false => "" ({%s(%d) : eval()'d code:1}(): Passing bool to parameter #1 ($arg) of type array|string is deprecated) -null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|string, null given +true => "1" ({closure:%s:%d}(): Passing bool to parameter #1 ($arg) of type array|string is deprecated) +false => "" ({closure:%s:%d}(): Passing bool to parameter #1 ($arg) of type array|string is deprecated) +null => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|string, null given [] => [] -new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|string, stdClass given +new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|string, stdClass given new WithToString => "__toString()" Type bool|array: -42 => true ({%s(%d) : eval()'d code:1}(): Passing int to parameter #1 ($arg) of type array|bool is deprecated) -42.0 => true ({%s(%d) : eval()'d code:1}(): Passing float to parameter #1 ($arg) of type array|bool is deprecated) -INF => true ({%s(%d) : eval()'d code:1}(): Passing float to parameter #1 ($arg) of type array|bool is deprecated) -"42" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) -"42.0" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) -"42x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) -"x" => true ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) -"" => false ({%s(%d) : eval()'d code:1}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) +42 => true ({closure:%s:%d}(): Passing int to parameter #1 ($arg) of type array|bool is deprecated) +42.0 => true ({closure:%s:%d}(): Passing float to parameter #1 ($arg) of type array|bool is deprecated) +INF => true ({closure:%s:%d}(): Passing float to parameter #1 ($arg) of type array|bool is deprecated) +"42" => true ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) +"42.0" => true ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) +"42x" => true ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) +"x" => true ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) +"" => false ({closure:%s:%d}(): Passing string to parameter #1 ($arg) of type array|bool is deprecated) true => true false => false -null => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|bool, null given +null => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|bool, null given [] => [] -new stdClass => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|bool, stdClass given -new WithToString => {%s(%d) : eval()'d code:1}(): Argument #1 ($arg) must be of type array|bool, WithToString given +new stdClass => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|bool, stdClass given +new WithToString => {closure:%s:%d}(): Argument #1 ($arg) must be of type array|bool, WithToString given From 0e1de90efa1065ec3262ac24d8a94b4af1806f7b Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Fri, 20 Jun 2025 14:37:00 +0200 Subject: [PATCH 7/7] ext/zlib: Refactor tests - Remove ZPP tests - Simplify some --- ext/zlib/tests/002.phpt | 4 +- ext/zlib/tests/003.phpt | 2 +- ext/zlib/tests/bug60761.phpt | 7 +- ext/zlib/tests/bug61139.phpt | 2 +- ext/zlib/tests/bug71417.phpt | 2 +- ext/zlib/tests/bug74240.phpt | 4 +- ext/zlib/tests/compress_zlib_wrapper.phpt | 8 +- ext/zlib/tests/{ => data}/data.inc | 0 ext/zlib/tests/{ => data}/func.inc | 0 .../tests/{004.txt.gz => data/test.txt.gz} | Bin ext/zlib/tests/deflate_init_reuse.phpt | 3 +- ext/zlib/tests/gzclose_basic.phpt | 2 +- ext/zlib/tests/gzcompress_basic1.phpt | 54 ++++----- ext/zlib/tests/gzcompress_error1.phpt | 1 - ext/zlib/tests/gzcompress_variation1.phpt | 2 +- ext/zlib/tests/gzdeflate_basic1.phpt | 54 ++++----- ext/zlib/tests/gzdeflate_variation1.phpt | 4 +- ext/zlib/tests/gzencode_basic1.phpt | 10 +- .../tests/{007.phpt => gzencode_invalid.phpt} | 0 ext/zlib/tests/gzencode_variation1-win32.phpt | 2 +- ext/zlib/tests/gzencode_variation1.phpt | 4 +- ext/zlib/tests/gzencode_variation2-win32.phpt | 6 +- ext/zlib/tests/gzencode_variation2.phpt | 4 - ext/zlib/tests/gzeof_basic.phpt | 2 +- ext/zlib/tests/{004.phpt => gzfile-mb.phpt} | 10 +- ...43\202\214\343\201\276\343\201\231.txt.gz" | Bin ext/zlib/tests/gzfile_basic.phpt | 9 +- ext/zlib/tests/gzfile_basic2.phpt | 9 +- .../{004-mb.phpt => gzfile_open_gz.phpt} | 12 +- .../{005.txt.gz => gzfile_open_gz.txt.gz} | Bin ext/zlib/tests/gzfile_variation4.phpt | 39 ------- ext/zlib/tests/gzfile_variation5.phpt | 35 ------ ext/zlib/tests/gzfile_variation7.phpt | 33 +----- ext/zlib/tests/gzfile_variation9.phpt | 103 ------------------ ext/zlib/tests/gzgetc_basic.phpt | 5 +- ext/zlib/tests/gzgetc_basic_1.phpt | 4 +- ext/zlib/tests/gzgets_basic.phpt | 2 +- ext/zlib/tests/gzinflate_error1.phpt | 2 +- ext/zlib/tests/gzinflate_length.phpt | 4 +- ext/zlib/tests/gzopen_basic.phpt | 2 +- ext/zlib/tests/gzopen_variation7.phpt | 2 +- ext/zlib/tests/gzopen_variation9.phpt | 4 +- ext/zlib/tests/gzpassthru_basic.phpt | 2 +- ext/zlib/tests/gzread_basic.phpt | 2 +- ext/zlib/tests/gzread_error2.phpt | 2 +- ext/zlib/tests/gzrewind_basic.phpt | 2 +- ext/zlib/tests/gzrewind_basic2.phpt | 2 +- ext/zlib/tests/gzseek_basic.phpt | 2 +- ext/zlib/tests/gzseek_variation2.phpt | 2 +- ext/zlib/tests/gzseek_variation3.phpt | 2 +- ext/zlib/tests/gzseek_variation6.phpt | 2 +- ext/zlib/tests/gztell_basic.phpt | 2 +- ext/zlib/tests/gzuncompress_basic1.phpt | 2 +- ext/zlib/tests/gzwrite_variation1.phpt | 2 +- ext/zlib/tests/ob_001.phpt | 4 +- ext/zlib/tests/ob_003.phpt | 4 +- ext/zlib/tests/ob_004.phpt | 4 +- ext/zlib/tests/ob_005.phpt | 5 +- ext/zlib/tests/ob_gzhandler_legacy_002.phpt | 5 +- ext/zlib/tests/readgzfile_variation4.phpt | 39 ------- ext/zlib/tests/readgzfile_variation5.phpt | 35 ------ ext/zlib/tests/readgzfile_variation7.phpt | 34 +----- ext/zlib/tests/readgzfile_variation9.phpt | 51 --------- ext/zlib/tests/zlib_scheme_copy_basic.phpt | 2 +- .../tests/zlib_scheme_copy_variation1.phpt | 2 +- ext/zlib/tests/zlib_scheme_file_basic.phpt | 2 +- .../zlib_scheme_file_get_contents_basic.phpt | 2 +- .../zlib_scheme_file_read_file_basic.phpt | 2 +- ext/zlib/tests/zlib_scheme_fopen_basic.phpt | 2 +- .../tests/zlib_scheme_fopen_variation1.phpt | 4 +- ext/zlib/tests/zlib_scheme_rename_basic.phpt | 2 +- ext/zlib/tests/zlib_scheme_stat_basic2.phpt | 8 +- ext/zlib/tests/zlib_scheme_unlink_basic.phpt | 2 +- ext/zlib/tests/zlib_wrapper_flock_basic.phpt | 2 +- ext/zlib/tests/zlib_wrapper_fstat_basic.phpt | 2 +- .../tests/zlib_wrapper_ftruncate_basic.phpt | 2 +- ext/zlib/tests/zlib_wrapper_level.phpt | 2 +- .../tests/zlib_wrapper_meta_data_basic.phpt | 8 +- 78 files changed, 165 insertions(+), 536 deletions(-) rename ext/zlib/tests/{ => data}/data.inc (100%) rename ext/zlib/tests/{ => data}/func.inc (100%) rename ext/zlib/tests/{004.txt.gz => data/test.txt.gz} (100%) rename ext/zlib/tests/{007.phpt => gzencode_invalid.phpt} (100%) rename ext/zlib/tests/{004.phpt => gzfile-mb.phpt} (74%) rename "ext/zlib/tests/004\347\247\201\343\201\257\343\202\254\343\203\251\343\202\271\343\202\222\351\243\237\343\201\271\343\202\211\343\202\214\343\201\276\343\201\231.txt.gz" => "ext/zlib/tests/gzfile-mb\347\247\201\343\201\257\343\202\254\343\203\251\343\202\271\343\202\222\351\243\237\343\201\271\343\202\211\343\202\214\343\201\276\343\201\231.txt.gz" (100%) rename ext/zlib/tests/{004-mb.phpt => gzfile_open_gz.phpt} (66%) rename ext/zlib/tests/{005.txt.gz => gzfile_open_gz.txt.gz} (100%) delete mode 100644 ext/zlib/tests/gzfile_variation4.phpt delete mode 100644 ext/zlib/tests/gzfile_variation5.phpt delete mode 100644 ext/zlib/tests/gzfile_variation9.phpt delete mode 100644 ext/zlib/tests/readgzfile_variation4.phpt delete mode 100644 ext/zlib/tests/readgzfile_variation5.phpt delete mode 100644 ext/zlib/tests/readgzfile_variation9.phpt diff --git a/ext/zlib/tests/002.phpt b/ext/zlib/tests/002.phpt index 83f701e5aaf19..6564cc3f07388 100644 --- a/ext/zlib/tests/002.phpt +++ b/ext/zlib/tests/002.phpt @@ -8,14 +8,14 @@ $original = str_repeat("hallo php",4096); $packed=gzcompress($original); echo strlen($packed)." ".strlen($original)."\n"; $unpacked=gzuncompress($packed); -if (strcmp($original,$unpacked)==0) echo "Strings are equal\n"; +if ($original === $unpacked) echo "Strings are equal\n"; /* with explicit compression level, length */ $original = str_repeat("hallo php",4096); $packed=gzcompress($original, 9); echo strlen($packed)." ".strlen($original)."\n"; $unpacked=gzuncompress($packed, 40000); -if (strcmp($original,$unpacked)==0) echo "Strings are equal\n"; +if ($original === $unpacked) echo "Strings are equal\n"; ?> --EXPECT-- 106 36864 diff --git a/ext/zlib/tests/003.phpt b/ext/zlib/tests/003.phpt index 6fc5a71980ba6..0c731a0dfafba 100644 --- a/ext/zlib/tests/003.phpt +++ b/ext/zlib/tests/003.phpt @@ -7,7 +7,7 @@ zlib $original = str_repeat("hallo php",4096); $packed = gzencode($original); echo strlen($packed)." ".strlen($original). "\n"; -if (strcmp($original, gzdecode($packed)) == 0) echo "Strings are equal"; +if ($original === gzdecode($packed)) echo "Strings are equal\n"; ?> --EXPECT-- 118 36864 diff --git a/ext/zlib/tests/bug60761.phpt b/ext/zlib/tests/bug60761.phpt index 735123869432d..16577f869081b 100644 --- a/ext/zlib/tests/bug60761.phpt +++ b/ext/zlib/tests/bug60761.phpt @@ -2,14 +2,13 @@ checks zlib compression output size is always the same --EXTENSIONS-- zlib +--INI-- +zlib.output_compression=4096 +zlib.output_compression_level=9 --CGI-- --FILE-- --CLEAN-- --EXPECTF-- Warning: gzopen(): gzopen failed in %s on line %d diff --git a/ext/zlib/tests/bug71417.phpt b/ext/zlib/tests/bug71417.phpt index 8d871a329e7fe..ee8b30f18e998 100644 --- a/ext/zlib/tests/bug71417.phpt +++ b/ext/zlib/tests/bug71417.phpt @@ -45,7 +45,7 @@ function test($case) { // The gzdecode() function applied to the corrupted compressed data always // detects the error: // --> gzdecode(): PHP Fatal error: Uncaught ErrorException: gzdecode(): data error in ... - echo "gzdecode(): ", rawurldecode(gzdecode($compressed)), "\n"; + echo "gzdecode(): ", rawurldecode((string) gzdecode($compressed)), "\n"; file_put_contents($fn, $compressed); diff --git a/ext/zlib/tests/bug74240.phpt b/ext/zlib/tests/bug74240.phpt index c3dbcc26e369e..f45cd04f71c0e 100644 --- a/ext/zlib/tests/bug74240.phpt +++ b/ext/zlib/tests/bug74240.phpt @@ -2,11 +2,11 @@ Bug #74240 (deflate_add can allocate too much memory) --EXTENSIONS-- zlib +--INI-- +memory_limit=64M --FILE-- ===DONE=== --EXPECT-- +bool(true) ===DONE=== diff --git a/ext/zlib/tests/gzclose_basic.phpt b/ext/zlib/tests/gzclose_basic.phpt index c1d6edf4d95e1..f2e03a579de5e 100644 --- a/ext/zlib/tests/gzclose_basic.phpt +++ b/ext/zlib/tests/gzclose_basic.phpt @@ -7,7 +7,7 @@ zlib // note that gzclose is an alias to fclose. parameter checking tests will be // the same as fclose -$f = __DIR__."/004.txt.gz"; +$f = __DIR__."/data/test.txt.gz"; $h = gzopen($f, 'r'); gzread($h, 20); var_dump(gzclose($h)); diff --git a/ext/zlib/tests/gzcompress_basic1.phpt b/ext/zlib/tests/gzcompress_basic1.phpt index 8899deaed0f72..606da46e5c873 100644 --- a/ext/zlib/tests/gzcompress_basic1.phpt +++ b/ext/zlib/tests/gzcompress_basic1.phpt @@ -8,7 +8,7 @@ zlib * add a comment here to say what the test is supposed to do */ -include(__DIR__ . '/data.inc'); +include(__DIR__ . '/data/data.inc'); echo "*** Testing gzcompress() : basic functionality ***\n"; @@ -23,68 +23,68 @@ $smallstring = "A small string to compress\n"; for($i = -1; $i < 10; $i++) { echo "-- Compression level $i --\n"; $output = gzcompress($data, $i); - var_dump(strcmp(gzuncompress($output), $data)); + var_dump(gzuncompress($output) === $data); } // Compressing a smaller string for($i = -1; $i < 10; $i++) { echo "-- Compression level $i --\n"; $output = gzcompress($smallstring, $i); - var_dump(strcmp(gzuncompress($output), $smallstring)); + var_dump(gzuncompress($output) === $smallstring); } // Calling gzcompress() with mandatory arguments echo "\n-- Testing with no specified compression level --\n"; $output = gzcompress($smallstring); - var_dump(strcmp(gzuncompress($output), $smallstring)); +var_dump(gzuncompress($output) === $smallstring); ?> --EXPECT-- *** Testing gzcompress() : basic functionality *** -- Compression level -1 -- -int(0) +bool(true) -- Compression level 0 -- -int(0) +bool(true) -- Compression level 1 -- -int(0) +bool(true) -- Compression level 2 -- -int(0) +bool(true) -- Compression level 3 -- -int(0) +bool(true) -- Compression level 4 -- -int(0) +bool(true) -- Compression level 5 -- -int(0) +bool(true) -- Compression level 6 -- -int(0) +bool(true) -- Compression level 7 -- -int(0) +bool(true) -- Compression level 8 -- -int(0) +bool(true) -- Compression level 9 -- -int(0) +bool(true) -- Compression level -1 -- -int(0) +bool(true) -- Compression level 0 -- -int(0) +bool(true) -- Compression level 1 -- -int(0) +bool(true) -- Compression level 2 -- -int(0) +bool(true) -- Compression level 3 -- -int(0) +bool(true) -- Compression level 4 -- -int(0) +bool(true) -- Compression level 5 -- -int(0) +bool(true) -- Compression level 6 -- -int(0) +bool(true) -- Compression level 7 -- -int(0) +bool(true) -- Compression level 8 -- -int(0) +bool(true) -- Compression level 9 -- -int(0) +bool(true) -- Testing with no specified compression level -- -int(0) +bool(true) diff --git a/ext/zlib/tests/gzcompress_error1.phpt b/ext/zlib/tests/gzcompress_error1.phpt index a34ceaf7248fd..b21743755417f 100644 --- a/ext/zlib/tests/gzcompress_error1.phpt +++ b/ext/zlib/tests/gzcompress_error1.phpt @@ -20,7 +20,6 @@ try { } echo "\n-- Testing with invalid encoding --\n"; -$data = 'string_val'; $level = 2; $encoding = 99; try { diff --git a/ext/zlib/tests/gzcompress_variation1.phpt b/ext/zlib/tests/gzcompress_variation1.phpt index 81dafa737c305..032a77a1a55ab 100644 --- a/ext/zlib/tests/gzcompress_variation1.phpt +++ b/ext/zlib/tests/gzcompress_variation1.phpt @@ -4,7 +4,7 @@ Test gzcompress() function : variation zlib --FILE-- --EXPECT-- *** Testing gzdeflate() : basic functionality *** -- Compression level -1 -- -int(0) +bool(true) -- Compression level 0 -- -int(0) +bool(true) -- Compression level 1 -- -int(0) +bool(true) -- Compression level 2 -- -int(0) +bool(true) -- Compression level 3 -- -int(0) +bool(true) -- Compression level 4 -- -int(0) +bool(true) -- Compression level 5 -- -int(0) +bool(true) -- Compression level 6 -- -int(0) +bool(true) -- Compression level 7 -- -int(0) +bool(true) -- Compression level 8 -- -int(0) +bool(true) -- Compression level 9 -- -int(0) +bool(true) -- Compression level -1 -- -int(0) +bool(true) -- Compression level 0 -- -int(0) +bool(true) -- Compression level 1 -- -int(0) +bool(true) -- Compression level 2 -- -int(0) +bool(true) -- Compression level 3 -- -int(0) +bool(true) -- Compression level 4 -- -int(0) +bool(true) -- Compression level 5 -- -int(0) +bool(true) -- Compression level 6 -- -int(0) +bool(true) -- Compression level 7 -- -int(0) +bool(true) -- Compression level 8 -- -int(0) +bool(true) -- Compression level 9 -- -int(0) +bool(true) -- Testing with no specified compression level -- -int(0) +bool(true) diff --git a/ext/zlib/tests/gzdeflate_variation1.phpt b/ext/zlib/tests/gzdeflate_variation1.phpt index 21456a9887659..b2d98ce978d04 100644 --- a/ext/zlib/tests/gzdeflate_variation1.phpt +++ b/ext/zlib/tests/gzdeflate_variation1.phpt @@ -4,12 +4,10 @@ Test gzdeflate() function : variation zlib --FILE-- --EXPECTF-- *** Testing gzencode() : basic functionality *** diff --git a/ext/zlib/tests/007.phpt b/ext/zlib/tests/gzencode_invalid.phpt similarity index 100% rename from ext/zlib/tests/007.phpt rename to ext/zlib/tests/gzencode_invalid.phpt diff --git a/ext/zlib/tests/gzencode_variation1-win32.phpt b/ext/zlib/tests/gzencode_variation1-win32.phpt index 31329bb5ea9cc..c6d261567c90e 100644 --- a/ext/zlib/tests/gzencode_variation1-win32.phpt +++ b/ext/zlib/tests/gzencode_variation1-win32.phpt @@ -11,7 +11,7 @@ if (substr(PHP_OS, 0, 3) != "WIN") { --FILE-- --FILE-- ---EXPECTF-- -Warning: gzfile(nonexistent_file_gzfile): Failed to open stream: No such file or directory in %s on line %d -bool(false) +--EXPECT-- array(6) { [0]=> string(36) "When you're taught through feelings diff --git "a/ext/zlib/tests/004\347\247\201\343\201\257\343\202\254\343\203\251\343\202\271\343\202\222\351\243\237\343\201\271\343\202\211\343\202\214\343\201\276\343\201\231.txt.gz" "b/ext/zlib/tests/gzfile-mb\347\247\201\343\201\257\343\202\254\343\203\251\343\202\271\343\202\222\351\243\237\343\201\271\343\202\211\343\202\214\343\201\276\343\201\231.txt.gz" similarity index 100% rename from "ext/zlib/tests/004\347\247\201\343\201\257\343\202\254\343\203\251\343\202\271\343\202\222\351\243\237\343\201\271\343\202\211\343\202\214\343\201\276\343\201\231.txt.gz" rename to "ext/zlib/tests/gzfile-mb\347\247\201\343\201\257\343\202\254\343\203\251\343\202\271\343\202\222\351\243\237\343\201\271\343\202\211\343\202\214\343\201\276\343\201\231.txt.gz" diff --git a/ext/zlib/tests/gzfile_basic.phpt b/ext/zlib/tests/gzfile_basic.phpt index 26cde7397cea1..a993893c1dc6c 100644 --- a/ext/zlib/tests/gzfile_basic.phpt +++ b/ext/zlib/tests/gzfile_basic.phpt @@ -19,8 +19,13 @@ gzclose($h); var_dump(gzfile( $filename ) ); -unlink($filename); -rmdir($dirname); +?> +--CLEAN-- + --EXPECT-- array(3) { diff --git a/ext/zlib/tests/gzfile_basic2.phpt b/ext/zlib/tests/gzfile_basic2.phpt index 2b59656a6f314..b098692620a26 100644 --- a/ext/zlib/tests/gzfile_basic2.phpt +++ b/ext/zlib/tests/gzfile_basic2.phpt @@ -19,8 +19,13 @@ fclose($h); var_dump(gzfile( $filename ) ); -unlink($filename); -rmdir($dirname); +?> +--CLEAN-- + --EXPECT-- array(3) { diff --git a/ext/zlib/tests/004-mb.phpt b/ext/zlib/tests/gzfile_open_gz.phpt similarity index 66% rename from ext/zlib/tests/004-mb.phpt rename to ext/zlib/tests/gzfile_open_gz.phpt index 9cf6dd628c6a1..327503c529bc6 100644 --- a/ext/zlib/tests/004-mb.phpt +++ b/ext/zlib/tests/gzfile_open_gz.phpt @@ -1,20 +1,16 @@ --TEST-- -gzfile() with various invalid params +gzfile() with a proper gz file --EXTENSIONS-- zlib --FILE-- ---EXPECTF-- -Warning: gzfile(nonexistent_file_gzfile): Failed to open stream: No such file or directory in %s on line %d -bool(false) +--EXPECT-- array(6) { [0]=> string(36) "When you're taught through feelings diff --git a/ext/zlib/tests/005.txt.gz b/ext/zlib/tests/gzfile_open_gz.txt.gz similarity index 100% rename from ext/zlib/tests/005.txt.gz rename to ext/zlib/tests/gzfile_open_gz.txt.gz diff --git a/ext/zlib/tests/gzfile_variation4.phpt b/ext/zlib/tests/gzfile_variation4.phpt deleted file mode 100644 index 86d84899b86e9..0000000000000 --- a/ext/zlib/tests/gzfile_variation4.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -Test function gzfile() by substituting argument 1 with float values. ---EXTENSIONS-- -zlib ---FILE-- - 10.5, - 'float -10.5' => -10.5, - 'float 12.3456789000e10' => 12.3456789000e10, - 'float -12.3456789000e10' => -12.3456789000e10, - 'float .5' => .5, - ); - - -foreach ( $variation as $var ) { - var_dump(gzfile( $var , $use_include_path ) ); -} -?> ---EXPECTF-- -Warning: gzfile(10.5): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: gzfile(-10.5): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: gzfile(123456789000): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: gzfile(-123456789000): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: gzfile(0.5): Failed to open stream: No such file or directory in %s on line %d -bool(false) diff --git a/ext/zlib/tests/gzfile_variation5.phpt b/ext/zlib/tests/gzfile_variation5.phpt deleted file mode 100644 index 75751ea12cc77..0000000000000 --- a/ext/zlib/tests/gzfile_variation5.phpt +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -Test function gzfile() by substituting argument 1 with int values. ---EXTENSIONS-- -zlib ---FILE-- - 0, - 'int 1' => 1, - 'int 12345' => 12345, - 'int -12345' => -2345, - ); - - -foreach ( $variation as $var ) { - var_dump(gzfile( $var , $use_include_path ) ); -} -?> ---EXPECTF-- -Warning: gzfile(0): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: gzfile(1): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: gzfile(12345): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: gzfile(-2345): Failed to open stream: No such file or directory in %s on line %d -bool(false) diff --git a/ext/zlib/tests/gzfile_variation7.phpt b/ext/zlib/tests/gzfile_variation7.phpt index 834f8937e823f..ca221c12cff3f 100644 --- a/ext/zlib/tests/gzfile_variation7.phpt +++ b/ext/zlib/tests/gzfile_variation7.phpt @@ -1,39 +1,18 @@ --TEST-- -Test function gzfile() by substituting argument 1 with string values. +gzfile() with unknown file --EXTENSIONS-- zlib --FILE-- "string", - 'string SQ' => 'string', - 'mixed case string' => "sTrInG", - 'heredoc' => $heredoc - ); - - -foreach ( $variation_array as $var ) { - var_dump(gzfile( $var , $use_include_path ) ); -} +var_dump(gzfile($filename, false)); +var_dump(gzfile($filename, true)); ?> --EXPECTF-- -Warning: gzfile(string): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: gzfile(string): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: gzfile(sTrInG): Failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(nonexistent_file_gzfile.txt.gz): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(hello world): Failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(nonexistent_file_gzfile.txt.gz): Failed to open stream: No such file or directory in %s on line %d bool(false) diff --git a/ext/zlib/tests/gzfile_variation9.phpt b/ext/zlib/tests/gzfile_variation9.phpt deleted file mode 100644 index f2919d79be5c1..0000000000000 --- a/ext/zlib/tests/gzfile_variation9.phpt +++ /dev/null @@ -1,103 +0,0 @@ ---TEST-- -Test function gzfile() by substituting argument 2 with boolean values. ---EXTENSIONS-- -zlib ---FILE-- - true, - 'lowercase false' =>false, - 'uppercase TRUE' =>TRUE, - 'uppercase FALSE' =>FALSE, - ); - - -foreach ( $variation as $var ) { - var_dump(gzfile( $filename, $var ) ); -} -?> ---EXPECT-- -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} diff --git a/ext/zlib/tests/gzgetc_basic.phpt b/ext/zlib/tests/gzgetc_basic.phpt index 7164c23098d92..ce366e4b6b31a 100644 --- a/ext/zlib/tests/gzgetc_basic.phpt +++ b/ext/zlib/tests/gzgetc_basic.phpt @@ -4,8 +4,7 @@ Test function gzgetc() by calling it with its expected arguments zlib 1.2.5 zlib --SKIPIF-- 0) { die('skip - only for zlib <= 1.2.5'); } @@ -16,7 +15,7 @@ if (version_compare(get_zlib_version(), '1.2.5') > 0) { // note that gzgets is an alias to fgets. parameter checking tests will be // the same as gzgets -$f = __DIR__."/004.txt.gz"; +$f = __DIR__."/data/test.txt.gz"; $h = gzopen($f, 'r'); $count = 0; diff --git a/ext/zlib/tests/gzgetc_basic_1.phpt b/ext/zlib/tests/gzgetc_basic_1.phpt index e70c5814fcbc8..cf6da96e5612f 100644 --- a/ext/zlib/tests/gzgetc_basic_1.phpt +++ b/ext/zlib/tests/gzgetc_basic_1.phpt @@ -5,7 +5,7 @@ zlib --SKIPIF-- = 1.2.7'); } @@ -16,7 +16,7 @@ if (version_compare(get_zlib_version(), '1.2.7') < 0) { // note that gzgets is an alias to fgets. parameter checking tests will be // the same as gzgets -$f = __DIR__."/004.txt.gz"; +$f = __DIR__."/data/test.txt.gz"; $h = gzopen($f, 'r'); if ($h) { $count = 0; diff --git a/ext/zlib/tests/gzgets_basic.phpt b/ext/zlib/tests/gzgets_basic.phpt index f43b3ad5342c3..a971d5e3a620c 100644 --- a/ext/zlib/tests/gzgets_basic.phpt +++ b/ext/zlib/tests/gzgets_basic.phpt @@ -8,7 +8,7 @@ zlib // note that gzgets is an alias to fgets. parameter checking tests will be // the same as fgets -$f = __DIR__."/004.txt.gz"; +$f = __DIR__."/data/test.txt.gz"; $h = gzopen($f, 'r'); $lengths = array(10, 14, 7, 99); foreach ($lengths as $length) { diff --git a/ext/zlib/tests/gzinflate_error1.phpt b/ext/zlib/tests/gzinflate_error1.phpt index 8d4abdf529b02..4d02c2604e30e 100644 --- a/ext/zlib/tests/gzinflate_error1.phpt +++ b/ext/zlib/tests/gzinflate_error1.phpt @@ -4,7 +4,7 @@ Test gzinflate() function : error conditions zlib --FILE-- +--CGI-- --GET-- a=b --INI-- diff --git a/ext/zlib/tests/ob_003.phpt b/ext/zlib/tests/ob_003.phpt index 647a120627044..70bd209f3824c 100644 --- a/ext/zlib/tests/ob_003.phpt +++ b/ext/zlib/tests/ob_003.phpt @@ -3,9 +3,7 @@ zlib.output_compression --EXTENSIONS-- zlib --SKIPIF-- - +--CGI-- --INI-- zlib.output_compression=0 --ENV-- diff --git a/ext/zlib/tests/ob_004.phpt b/ext/zlib/tests/ob_004.phpt index ac4ec2d862db1..dc48c39aa1f20 100644 --- a/ext/zlib/tests/ob_004.phpt +++ b/ext/zlib/tests/ob_004.phpt @@ -3,9 +3,7 @@ ob_gzhandler --EXTENSIONS-- zlib --SKIPIF-- - +--CGI-- --INI-- zlib.output_compression=0 --ENV-- diff --git a/ext/zlib/tests/ob_005.phpt b/ext/zlib/tests/ob_005.phpt index aaa9856dbaab7..343d548161808 100644 --- a/ext/zlib/tests/ob_005.phpt +++ b/ext/zlib/tests/ob_005.phpt @@ -2,10 +2,7 @@ ob_gzhandler --EXTENSIONS-- zlib ---SKIPIF-- - +--CGI- --INI-- zlib.output_compression=0 --ENV-- diff --git a/ext/zlib/tests/ob_gzhandler_legacy_002.phpt b/ext/zlib/tests/ob_gzhandler_legacy_002.phpt index 6789ba2d53f90..41cdda1f8d671 100644 --- a/ext/zlib/tests/ob_gzhandler_legacy_002.phpt +++ b/ext/zlib/tests/ob_gzhandler_legacy_002.phpt @@ -2,10 +2,7 @@ ob_gzhandler legacy --EXTENSIONS-- zlib ---SKIPIF-- - +--CGI-- --INI-- zlib.output_compression=0 --ENV-- diff --git a/ext/zlib/tests/readgzfile_variation4.phpt b/ext/zlib/tests/readgzfile_variation4.phpt deleted file mode 100644 index 85854b024fc56..0000000000000 --- a/ext/zlib/tests/readgzfile_variation4.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -Test function readgzfile() by substituting argument 1 with float values. ---EXTENSIONS-- -zlib ---FILE-- - 10.5, - 'float -10.5' => -10.5, - 'float 12.3456789000e10' => 12.3456789000e10, - 'float -12.3456789000e10' => -12.3456789000e10, - 'float .5' => .5, - ); - - -foreach ( $variation as $var ) { - var_dump(readgzfile( $var , $use_include_path ) ); -} -?> ---EXPECTF-- -Warning: readgzfile(10.5): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: readgzfile(-10.5): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: readgzfile(123456789000): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: readgzfile(-123456789000): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: readgzfile(0.5): Failed to open stream: No such file or directory in %s on line %d -bool(false) diff --git a/ext/zlib/tests/readgzfile_variation5.phpt b/ext/zlib/tests/readgzfile_variation5.phpt deleted file mode 100644 index 039812ba2e813..0000000000000 --- a/ext/zlib/tests/readgzfile_variation5.phpt +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -Test function readgzfile() by substituting argument 1 with int values. ---EXTENSIONS-- -zlib ---FILE-- - 0, - 'int 1' => 1, - 'int 12345' => 12345, - 'int -12345' => -2345, - ); - - -foreach ( $variation as $var ) { - var_dump(readgzfile( $var , $use_include_path ) ); -} -?> ---EXPECTF-- -Warning: readgzfile(0): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: readgzfile(1): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: readgzfile(12345): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: readgzfile(-2345): Failed to open stream: No such file or directory in %s on line %d -bool(false) diff --git a/ext/zlib/tests/readgzfile_variation7.phpt b/ext/zlib/tests/readgzfile_variation7.phpt index 0d357c6774b69..6f201abe2361b 100644 --- a/ext/zlib/tests/readgzfile_variation7.phpt +++ b/ext/zlib/tests/readgzfile_variation7.phpt @@ -1,39 +1,17 @@ --TEST-- -Test function readgzfile() by substituting argument 1 with string values. +readgzfile() with unknown file --EXTENSIONS-- zlib --FILE-- "string", - 'string SQ' => 'string', - 'mixed case string' => "sTrInG", - 'heredoc' => $heredoc - ); - - -foreach ( $variation_array as $var ) { - var_dump(readgzfile( $var , $use_include_path ) ); -} +$file = "unknown_file.txt.gz"; +var_dump(readgzfile($file, false)); +var_dump(readgzfile($file, true)); ?> --EXPECTF-- -Warning: readgzfile(string): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: readgzfile(string): Failed to open stream: No such file or directory in %s on line %d -bool(false) - -Warning: readgzfile(sTrInG): Failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(unknown_file.txt.gz): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(hello world): Failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(unknown_file.txt.gz): Failed to open stream: No such file or directory in %s on line %d bool(false) diff --git a/ext/zlib/tests/readgzfile_variation9.phpt b/ext/zlib/tests/readgzfile_variation9.phpt deleted file mode 100644 index 011ded054b780..0000000000000 --- a/ext/zlib/tests/readgzfile_variation9.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -Test function readgzfile() by substituting argument 2 with boolean values. ---EXTENSIONS-- -zlib ---FILE-- - true, - 'lowercase false' =>false, - 'uppercase TRUE' =>TRUE, - 'uppercase FALSE' =>FALSE, - ); - - -foreach ( $variation as $var ) { - var_dump(readgzfile( $filename, $var ) ); -} -?> ---EXPECT-- -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) diff --git a/ext/zlib/tests/zlib_scheme_copy_basic.phpt b/ext/zlib/tests/zlib_scheme_copy_basic.phpt index 139296247e17d..80fa9e31fde3d 100644 --- a/ext/zlib/tests/zlib_scheme_copy_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_copy_basic.phpt @@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the copy function: compressed to compressed zlib --FILE-- diff --git a/ext/zlib/tests/zlib_scheme_fopen_basic.phpt b/ext/zlib/tests/zlib_scheme_fopen_basic.phpt index 9d366670f1ca8..fbac2f82ae637 100644 --- a/ext/zlib/tests/zlib_scheme_fopen_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_fopen_basic.phpt @@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the fopen zlib --FILE-- --EXPECTF-- -file=compress.zlib://file://%s/004.txt.gz +file=compress.zlib://file://%s/test.txt.gz When you're taught through feelings Destiny flying high above diff --git a/ext/zlib/tests/zlib_scheme_rename_basic.phpt b/ext/zlib/tests/zlib_scheme_rename_basic.phpt index be9df167220a5..506ac9cb92367 100644 --- a/ext/zlib/tests/zlib_scheme_rename_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_rename_basic.phpt @@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the unlink function zlib --FILE-- --FILE-- bool(true) ["uri"]=> - string(%d) "compress.zlib://%s/004.txt.gz" + string(%d) "compress.zlib://%s/test.txt.gz" }