Bug #79053 [Com]: No error is reported when using null coalescing operator
| From: | rubencm at gmail dot com | Date: | Wed, 01 Jan 2020 13:52:46 +0000 |
| Subject: | Bug #79053 [Com]: No error is reported when using null coalescing operator | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224650@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79053&edit=1
ID: 79053
Comment by: rubencm at gmail dot com
Reported by: rubencm at gmail dot com
Summary: No error is reported when using null coalescing
operator
Status: Open
Type: Bug
Package: *General Issues
PHP Version: 7.4.1
Block user comment: N
Private report: N
New Comment:
Well, just close the report if you want.
But I thought that all this cases should have the same behavior, while in the last line the error
isn't being reported.
If is the expected behavior just close this.
<?php
function bar()
{
return false[''];
}
bar();
false[''];
bar()??false;
false['']??false;
Previous Comments:
------------------------------------------------------------------------
[2020-01-01 13:48:20] bugreports at gmail dot com
<?php
function bar()
{
return false[''];
}
?>
this has again *nothing* to do with "null coalescing operator" because you are not using
it at all, that way you would usie it
<?php
function bar()
{
return false[''] ?? NULL;
}
that all looks like lack of understand php basics
?>
------------------------------------------------------------------------
[2020-01-01 13:44:38] bugreports at gmail dot com
you can't seriously compare that becaus ethe case is completly wrong
trigger_error("foo", E_USER_NOTICE); has nothing to do with "null coalescing
operator" at all, you call the function and the function does what it is supposed to do, throw
a E_USER_NOTICE
why do you think "null coalescing operator" is involved here at all?
teh function returns NULL and "bar()??false" does what it is supposed to do
------------------------------------------------------------------------
[2020-01-01 13:41:32] rubencm at gmail dot com
Here is an equivalent codes with diferent behavior
<?php
function bar()
{
return false[''];
}
var_dump(bar()??false);
?>
<?php
var_dump(false['']??false);
?>
------------------------------------------------------------------------
[2020-01-01 13:37:42] rubencm at gmail dot com
Well, in this case the notice is being reported, that still don't have much sense for me.
<?php
function bar()
{
trigger_error("foo", E_USER_NOTICE);
return null;
}
var_dump(bar()??false);
------------------------------------------------------------------------
[2020-01-01 13:28:45] bugreports at gmail dot com
taht's the whole point of null coalescing operator
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=79053
--
Edit this bug report at https://bugs.php.net/bug.php?id=79053&edit=1