1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/Zend/tests/gh16725.phpt
Ilija Tovilo 048fa7bacc Fix get_object_vars() for non-hooked props in hooked prop iter
The zend_hash_update_ind() variant unwraps indirects, rather than creating them.
Don't use _zend_hash_append_ind() because the property might already exist.

Fixes GH-16725
Closes GH-16805
2024-11-18 16:20:19 +01:00

28 lines
491 B
PHP

--TEST--
GH-16725: Incorrect access check for non-hooked props in hooked object iterator
--FILE--
<?php
class C implements JsonSerializable
{
private string $prop1 { get => 'bar'; }
public function __construct(
private string $prop2,
) {}
public function jsonSerialize(): mixed {
return get_object_vars($this);
}
}
$obj = new C('foo');
var_dump(get_object_vars($obj));
echo json_encode($obj);
?>
--EXPECT--
array(0) {
}
{"prop1":"bar","prop2":"foo"}