[PHP-DEV] [DISCUSSION] Ternary nullcoalesce operator

2025-02-20 Thread Mihail Liahimov
Now we have nullcoalesca operator in PHP: $a = $a ?? $b; And nullcoalesce assignment operator: $a ??= $b; (which is equivalent of previous example with nullcoalesce operator). Also we have a short syntax for ternary operator: $a = $a ?: $b; which is equivalent to: $a = $a ? $b : $a; Maybe

Re: [PHP-DEV] RFC: Not Null Assertion Operator

2025-02-11 Thread Mihail Liahimov
HI! I was referring to this particular scenario of using this operator. Constantly writing checks and nullsafes seems like something superfluous. If we have an opportunity at the language level to throw a domain exception or something like that, it will be convenient. Besides, it will also be usef

[PHP-DEV] Override static in return types with self in final classes

2025-02-10 Thread Mihail Liahimov
After implementing static types in return methods, I noticed one thing that was illogical, in my opinion. We have the following code: interface A { public function method1(): static; } final class Foo extends B implements A { public function method1(): static { return $this;

Re: [PHP-DEV] RFC: Not Null Assertion Operator

2025-02-06 Thread Mihail Liahimov
tor will help avoid writing unnecessary code. The problem, of course, will be catching errors. It is not clear how to catch errors by a specific value. I will think about it. ср, 5 февр. 2025 г. в 17:09, Ilija Tovilo : > Hi Mihail > > Thanks for your proposal. > > On Wed, Feb

[PHP-DEV] RFC: Not Null Assertion Operator

2025-02-06 Thread Mihail Liahimov
Thank you for your answer. Now I will give examples for better understanding. Simple examples from Typescript: let foo = ... foo!.bar() foo!.someProperty.baz() Examples of potentially using in PHP: Without this operator we writing this code: $foo = ... if ($foo === null) { throw new FooIsN

[PHP-DEV] RFC: Not Null Assertion Operator

2025-02-05 Thread Mihail Liahimov
Good afternoon. I would like to create an RFC on the implementation of the NOT null assertion operator. Do you think it makes sense to create it? I was able to implement the operator. I've already posted a draft in my github - https://github.com/rekmixa/php-src/tree/feature/not_null_assertion_opera