On Mon, Mar 16, 2020 at 9:31 AM Marco Pivetta <[email protected]> wrote:
> What happens if you have an expression that throws?
>
> class Foo
> {
> public $a;
> public $b;
> public $c;
> }
>
> $instance = new Foo();
>
> function iThrow() {
> throw new \Exception();
> }
>
> try {
> $foo ->[
> a = 'a',
> b = iThrow(),
> c = 'c',
> ];
> } catch (\Throwable $e) {
> var_export($foo); // ???
> }
Hi Marco!
Trivial question - let's see what happens:
Just replace COPA with the old syntax and run it:
try {
$foo->a = 'a';
$foo->b = iThrow();
$foo->x = 'c';
} catch (\Throwable $e) {
var_export($foo); // ???
}
Result:
Foo::__set_state(array(
'a' => 'a',
'b' => NULL,
'c' => NULL,
))
So the first property will be set, the rest will be left as they were.
Best,
Jakob
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php