Commit 5ed6625e4c0 for php
commit 5ed6625e4c0982512e6ec827716083e928f5406d
Author: Daniel Scherzer <daniel.e.scherzer@gmail.com>
Date: Sat Aug 8 13:22:51 2026 -0700
[`%pS` migration] Use `%pS` in ext/standard/var.c
diff --git a/Zend/tests/anon/012.phpt b/Zend/tests/anon/012.phpt
index d82f237c1c8..74bf25518e4 100644
--- a/Zend/tests/anon/012.phpt
+++ b/Zend/tests/anon/012.phpt
@@ -4,8 +4,8 @@
<?php
var_dump(new class { private $foo; });
?>
---EXPECT--
-object(class@anonymous)#1 (1) {
+--EXPECTF--
+object(class@anonymous%0%s)#1 (1) {
["foo":"class@anonymous":private]=>
NULL
}
diff --git a/Zend/tests/anon/013.phpt b/Zend/tests/anon/013.phpt
index b66be660d70..298ae783742 100644
--- a/Zend/tests/anon/013.phpt
+++ b/Zend/tests/anon/013.phpt
@@ -10,6 +10,6 @@
$closure = Closure::bind($foo, $class, $class);
var_dump($closure());
?>
---EXPECT--
-object(class@anonymous)#1 (0) {
+--EXPECTF--
+object(class@anonymous%0%s)#1 (0) {
}
diff --git a/Zend/tests/bug72598.phpt b/Zend/tests/bug72598.phpt
index 741abc35e22..d546332c79f 100644
--- a/Zend/tests/bug72598.phpt
+++ b/Zend/tests/bug72598.phpt
@@ -18,9 +18,9 @@ function __construct() {
?>
--EXPECTF--
Warning: ref(): Argument #1 ($ref) must be passed by reference, value given in %s on line %d
-object(class@anonymous)#1 (0) {
+object(class@anonymous%0%s)#1 (0) {
}
Warning: ref(): Argument #1 ($ref) must be passed by reference, value given in %s on line %d
-object(class@anonymous)#1 (0) {
+object(class@anonymous%0%s)#1 (0) {
}
diff --git a/Zend/tests/bug73816.phpt b/Zend/tests/bug73816.phpt
index aea392be5e1..08f73560788 100644
--- a/Zend/tests/bug73816.phpt
+++ b/Zend/tests/bug73816.phpt
@@ -13,12 +13,12 @@ function anon()
var_dump(anon());
?>
---EXPECT--
-object(class@anonymous)#1 (1) {
+--EXPECTF--
+object(class@anonymous%0%s)#1 (1) {
["prop1":"class@anonymous":private]=>
NULL
}
-object(class@anonymous)#1 (1) {
+object(class@anonymous%0%s)#1 (1) {
["prop2":"class@anonymous":private]=>
NULL
}
diff --git a/Zend/tests/constexpr/new_anon_class.phpt b/Zend/tests/constexpr/new_anon_class.phpt
index 49fc120f6b9..197f594f688 100644
--- a/Zend/tests/constexpr/new_anon_class.phpt
+++ b/Zend/tests/constexpr/new_anon_class.phpt
@@ -8,6 +8,6 @@
var_dump($x);
?>
---EXPECT--
-object(class@anonymous)#1 (0) {
+--EXPECTF--
+object(class@anonymous%0%s)#1 (0) {
}
diff --git a/Zend/tests/partial_application/static_pfa_004.phpt b/Zend/tests/partial_application/static_pfa_004.phpt
index 093430232d4..9a7de941bf4 100644
--- a/Zend/tests/partial_application/static_pfa_004.phpt
+++ b/Zend/tests/partial_application/static_pfa_004.phpt
@@ -39,6 +39,6 @@
Error: Using $this when not in object context
# Re-bound PFA
-object(class@anonymous)#3 (0) {
+object(class@anonymous%0%s)#3 (0) {
}
bool(true)
diff --git a/Zend/tests/property_hooks/oss_fuzz_403308724.phpt b/Zend/tests/property_hooks/oss_fuzz_403308724.phpt
index b27b08dd703..683814387f4 100644
--- a/Zend/tests/property_hooks/oss_fuzz_403308724.phpt
+++ b/Zend/tests/property_hooks/oss_fuzz_403308724.phpt
@@ -19,10 +19,10 @@ class Test extends Base {
var_dump($y);
var_dump($y[0]->inner);
?>
---EXPECT--
+--EXPECTF--
array(2) {
[0]=>
- object(class@anonymous)#2 (0) {
+ object(class@anonymous%0%s)#2 (0) {
}
[1]=>
int(1)
diff --git a/Zend/tests/type_declarations/typed_properties_001.phpt b/Zend/tests/type_declarations/typed_properties_001.phpt
index ce791cd4b56..d6136642b24 100644
--- a/Zend/tests/type_declarations/typed_properties_001.phpt
+++ b/Zend/tests/type_declarations/typed_properties_001.phpt
@@ -21,7 +21,7 @@ public function __construct(int $int, float $float, bool $bool, array $array, st
});
?>
--EXPECTF--
-object(class@anonymous)#%d (6) {
+object(class@anonymous%0%s)#%d (6) {
["int"]=>
int(1)
["float"]=>
diff --git a/Zend/tests/type_declarations/typed_properties_033.phpt b/Zend/tests/type_declarations/typed_properties_033.phpt
index 59d5943f1fe..b48b5437030 100644
--- a/Zend/tests/type_declarations/typed_properties_033.phpt
+++ b/Zend/tests/type_declarations/typed_properties_033.phpt
@@ -26,7 +26,7 @@ public function &fetch() {
?>
--EXPECTF--
TypeError: Cannot assign float to reference held by property class@anonymous%0%s::$qux of type int
-object(class@anonymous)#1 (4) {
+object(class@anonymous%0%s)#1 (4) {
["foo"]=>
int(2)
["bar"]=>
diff --git a/Zend/tests/type_declarations/typed_properties_034.phpt b/Zend/tests/type_declarations/typed_properties_034.phpt
index 1ba07f59bb5..9c7f10f9170 100644
--- a/Zend/tests/type_declarations/typed_properties_034.phpt
+++ b/Zend/tests/type_declarations/typed_properties_034.phpt
@@ -43,7 +43,7 @@ function foo(?int &$a) {
int(10)
int(10)
TypeError: Cannot assign null to reference held by property class@anonymous%0%s::$baz of type int
-object(class@anonymous)#1 (2) {
+object(class@anonymous%0%s)#1 (2) {
["bar"]=>
&int(10)
["baz"]=>
diff --git a/Zend/tests/type_declarations/typed_properties_037.phpt b/Zend/tests/type_declarations/typed_properties_037.phpt
index 87efa3317a0..54616103600 100644
--- a/Zend/tests/type_declarations/typed_properties_037.phpt
+++ b/Zend/tests/type_declarations/typed_properties_037.phpt
@@ -9,7 +9,7 @@
var_dump($foo);
?>
--EXPECTF--
-object(class@anonymous)#%d (1) {
+object(class@anonymous%0%s)#%d (1) {
["bar"]=>
int(10)
["qux"]=>
diff --git a/Zend/tests/type_declarations/typed_properties_038.phpt b/Zend/tests/type_declarations/typed_properties_038.phpt
index 0f7ac9b239c..d62df628ff8 100644
--- a/Zend/tests/type_declarations/typed_properties_038.phpt
+++ b/Zend/tests/type_declarations/typed_properties_038.phpt
@@ -41,22 +41,22 @@
?>
--EXPECTF--
TypeError: Cannot increment property class@anonymous%0%s::$bar of type int past its maximal value
-object(class@anonymous)#1 (1) {
+object(class@anonymous%0%s)#1 (1) {
["bar"]=>
int(%d)
}
TypeError: Cannot assign float to property class@anonymous%0%s::$bar of type int
-object(class@anonymous)#1 (1) {
+object(class@anonymous%0%s)#1 (1) {
["bar"]=>
int(%d)
}
TypeError: Cannot increment property class@anonymous%0%s::$bar of type int past its maximal value
-object(class@anonymous)#1 (1) {
+object(class@anonymous%0%s)#1 (1) {
["bar"]=>
int(%d)
}
TypeError: Cannot assign float to property class@anonymous%0%s::$bar of type int
-object(class@anonymous)#1 (1) {
+object(class@anonymous%0%s)#1 (1) {
["bar"]=>
int(%d)
}
diff --git a/ext/opcache/tests/bug78937_1.phpt b/ext/opcache/tests/bug78937_1.phpt
index 657b306d68d..64c3beed8ae 100644
--- a/ext/opcache/tests/bug78937_1.phpt
+++ b/ext/opcache/tests/bug78937_1.phpt
@@ -19,5 +19,5 @@ class Bar {
?>
--EXPECTF--
Warning: Can't preload unlinked class Bar@anonymous: Unknown parent Bar in %spreload_bug78937.inc on line 3
-object(Bar@anonymous)#%d (0) {
+object(Bar@anonymous%0%s)#%d (0) {
}
diff --git a/ext/opcache/tests/bug78937_2.phpt b/ext/opcache/tests/bug78937_2.phpt
index eb359cee96b..2415582054d 100644
--- a/ext/opcache/tests/bug78937_2.phpt
+++ b/ext/opcache/tests/bug78937_2.phpt
@@ -20,5 +20,5 @@ class Bar {
?>
--EXPECTF--
Warning: Can't preload unlinked class Bar@anonymous: Unknown parent Bar in %spreload_bug78937.inc on line 3
-object(Bar@anonymous)#%d (0) {
+object(Bar@anonymous%0%s)#%d (0) {
}
diff --git a/ext/opcache/tests/preload_008.phpt b/ext/opcache/tests/preload_008.phpt
index c6ae2ce1d3b..746f83c0043 100644
--- a/ext/opcache/tests/preload_008.phpt
+++ b/ext/opcache/tests/preload_008.phpt
@@ -15,6 +15,6 @@
<?php
var_dump(get_anon());
?>
---EXPECT--
-object(class@anonymous)#1 (0) {
+--EXPECTF--
+object(class@anonymous%0%s)#1 (0) {
}
diff --git a/ext/reflection/tests/ReflectionGenerator_basic.phpt b/ext/reflection/tests/ReflectionGenerator_basic.phpt
index f215bf4c0dd..b541c483e99 100644
--- a/ext/reflection/tests/ReflectionGenerator_basic.phpt
+++ b/ext/reflection/tests/ReflectionGenerator_basic.phpt
@@ -59,7 +59,7 @@ function a() {
["class"]=>
string(%d) "class@anonymous%s"
["object"]=>
- object(class@anonymous)#%d (0) {
+ object(class@anonymous%0%s)#%d (0) {
}
["type"]=>
string(2) "->"
@@ -80,7 +80,7 @@ function a() {
["class"]=>
string(%d) "class@anonymous%s"
}
-object(class@anonymous)#1 (0) {
+object(class@anonymous%0%s)#1 (0) {
}
object(Generator)#%d (1) {
["function"]=>
diff --git a/ext/standard/tests/array/compact_this.phpt b/ext/standard/tests/array/compact_this.phpt
index f3677e03e27..b7425c0e815 100644
--- a/ext/standard/tests/array/compact_this.phpt
+++ b/ext/standard/tests/array/compact_this.phpt
@@ -28,19 +28,19 @@ function test(){
);
?>
---EXPECT--
+--EXPECTF--
array(1) {
["this"]=>
- object(class@anonymous)#1 (0) {
+ object(class@anonymous%0%s)#1 (0) {
}
}
array(1) {
["this"]=>
- object(class@anonymous)#1 (0) {
+ object(class@anonymous%0%s)#1 (0) {
}
}
array(1) {
["this"]=>
- object(class@anonymous)#1 (0) {
+ object(class@anonymous%0%s)#1 (0) {
}
}
diff --git a/ext/standard/tests/class_object/get_object_vars_variation_004.phpt b/ext/standard/tests/class_object/get_object_vars_variation_004.phpt
index 84827134c1b..a7af049ebd5 100644
--- a/ext/standard/tests/class_object/get_object_vars_variation_004.phpt
+++ b/ext/standard/tests/class_object/get_object_vars_variation_004.phpt
@@ -32,7 +32,7 @@ public function jsonSerialize(): mixed {
[12]=>
int(6)
["test"]=>
- object(JsonSerializable@anonymous)#2 (0) {
+ object(JsonSerializable@anonymous%0%s)#2 (0) {
}
}
array(4) {
@@ -43,6 +43,6 @@ public function jsonSerialize(): mixed {
[12]=>
int(6)
["test"]=>
- object(JsonSerializable@anonymous)#2 (0) {
+ object(JsonSerializable@anonymous%0%s)#2 (0) {
}
}
diff --git a/ext/standard/tests/general_functions/debug_zval_dump_gh19801_memory_leak.phpt b/ext/standard/tests/general_functions/debug_zval_dump_gh19801_memory_leak.phpt
index cf2f1d444f1..012d0991515 100644
--- a/ext/standard/tests/general_functions/debug_zval_dump_gh19801_memory_leak.phpt
+++ b/ext/standard/tests/general_functions/debug_zval_dump_gh19801_memory_leak.phpt
@@ -25,7 +25,7 @@ function __debugInfo() {
reference refcount(%d) {
array(1) packed refcount(%d){
[0]=>
- object(class@anonymous)#1 (0) refcount(%d){
+ object(class@anonymous%0%s)#1 (0) refcount(%d){
}
}
}
diff --git a/ext/standard/tests/general_functions/var_dump_gh19801_memory_leak.phpt b/ext/standard/tests/general_functions/var_dump_gh19801_memory_leak.phpt
index f0522916de4..68333d3c884 100644
--- a/ext/standard/tests/general_functions/var_dump_gh19801_memory_leak.phpt
+++ b/ext/standard/tests/general_functions/var_dump_gh19801_memory_leak.phpt
@@ -24,7 +24,7 @@ function __debugInfo() {
["a"]=>
&array(1) {
[0]=>
- object(class@anonymous)#1 (0) {
+ object(class@anonymous%0%s)#1 (0) {
}
}
}
diff --git a/ext/standard/tests/serialize/bug81111.phpt b/ext/standard/tests/serialize/bug81111.phpt
index 5a004476abb..e7f21b7c6c1 100644
--- a/ext/standard/tests/serialize/bug81111.phpt
+++ b/ext/standard/tests/serialize/bug81111.phpt
@@ -46,7 +46,7 @@ public function __unserialize($value) { }
?>
--EXPECTF--
Exception: Serialization of 'MySplFileInfo' is not allowed
-Exception: Serialization of 'class@anonymous' is not allowed
+Exception: Serialization of 'class@anonymous%0%s' is not allowed
Exception: Unserialization of 'MySplFileInfo' is not allowed
Exception: Unserialization of 'MySplFileInfo' is not allowed
diff --git a/ext/standard/tests/serialize/unserialize_allowed_classes_option_invalid_class_names.phpt b/ext/standard/tests/serialize/unserialize_allowed_classes_option_invalid_class_names.phpt
index 74997939817..30740760570 100644
--- a/ext/standard/tests/serialize/unserialize_allowed_classes_option_invalid_class_names.phpt
+++ b/ext/standard/tests/serialize/unserialize_allowed_classes_option_invalid_class_names.phpt
@@ -40,9 +40,9 @@ class foo {
}
?>
---EXPECT--
+--EXPECTF--
ValueError: unserialize(): Option "allowed_classes" must be an array of class names, " whitespace " given
ValueError: unserialize(): Option "allowed_classes" must be an array of class names, "name
with whitespace" given
ValueError: unserialize(): Option "allowed_classes" must be an array of class names, "$dollars" given
-ValueError: unserialize(): Option "allowed_classes" must be an array of class names, "have" given
+ValueError: unserialize(): Option "allowed_classes" must be an array of class names, "have%0nul_byte" given
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 97eb7cb7f22..c7db83f0062 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -92,8 +92,8 @@ static void php_object_property_dump(zend_property_info *prop_info, zval *zv, ze
if (Z_TYPE_P(zv) == IS_UNDEF) {
ZEND_ASSERT(ZEND_TYPE_IS_SET(prop_info->type));
zend_string *type_str = zend_type_to_string(prop_info->type);
- php_printf("%*cuninitialized(%s)\n",
- level + 1, ' ', ZSTR_VAL(type_str));
+ php_printf("%*cuninitialized(%pS)\n",
+ level + 1, ' ', type_str);
zend_string_release(type_str);
} else {
php_var_dump(zv, level + 2);
@@ -177,7 +177,7 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */
zend_class_entry *ce = Z_OBJCE_P(struc);
if ((ce->ce_flags & ZEND_ACC_ENUM) && ce->__debugInfo == NULL) {
zval *case_name_zval = zend_enum_fetch_case_name(Z_OBJ_P(struc));
- php_printf("%senum(%s::%s)\n", COMMON, ZSTR_VAL(ce->name), Z_STRVAL_P(case_name_zval));
+ php_printf("%senum(%pS::%pS)\n", COMMON, ce->name, Z_STR_P(case_name_zval));
return;
}
zend_object *zobj = Z_OBJ_P(struc);
@@ -191,12 +191,12 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */
myht = zend_get_properties_for(struc, ZEND_PROP_PURPOSE_DEBUG);
if (ce->ce_flags & ZEND_ACC_ENUM) {
zval *case_name_zval = zend_enum_fetch_case_name(Z_OBJ_P(struc));
- php_printf("%senum(%s::%s) (%d) {\n", COMMON, ZSTR_VAL(ce->name), Z_STRVAL_P(case_name_zval), myht ? zend_array_count(myht) : 0);
+ php_printf("%senum(%pS::%pS) (%d) {\n", COMMON, ce->name, Z_STR_P(case_name_zval), myht ? zend_array_count(myht) : 0);
} else {
class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc));
const char *prefix = php_var_dump_object_prefix(Z_OBJ_P(struc));
- php_printf("%s%sobject(%s)#%d (%d) {\n", COMMON, prefix, ZSTR_VAL(class_name), Z_OBJ_HANDLE_P(struc), myht ? zend_array_count(myht) : 0);
+ php_printf("%s%sobject(%pS)#%d (%d) {\n", COMMON, prefix, class_name, Z_OBJ_HANDLE_P(struc), myht ? zend_array_count(myht) : 0);
zend_string_release_ex(class_name, 0);
}
@@ -312,8 +312,8 @@ static void zval_object_property_dump(zend_property_info *prop_info, zval *zv, z
}
if (prop_info && Z_TYPE_P(zv) == IS_UNDEF) {
zend_string *type_str = zend_type_to_string(prop_info->type);
- php_printf("%*cuninitialized(%s)\n",
- level + 1, ' ', ZSTR_VAL(type_str));
+ php_printf("%*cuninitialized(%pS)\n",
+ level + 1, ' ', type_str);
zend_string_release(type_str);
} else {
php_debug_zval_dump(zv, level + 2);
@@ -407,7 +407,7 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level) /* {{{ */
class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc));
const char *prefix = php_var_dump_object_prefix(Z_OBJ_P(struc));
- php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", prefix, ZSTR_VAL(class_name), Z_OBJ_HANDLE_P(struc), myht ? zend_array_count(myht) : 0, Z_REFCOUNT_P(struc));
+ php_printf("%sobject(%pS)#%d (%d) refcount(%u){\n", prefix, class_name, Z_OBJ_HANDLE_P(struc), myht ? zend_array_count(myht) : 0, Z_REFCOUNT_P(struc));
zend_string_release_ex(class_name, 0);
if (myht) {
ZEND_HASH_FOREACH_KEY_VAL(myht, index, key, val) {
@@ -929,7 +929,7 @@ static HashTable* php_var_serialize_call_sleep(zend_object *obj, zend_function *
if (Z_TYPE(retval) != IS_ARRAY) {
zval_ptr_dtor(&retval);
- php_error_docref(NULL, E_WARNING, "%s::__sleep() should return an array only containing the names of instance-variables to serialize", ZSTR_VAL(obj->ce->name));
+ php_error_docref(NULL, E_WARNING, "%pS::__sleep() should return an array only containing the names of instance-variables to serialize", obj->ce->name);
return NULL;
}
@@ -951,7 +951,7 @@ static int php_var_serialize_call_magic_serialize(zval *retval, zval *obj) /* {{
if (Z_TYPE_P(retval) != IS_ARRAY) {
zval_ptr_dtor(retval);
- zend_type_error("%s::__serialize() must return an array", ZSTR_VAL(Z_OBJCE_P(obj)->name));
+ zend_type_error("%pS::__serialize() must return an array", Z_OBJCE_P(obj)->name);
return FAILURE;
}
@@ -980,7 +980,7 @@ static int php_var_serialize_try_add_sleep_prop(
if (!zend_hash_add(ht, name, val)) {
php_error_docref(NULL, E_WARNING,
- "\"%s\" is returned from __sleep() multiple times", ZSTR_VAL(error_name));
+ "\"%pS\" is returned from __sleep() multiple times", error_name);
return SUCCESS;
}
@@ -1006,8 +1006,8 @@ static int php_var_serialize_get_sleep_props(
ZVAL_DEREF(name_val);
if (Z_TYPE_P(name_val) != IS_STRING) {
php_error_docref(NULL, E_WARNING,
- "%s::__sleep() should return an array only containing the names of instance-variables to serialize",
- ZSTR_VAL(ce->name));
+ "%pS::__sleep() should return an array only containing the names of instance-variables to serialize",
+ ce->name);
}
name = zval_get_tmp_string(name_val, &tmp_name);
@@ -1054,7 +1054,7 @@ static int php_var_serialize_get_sleep_props(
}
php_error_docref(NULL, E_WARNING,
- "\"%s\" returned as member variable from __sleep() but does not exist", ZSTR_VAL(name));
+ "\"%pS\" returned as member variable from __sleep() but does not exist", name);
zend_tmp_string_release(tmp_name);
} ZEND_HASH_FOREACH_END();
@@ -1206,8 +1206,8 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
}
if (ce->ce_flags & ZEND_ACC_NOT_SERIALIZABLE) {
- zend_throw_exception_ex(NULL, 0, "Serialization of '%s' is not allowed",
- ZSTR_VAL(ce->name));
+ zend_throw_exception_ex(NULL, 0, "Serialization of '%pS' is not allowed",
+ ce->name);
return;
}
@@ -1521,7 +1521,7 @@ PHPAPI void php_unserialize_with_options(zval *return_value, const char *buf, co
goto cleanup;
}
if (UNEXPECTED(!zend_is_valid_class_name(name))) {
- zend_value_error("%s(): Option \"allowed_classes\" must be an array of class names, \"%s\" given", function_name, ZSTR_VAL(name));
+ zend_value_error("%s(): Option \"allowed_classes\" must be an array of class names, \"%pS\" given", function_name, name);
zend_tmp_string_release(tmp_str);
goto cleanup;
}