Req #70278 [Com]: Allow null to be passed by reference

From: Date: Tue, 12 Mar 2019 15:59:49 +0000
Subject: Req #70278 [Com]: Allow null to be passed by reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219929@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 Comment by: spam2 at rhsoft dot net 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: it is a BY-REFERENCE param so what do you think means a default of NULL? omit errors, do nothing at all and no it would not be better allow function(null) as call because you technically can't pass anything else then variables as reference just don't specify that optional param at all if you don't make use of it, don't call the variable $null because it is wrong and to satisfy your buggy IDE write $output = '' instead null and you are done - hell, it's a REFERENCE and so it don't matter what value it has to satisfy your IDE because after the call it has the output of the called function Previous Comments: ------------------------------------------------------------------------ [2019-03-12 15:37:49] cyslider at posteo dot de That is what my IDE shows me. Also a bug? function exec ($command, array &$output = null, &$return_var = null) {} I understand 'array &$output = null' as having null by default. Sorry if this is not meant that way internally. I am not aware of that. I thought this notation always refers to setting a default value in case the value is omitted. ------------------------------------------------------------------------ [2019-03-12 14:49:03] cmb@php.net The default value of the $output parameter of exec() is not NULL; actually, this parameter has no default value. Either the argument is omitted, or not. Anyhow, this feature request is obviously controversial, so it should be discussed on <internals@lists.php.net>, and might need the RFC process[1]. [1] <https://wiki.php.net/rfc/howto> ------------------------------------------------------------------------ [2019-03-12 13:48:39] cyslider at posteo dot de 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. ------------------------------------------------------------------------ [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 :-) ------------------------------------------------------------------------ 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

« previous php.bugs (#219929) next »