Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ PHP NEWS
. Fix ReflectionProperty::isReadable() not working for indirect slots.
(ndossche)

- Standard:
. Fixed var_dump() and debug_zval_dump() printing the full name of anonymous
classes, including the NUL byte. (Jorg Sowa)

- Streams:
. Fixed in-place URL decoding of interned strings in the HTTP and FTP
wrappers. (Alejandro Pacheco)
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/anon/012.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Ensure correct unmangling of private property names for anonymous class instance
<?php
var_dump(new class { private $foo; });
?>
--EXPECTF--
object(class@anonymous%0%s)#1 (1) {
--EXPECT--
object(class@anonymous)#1 (1) {
["foo":"class@anonymous":private]=>
NULL
}
4 changes: 2 additions & 2 deletions Zend/tests/anon/013.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ $foo = function() {
$closure = Closure::bind($foo, $class, $class);
var_dump($closure());
?>
--EXPECTF--
object(class@anonymous%0%s)#1 (0) {
--EXPECT--
object(class@anonymous)#1 (0) {
}
4 changes: 2 additions & 2 deletions Zend/tests/bug72598.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ new class {
?>
--EXPECTF--
Warning: ref(): Argument #1 ($ref) must be passed by reference, value given in %s on line %d
object(class@anonymous%0%s)#1 (0) {
object(class@anonymous)#1 (0) {
}

Warning: ref(): Argument #1 ($ref) must be passed by reference, value given in %s on line %d
object(class@anonymous%0%s)#1 (0) {
object(class@anonymous)#1 (0) {
}
6 changes: 3 additions & 3 deletions Zend/tests/bug73816.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ var_dump(anon());
var_dump(anon());

?>
--EXPECTF--
object(class@anonymous%0%s)#1 (1) {
--EXPECT--
object(class@anonymous)#1 (1) {
["prop1":"class@anonymous":private]=>
NULL
}
object(class@anonymous%0%s)#1 (1) {
object(class@anonymous)#1 (1) {
["prop2":"class@anonymous":private]=>
NULL
}
4 changes: 2 additions & 2 deletions Zend/tests/constexpr/new_anon_class.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ static $x = new class {};
var_dump($x);

?>
--EXPECTF--
object(class@anonymous%0%s)#1 (0) {
--EXPECT--
object(class@anonymous)#1 (0) {
}
2 changes: 1 addition & 1 deletion Zend/tests/partial_application/static_pfa_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ Closure [ <user> function {closure:pfa:%s:13} ] {

Error: Using $this when not in object context
# Re-bound PFA
object(class@anonymous%0%s)#3 (0) {
object(class@anonymous)#3 (0) {
}
bool(true)
4 changes: 2 additions & 2 deletions Zend/tests/property_hooks/oss_fuzz_403308724.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ $y = $test->y;
var_dump($y);
var_dump($y[0]->inner);
?>
--EXPECTF--
--EXPECT--
array(2) {
[0]=>
object(class@anonymous%0%s)#2 (0) {
object(class@anonymous)#2 (0) {
}
[1]=>
int(1)
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/type_declarations/typed_properties_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var_dump(new class(1, 2.2, true, ["four"], new stdClass) {
});
?>
--EXPECTF--
object(class@anonymous%0%s)#%d (6) {
object(class@anonymous)#%d (6) {
["int"]=>
int(1)
["float"]=>
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/type_declarations/typed_properties_033.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var_dump($foo);
?>
--EXPECTF--
TypeError: Cannot assign float to reference held by property class@anonymous%0%s::$qux of type int
object(class@anonymous%0%s)#1 (4) {
object(class@anonymous)#1 (4) {
["foo"]=>
int(2)
["bar"]=>
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/type_declarations/typed_properties_034.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int(1)
int(10)
int(10)
TypeError: Cannot assign null to reference held by property class@anonymous%0%s::$baz of type int
object(class@anonymous%0%s)#1 (2) {
object(class@anonymous)#1 (2) {
["bar"]=>
&int(10)
["baz"]=>
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/type_declarations/typed_properties_037.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $foo = new class {
var_dump($foo);
?>
--EXPECTF--
object(class@anonymous%0%s)#%d (1) {
object(class@anonymous)#%d (1) {
["bar"]=>
int(10)
["qux"]=>
Expand Down
8 changes: 4 additions & 4 deletions Zend/tests/type_declarations/typed_properties_038.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ var_dump($foo);
?>
--EXPECTF--
TypeError: Cannot increment property class@anonymous%0%s::$bar of type int past its maximal value
object(class@anonymous%0%s)#1 (1) {
object(class@anonymous)#1 (1) {
["bar"]=>
int(%d)
}
TypeError: Cannot assign float to property class@anonymous%0%s::$bar of type int
object(class@anonymous%0%s)#1 (1) {
object(class@anonymous)#1 (1) {
["bar"]=>
int(%d)
}
TypeError: Cannot increment property class@anonymous%0%s::$bar of type int past its maximal value
object(class@anonymous%0%s)#1 (1) {
object(class@anonymous)#1 (1) {
["bar"]=>
int(%d)
}
TypeError: Cannot assign float to property class@anonymous%0%s::$bar of type int
object(class@anonymous%0%s)#1 (1) {
object(class@anonymous)#1 (1) {
["bar"]=>
int(%d)
}
2 changes: 1 addition & 1 deletion ext/opcache/tests/bug78937_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ var_dump(foo());
?>
--EXPECTF--
Warning: Can't preload unlinked class Bar@anonymous: Unknown parent Bar in %spreload_bug78937.inc on line 3
object(Bar@anonymous%0%s)#%d (0) {
object(Bar@anonymous)#%d (0) {
}
2 changes: 1 addition & 1 deletion ext/opcache/tests/bug78937_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ var_dump(foo());
?>
--EXPECTF--
Warning: Can't preload unlinked class Bar@anonymous: Unknown parent Bar in %spreload_bug78937.inc on line 3
object(Bar@anonymous%0%s)#%d (0) {
object(Bar@anonymous)#%d (0) {
}
4 changes: 2 additions & 2 deletions ext/opcache/tests/preload_008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows
<?php
var_dump(get_anon());
?>
--EXPECTF--
object(class@anonymous%0%s)#1 (0) {
--EXPECT--
object(class@anonymous)#1 (0) {
}
4 changes: 2 additions & 2 deletions ext/reflection/tests/ReflectionGenerator_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ array(2) {
["class"]=>
string(%d) "class@anonymous%s"
["object"]=>
object(class@anonymous%0%s)#%d (0) {
object(class@anonymous)#%d (0) {
}
["type"]=>
string(2) "->"
Expand All @@ -80,7 +80,7 @@ object(ReflectionMethod)#8 (2) {
["class"]=>
string(%d) "class@anonymous%s"
}
object(class@anonymous%0%s)#1 (0) {
object(class@anonymous)#1 (0) {
}
object(Generator)#%d (1) {
["function"]=>
Expand Down
8 changes: 4 additions & 4 deletions ext/standard/tests/array/compact_this.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ var_dump(
);

