But wait!
In your example, funds won't get detracted. If `$accounts->get($receiver)`
will return `null`, then everything inside `addFunds(...)` will not be
executed.
Your example (simplified): https://3v4l.org/38Dk3
Another one:
```php
function expensive_function() {
var_dump(__FUNCTION__);
However, `null` value is not a good way to use a default value instead of
an object.
When it comes to polymorphism, we would like to avoid null checks from
being all around.
The same goes not only for `->`, but also return / argument type-hintings.
Why do we even need to know that object can be
Hm, yes. If the `get()` method can return `null`, then it is a problem.
Currently `null` is abused to indicate that value was not found.
`NotFoundException` should be thrown instead.
But.. yeah, we can't just use `nullsafe` by default because of abuse of
`null`.
On Tue, Nov 3, 2020 at 10:11 PM
On 03.11.2020 at 21:52, Nuno Maduro wrote:
> Hey internals,
>
> Thank you for the feedback on this thread so far.
>
> I think a detailed RFC will help to clarify the proposal and reasoning
> behind the chosen syntax. And after that, we can keep discussing the
> proposal.
>
> So I can move
Hey,
On Tue, Nov 3, 2020 at 9:11 PM Marco Pivetta wrote:
> Overall, "null safe" can be very dangerous if made the default.
>
> Here's a scenario where I'd never want "null safe" behaviour (which does
> anything but introducing safety):
>
> ```php
> $accounts->get($receiver)
> ->addFunds(
>
Hey internals,
Thank you for the feedback on this thread so far.
I think a detailed RFC will help to clarify the proposal and reasoning
behind the chosen syntax. And after that, we can keep discussing the
proposal.
So I can move forward, do you mind giving me the necessary karma to create
RFCs?
Heya,
On Tue, Nov 3, 2020, 17:38 Eugene Sidelnyk wrote:
> Hello, internals!
> I am wondering why don't we use ordinary `->` operator with safe null
> handling? Programmers will be more prone to return null values. And thus,
> in most of cases `?->` will replace `->`.
> Why do we need another
> > But some people vote down, because they are "narrow-minded" and "have bad
> > preconceptions" and would like to find more things they like about the
> > feature.
>
I think these words are quoted from a comment of mine on the operator
overloading RFC (or a surprising coincidence). This was a
> Le 3 nov. 2020 à 17:38, Eugene Sidelnyk a écrit :
>
> Hello, internals!
> I am wondering why don't we use ordinary `->` operator with safe null
> handling? Programmers will be more prone to return null values. And thus,
> in most of cases `?->` will replace `->`.
> Why do we need another
On Tue, 3 Nov 2020 at 19:36, Eugene Sidelnyk wrote:
> But some people vote down, because they are "narrow-minded" and "have bad
> preconceptions" and would like to find more things they like about the
> feature.
Please don't call people names.
People vote based on their own choice, and yes
About implemented, there were many implemented features, but not accepted.
I was very frustrated, when I knew that PHP could have
https://wiki.php.net/rfc/userspace_operator_overloading , and it was
already implemented.
But some people vote down, because they are "narrow-minded" and "have bad
-- Forwarded message -
From: G. P. B.
Date: Tue, Nov 3, 2020 at 9:08 PM
Subject: Re: [PHP-DEV] Nullsafe
To: Eugene Sidelnyk
On Tue, 3 Nov 2020 at 19:05, Eugene Sidelnyk wrote:
> Null value by itself was invented to indicate lack of data.
> But we can't just use it instead of
On Tue, Nov 3, 2020, 7:58 PM Benjamin Morel
wrote:
> Hi,
>
> It currently returns null but issues a warning (which can be, and often
> is, converted to an exception by frameworks / custom error handlers):
> https://3v4l.org/1ZkVC
>
> The new operator returns null with no warning:
>
-- Forwarded message -
From: Eugene Sidelnyk
Date: Tue, Nov 3, 2020 at 9:05 PM
Subject: Re: [PHP-DEV] Nullsafe
To: G. P. B.
Null value by itself was invented to indicate lack of data.
But we can't just use it instead of objects, because of how it works.
We need to create a
-- Forwarded message -
From: Eugene Sidelnyk
Date: Tue, Nov 3, 2020 at 8:11 PM
Subject: Re: [PHP-DEV] Nullsafe
To: Benjamin Morel
When trying call a method, php falls with fatal error:
https://3v4l.org/jk5Fp
With nullsafe it silently returns null:
https://3v4l.org/MhXtM
Are
-- Forwarded message -
From: Eugene Sidelnyk
Date: Tue, Nov 3, 2020 at 7:08 PM
Subject: Re: [PHP-DEV] Nullsafe
To: Benjamin Morel
But currently working code doesn't fail with NullPointerException?
Otherwise it would not be a working code.
Early fail will be when we try return /
On Wed, 21 Oct 2020 at 16:56, Eugene Sidelnyk wrote:
> What is the practical use case for this. I think it will make code a bit
> more confusing
>
> On Wed, Oct 21, 2020, 5:59 PM G. P. B. wrote:
>
>> Hello internals,
>>
>> A rather short RFC about adding support for the "0o" prefix for octal
>>
On Tue, 3 Nov 2020 at 19:08, G. P. B. wrote:
> On Tue, 3 Nov 2020 at 19:05, Eugene Sidelnyk wrote:
>
>> Null value by itself was invented to indicate lack of data.
>> But we can't just use it instead of objects, because of how it works.
>> We need to create a boilerplate of NullObjects.
>>
On Tue, 3 Nov 2020 at 16:48, Benjamin Morel
wrote:
> On Tue, 3 Nov 2020 at 17:38, Eugene Sidelnyk wrote:
>
> > I am wondering why don't we use ordinary `->` operator with safe null
> > handling?
>
Implicit nullable is terrible, moreover I don't see why users should return
null values more
On Tue, 3 Nov 2020 at 17:38, Eugene Sidelnyk wrote:
> I am wondering why don't we use ordinary `->` operator with safe null
> handling?
Hi,
- changing the current behaviour of `->` would be a huge BC break
- and if we need another reason, there are many situations where you do
want to fail
Hello, internals!
I am wondering why don't we use ordinary `->` operator with safe null
handling? Programmers will be more prone to return null values. And thus,
in most of cases `?->` will replace `->`.
Why do we need another operator, if we can implement null safe in current
operator without BC
21 matches
Mail list logo