[php-src] Issue #8204: Nullsafe Operator doesn't work with uninitialized properties

From: Date: Thu, 17 Mar 2022 10:40:39 +0000
Subject: [php-src] Issue #8204: Nullsafe Operator doesn't work with uninitialized properties
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240385@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8204 Comment Author: iluuu1994 > I think the biggest confusion here is that another operator interacting with null works: I agree that the naming clash of nullsafe and null coalescing is somewhat unfortunate. However, the decision of handling or not handling IS_UNDEF was very explicit for both and not something we can change at this point without and RFC. > Is there a reason one guards against IS_UNDEF and the other doesn't? In my personal opinion, the null coalescing operator silences too many errors. E..g I think $doesNotExist ?? 'bar' should emit a undefined variable warning. The same for $foo->doesNotExist ?? 'bar'. On the other hand, that makes it more inconsistent (not behaving the same as isset()) and thus worse in other ways.

« previous php.bugs (#240385) next »