xref: /PHP-8.3/ext/reflection/tests/bug79683.phpt (revision 2447fd9f)
1--TEST--
2Bug #79683: Fake reflection scope affects __toString()
3--FILE--
4<?php
5
6class A
7{
8    private string $prop1 = '123';
9
10    public function __toString()
11    {
12        return $this->prop1;
13    }
14}
15
16class B
17{
18    private string $prop2;
19}
20
21$b = new B();
22
23$reflector = new ReflectionClass($b);
24$property = $reflector->getProperty('prop2');
25$property->setAccessible(true);
26$property->setValue($b, new A());
27
28var_dump($b);
29
30?>
31--EXPECT--
32object(B)#1 (1) {
33  ["prop2":"B":private]=>
34  string(3) "123"
35}
36