Skip to content

Commit 75d4d9d

Browse files
committed
Fix tests
1 parent 556ed13 commit 75d4d9d

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

Zend/tests/readonly_props/readonly_clone_success4.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Foo {
1616
echo $e->getMessage() . "\n";
1717
}
1818

19-
$this->bar = 1;
19+
$this->bar = 2;
2020
}
2121
}
2222

@@ -30,10 +30,10 @@ var_dump(clone $foo);
3030
Cannot assign string to property Foo::$bar of type int
3131
object(Foo)#%d (%d) {
3232
["bar"]=>
33-
int(1)
33+
int(2)
3434
}
3535
Cannot assign string to property Foo::$bar of type int
3636
object(Foo)#%d (%d) {
3737
["bar"]=>
38-
int(1)
38+
int(2)
3939
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Test failing readonly assignment with coercion
3+
--FILE--
4+
<?php
5+
6+
class Foo {
7+
public readonly string $bar;
8+
9+
public function __construct() {
10+
$this->bar = 'bar';
11+
try {
12+
$this->bar = 42;
13+
} catch (Error $e) {
14+
echo $e->getMessage(), "\n";
15+
}
16+
}
17+
}
18+
19+
new Foo();
20+
21+
?>
22+
--EXPECTF--
23+
Cannot modify readonly property Foo::$bar

Zend/zend_object_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ ZEND_API zval *zend_std_write_property(zend_object *zobj, zend_string *name, zva
832832
if (Z_PROP_FLAG_P(variable_ptr) & IS_PROP_REINITABLE) {
833833
Z_PROP_FLAG_P(variable_ptr) &= ~IS_PROP_REINITABLE;
834834
} else {
835-
Z_TRY_DELREF_P(value);
835+
zval_ptr_dtor(&tmp);
836836
zend_readonly_property_modification_error(prop_info);
837837
variable_ptr = &EG(error_zval);
838838
goto exit;

0 commit comments

Comments
 (0)