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_clone_error1.phpt
Ilija Tovilo 3f7dadfeca Fix readonly+clone JIT issues
Closes GH-10748
2023-03-07 13:20:52 +01:00

37 lines
520 B
PHP

--TEST--
Readonly property cannot be reset twice during cloning
--FILE--
<?php
class Foo {
public function __construct(
public readonly int $bar
) {}
public function __clone()
{
$this->bar = 2;
var_dump($this);
$this->bar = 3;
}
}
$foo = new Foo(1);
try {
clone $foo;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
echo "done";
?>
--EXPECT--
object(Foo)#2 (1) {
["bar"]=>
int(2)
}
Cannot modify readonly property Foo::$bar
done