Req #70278 [Opn]: Allow null to be passed by reference
| From: | cyslider at posteo dot de | Date: | Tue, 12 Mar 2019 13:48:39 +0000 |
| Subject: | Req #70278 [Opn]: Allow null to be passed by reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-219925@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70278&edit=1
ID: 70278
User updated by: cyslider at posteo dot de
Reported by: cyslider at posteo dot de
Summary: Allow null to be passed by reference
Status: Open
Type: Feature/Change Request
Package: *General Issues
PHP Version: Next Major Version
Block user comment: N
Private report: N
New Comment:
All I am saying is that having to pass null by reference to a function that explicitly states to
accept null as a value, even as its default, is odd.
Previous Comments:
------------------------------------------------------------------------
[2019-03-12 09:37:01] spam2 at rhsoft dot net
yes it is because the default value means "don't store it anywhere" and honestly what
sort of argumentation is "i always need to remember it"?
for your IDE:make a bugreport there that they should stop warn about correct usage and start warning
about your repeated mistake you never remember
------------------------------------------------------------------------
[2019-03-12 09:04:44] cyslider at posteo dot de
> there is no reason for the first line to begin with at all
Tell this my IDE that warns me of an undefined variable which is, at least in eclipse, not
suppressible.
But far more annoying is that I have to remember this as I always initially pass null and get that
error, then have to go back and correct it.
The extra line is less of an issue to me.
Is it really that hard, to allow null at the point where this error is generated, at least if the
default value allows null? Is there a reason not to always allow null, even?
>> Beside that, often this functions are declared in includes so
>> I have no control over how the function is defined.
>This is certainly true, but that doesn't automatically mean that the language
>should be changed, rather than just the third-party code you are calling into.
>File a bug with them if you think their function signatures could be more
>useful - you'll probably get a faster turnaround than waiting for a new stable
>version of PHP anyway!
exec is part of PHP core. So consider this advice of rowan collins followed :-)
------------------------------------------------------------------------
[2019-03-11 18:19:15] spam2 at rhsoft dot net
> $null = null
> exec($script, $null, $result)
there is no reason for the first line to begin with at all
[harry@srv-rhsoft:/downloads]$ php test.php
[harry@srv-rhsoft:/downloads]$ cat test.php
<?php declare(strict_types=1);
exec('hostname', $null, $result);
?>
------------------------------------------------------------------------
[2019-03-11 18:14:07] cyslider at posteo dot de
> I think this case - a parameter which is by-reference, defaultable, and not at the end of the
> list - would be relatively rare, though.
Well I just again came across this using exec
$null = null
exec($script, $null, $result)
So I would still be glad to be allowed to simply pass null in such cases.
------------------------------------------------------------------------
[2015-08-19 00:40:25] requinix@php.net
Related To: Bug #70296
------------------------------------------------------------------------
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=70278
--
Edit this bug report at https://bugs.php.net/bug.php?id=70278&edit=1