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
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
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;
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
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
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