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/readonly_props/readonly_assign_no_sideeffect.phpt

34 lines
549 B
PHP

--TEST--
Test that there can be no side-effect when a readonly property modification fails
--FILE--
<?php
class Foo {
public function __construct(
public readonly string $bar
) {}
public function write() {
$this->bar = new S();
}
}
class S {
public function __toString() {
var_dump("Side-effect in __toString()");
return "";
}
}
$foo = new Foo("");
try {
$foo->write();
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
Cannot modify readonly property Foo::$bar