?>
--EXPECTF--
--EXPECT--
array(1) {
["this"]=>
object(class@anonymous%0%s)#1 (0) {
object(class@anonymous)#1 (0) {
}
}
array(1) {
["this"]=>
object(class@anonymous%0%s)#1 (0) {
object(class@anonymous)#1 (0) {
}
}
array(1) {
["this"]=>
object(class@anonymous%0%s)#1 (0) {
object(class@anonymous)#1 (0) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ array(4) {
[12]=>
int(6)
["test"]=>
object(JsonSerializable@anonymous%0%s)#2 (0) {
object(JsonSerializable@anonymous)#2 (0) {
}
}
array(4) {
Expand All @@ -43,6 +43,6 @@ array(4) {
[12]=>
int(6)
["test"]=>
object(JsonSerializable@anonymous%0%s)#2 (0) {
object(JsonSerializable@anonymous)#2 (0) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object(stdClass)#2 (1) refcount(%d){
reference refcount(%d) {
array(1) packed refcount(%d){
[0]=>
object(class@anonymous%0%s)#1 (0) refcount(%d){
object(class@anonymous)#1 (0) refcount(%d){
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
var_dump() and debug_zval_dump() print the short name of anonymous classes
--FILE--
<?php
$o = new class { public $a = 1; private $p; };
var_dump($o);
debug_zval_dump($o);
print_r($o);
echo "\n";
?>
--EXPECT--
object(class@anonymous)#1 (2) {
["a"]=>
int(1)
["p":"class@anonymous":private]=>
NULL
}
object(class@anonymous)#1 (2) refcount(2){
["a"]=>
int(1)
["p":"class@anonymous":private]=>
NULL
}
class@anonymous Object
(
[a] => 1
[p:class@anonymous:private] =>
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object(stdClass)#2 (1) {
["a"]=>
&array(1) {
[0]=>
object(class@anonymous%0%s)#1 (0) {
object(class@anonymous)#1 (0) {
}
}
}
6 changes: 4 additions & 2 deletions ext/standard/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ PHPAPI void php_var_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("%s%sobject(%pS)#%d (%d) {\n", COMMON, prefix, class_name, Z_OBJ_HANDLE_P(struc), myht ? zend_array_count(myht) : 0);
/* %s keeps anonymous class names short, matching property labels and print_r(). */
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);
zend_string_release_ex(class_name, 0);
}

Expand Down Expand Up @@ -407,7 +408,8 @@ 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(%pS)#%d (%d) refcount(%u){\n", prefix, class_name, Z_OBJ_HANDLE_P(struc), myht ? zend_array_count(myht) : 0, Z_REFCOUNT_P(struc));
/* %s keeps anonymous class names short, matching property labels and print_r(). */
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));
zend_string_release_ex(class_name, 0);
if (myht) {
ZEND_HASH_FOREACH_KEY_VAL(myht, index, key, val) {
Expand Down
Loading