Re: [RFC] [DISCUSSION] Compact Object Property Assignment

From: Date: Tue, 17 Mar 2020 01:26:57 +0000
Subject: Re: [RFC] [DISCUSSION] Compact Object Property Assignment
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-109086@lists.php.net to get a copy of this message
On Mon, Mar 16, 2020 at 9:31 AM Marco Pivetta <ocramius@gmail.com> 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

« previous php.internals (#109086) next »