Skip to content

Commit 4d03925

Browse files
add test for a promoted readonly property being set in both data and args
1 parent 6af7ab4 commit 4d03925

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ext/reflection/tests/ReflectionClass_newInstanceFromData_001.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ var_dump($rcE->newInstanceFromData(['a' => 123, 'b' => 'good'], [456, 'foo']));
129129
// class with readonly promoted property
130130
var_dump($rcF->newInstanceFromData(['a' => 123], ['b' => 'good']));
131131

132+
try
133+
{
134+
var_dump($rcF->newInstanceFromData(['a' => 123, 'b' => 'first'], ['b' => 'second']));
135+
echo "you should not see this\n";
136+
}
137+
catch(Throwable $e)
138+
{
139+
echo "Exception: " . $e->getMessage() . "\n";
140+
}
141+
132142
// readonly property set in the constructor
133143
try
134144
{
@@ -199,6 +209,7 @@ object(F)#%d (2) {
199209
["b"]=>
200210
string(4) "good"
201211
}
212+
Exception: Cannot modify readonly property F::$b
202213
Exception: Cannot modify readonly property G::$b
203214
object(H)#%d (1) {
204215
["a"]=>

0 commit comments

Comments
 (0)