Re: [PHP-DEV] Return When

2024-12-04 Thread Daniel Baldwin
To me it seams too similar to: return !$result['success']?? $result; Which returns at that point, regardless of the status of $result[’success’]; I think this if (!$result['success']) return $result; Is short enough and is clear when scanning the code that it will not return anything

Re: [PHP-DEV] Return When

2024-12-04 Thread Jorg Sowa
Hey Volodymyr, You can already write: $success or throw new Exception('I am here'); Honestly, I don't see a good reason to introduce another syntax to do the same thing. Kind regards, Jorg Sowa

Re: [PHP-DEV] Return When

2024-12-04 Thread Volodymyr Volynets
Great, thanks I went through RFC and discussions and there's new findings with throw: 1. *throw when* condition, new Exception('Massage!!!'); - throw when $success, new Exception('I am here'); 2. *return when* condition, 'return value'; - return when $success, $result; - retu

Re: [PHP-DEV] Multiple property assigning without constructor

2024-12-04 Thread Vinicius Dias
> But often classes need constructors only to set properties. In such cases, > constructors become redundant. Actually, the behavior is not the same and the constructors are not redundant. Taking your example: ``` class Person { public string $firstName; public int $age; } $person = new

Re: [PHP-DEV] Multiple property assigning without constructor

2024-12-04 Thread Erick de Azevedo Lima
> > $person = new Person("Name", 43) { > firstName: "John", > age: 42 > }; Hi! You could achieve similar functionality with a simple user-land method "assign". If you put such a method on a trait, you can use it everywhere. See the example: $propVal) { $this->$prop

[PHP-DEV] Multiple property assigning without constructor

2024-12-04 Thread Taras Chornyi
Hi Internals, I would like to discuss the possibility of assigning multiple public properties at once during the class initialization. Currently, with constructor property promotion we've already achieved the ability to skip a lot of boilerplate code. With property accessors (aka hooks) we could r