hi,
Please take a look into the proposal.
https://wiki.php.net/rfc/too_few_args
The RFC is extremely simple (both proposal and implementation) and almost completely described by the email subject.
I think, this mini-RFC doesn't need 2-weeks discussion period, so I'm going to start the vote on next week.
Thanks. Dmitry.
hi,
Please take a look into the proposal.
My first thought went into how people use func_get_args()
as this is (in
a sense) the opposite thereof.
That said I couldn't think of a good reason to disagree, but maybe
someone has a valid example where this change would have unforeseen
consequences.
~Florian
hi,
Please take a look into the proposal.
https://wiki.php.net/rfc/too_few_args
The RFC is extremely simple (both proposal and implementation) and almost completely described by the email subject.
I think, this mini-RFC doesn't need 2-weeks discussion period, so I'm going to start the vote on next week.
I like the concept behind this, but I worry it might have a rather large
BC impact. Like removing call-time pass-by-reference, there may be a lot
of long-untouched code that needs fixing to work within this constraint.
I'm not even sure how easy it would be for static analysis to identify
these cases. I guess on the flip-side, people will probably have
Warnings displayed or logged already...
The RFC would also benefit from more discussion of the current behaviour
in different cases:
function foo($a) {}
foo(); // Warning
function bar(A $a) {}
bar(); // Error
function baz(A $a=null) {}
baz(); // OK
function quux(?A $a) {}
quux(); // Not sure. Error?
function wibble(int $a) {}
wibble(); // Error (regardless of strict_types, I think)
function wobble(?int $a) {}
wobble(); // Error?
Any other cases?
Certainly, making these consistent would be nice, but like a lot of
consistency, does it come at too high a price?
Regards,
Rowan Collins
[IMSoP]
I like the concept behind this, but I worry it might have a rather large
BC impact. Like removing call-time pass-by-reference, there may be a lot
of long-untouched code that needs fixing to work within this constraint.
I'm not even sure how easy it would be for static analysis to identify
these cases. I guess on the flip-side, people will probably have
Warnings displayed or logged already...The RFC would also benefit from more discussion of the current behaviour
in different cases:function foo($a) {}
foo(); // Warningfunction bar(A $a) {}
bar(); // Errorfunction baz(A $a=null) {}
baz(); // OKfunction quux(?A $a) {}
quux(); // Not sure. Error?function wibble(int $a) {}
wibble(); // Error (regardless of strict_types, I think)function wobble(?int $a) {}
wobble(); // Error?Any other cases?
Certainly, making these consistent would be nice, but like a lot of
consistency, does it come at too high a price?
I fully agree with Rowan here. First we need a proper plan for all these
cases and a consistent behavior. Next we need to discuss if something
like this can be introduced in a feature release or requires a major
release.
Note that func_get_args()
should die too since we have variadic
arguments now. However, this can only be introduced in a major version.
(Correct me if I am wrong and didn't thought of a very common use case
that requires func_get_args()
. I for one never need it.)
Whether references need to die completely or not is a more complicated
discussion. There are valid use cases for them. However, they should be
avoided and other solutions should be preferred if possible.
--
Richard "Fleshgrinder" Fussenegger
Hi!
Note that
func_get_args()
should die too since we have variadic
arguments now.
It should not. There is nothing wrong with this function, the fact that
some of it's functionality is covered by variadic args notwithstanding.
Stas Malyshev
smalyshev@gmail.com
Evening,
Could you expand on the "obvious optimization opportunities" in the
document ?
They are not obvious to me, and even if they were, this document is
part of the history of this change, so a little more detail would be nice.
Cheers
Joe
hi,
Please take a look into the proposal.
https://wiki.php.net/rfc/too_few_args
The RFC is extremely simple (both proposal and implementation) and almost
completely described by the email subject.I think, this mini-RFC doesn't need 2-weeks discussion period, so I'm
going to start the vote on next week.Thanks. Dmitry.
hi,
Please take a look into the proposal.
https://wiki.php.net/rfc/too_few_args
The RFC is extremely simple (both proposal and implementation) and almost completely described by the email subject.
I think, this mini-RFC doesn't need 2-weeks discussion period, so I'm going to start the vote on next week.
Thanks. Dmitry.
+1 on this change. IMO, this is one of the few remaining unusual PHP behaviors that exists for no obvious reason. A function should not be called if too few arguments are provided.
While this might be considered a BC break, I can't imagine there's an actual code out there relying on suppressing the warning just to call a function without enough arguments. I see no problem putting this change in 7.1.
Aaron Piotrowski
While this might be considered a BC break, I can't imagine there's an actual code out there relying on suppressing the warning just to call a function without enough arguments. I see no problem putting this change in 7.1.
I think you're overestimating how much people care about their code
running without warnings. You don't have to suppress anything, just
lazily ignore warnings, or log them to a file you never get round to
reading. It might be that most users spot and act on the warnings, but
I'm not sure how we could know that with any confidence.
Regards,
--
Rowan Collins
[IMSoP]
While this might be considered a BC break, I can't imagine there's an actual code out there relying on suppressing the warning just to call a function without enough arguments. I see no problem putting this change in 7.1.
I think you're overestimating how much people care about their code running without warnings. You don't have to suppress anything, just lazily ignore warnings, or log them to a file you never get round to reading. It might be that most users spot and act on the warnings, but I'm not sure how we could know that with any confidence.
Perhaps I'm overestimating how much people care about eliminating warnings, but I doubt many functions work as intended without being supplied all required arguments. The few situations where code worked as intended when too few arguments were provided to a function are fragile and should be fixed. This change will better alert users to those problems.
Aaron Piotrowski
While this might be considered a BC break, I can't imagine there's an actual code out there relying on suppressing the warning just to call a function without enough arguments. I see no problem putting this change in 7.1.
I think you're overestimating how much people care about their code running without warnings. You don't have to suppress anything, just lazily ignore warnings, or log them to a file you never get round to reading. It might be that most users spot and act on the warnings, but I'm not sure how we could know that with any confidence.
Perhaps I'm overestimating how much people care about eliminating warnings, but I doubt many functions work as intended without being supplied all required arguments. The few situations where code worked as intended when too few arguments were provided to a function are fragile and should be fixed. This change will better alert users to those problems.
Sure, but "a good thing in the long run" is not the opposite of "BC
break". If people upgrade to PHP 7.1 and get a load of errors, they will
just delay adoption of that version. That is not a risk that should be
dismissed lightly, IMHO.
Regards,
Rowan Collins
[IMSoP]
Hi!
Please take a look into the proposal.
https://wiki.php.net/rfc/too_few_args
The RFC is extremely simple (both proposal and implementation) and almost completely described by the email subject.
Looks fine to me. I don't think having undef function parameters is a
very valuable feature that is widely used.
--
Stas Malyshev
smalyshev@gmail.com
Please take a look into the proposal.
https://wiki.php.net/rfc/too_few_args
The RFC is extremely simple (both proposal and implementation) and almost completely described by the email subject.
Looks fine to me. I don't think having undef function parameters is a
very valuable feature
ACK
that is widely used.
I have seen it several times; most likely the authors did it, because
it's common in JavaScript where default parameters are still not widely
available.
I would have been +1 on this RFC if it had targeted 7.0.0, but I tend to
be ±0 for PHP 7.x.
--
Christoph M. Becker
hi,
Please take a look into the proposal.
https://wiki.php.net/rfc/too_few_args
The RFC is extremely simple (both proposal and implementation) and almost
completely described by the email subject.I think, this mini-RFC doesn't need 2-weeks discussion period, so I'm
going to start the vote on next week.
Quick question, I think the error message might be a little confusing
asking for "exactly $n" parameters, because it could be a variadic function
using func_get_args()
, shouldn't the message be?
throw Error("Too few arguments to function %s(), 0 passed in %s on line %d
and at least %d expected")
This only changes the case where the passed arguments are smaller than the
required ones or not? This is acceptable BC, but passing more arguments
should still not be an error.
Thanks. Dmitry.
Am 01.06.2016 um 12:55 schrieb Dmitry Stogov dmitry@zend.com:
hi,
Please take a look into the proposal.
https://wiki.php.net/rfc/too_few_args
The RFC is extremely simple (both proposal and implementation) and almost completely described by the email subject.
I think, this mini-RFC doesn't need 2-weeks discussion period, so I'm going to start the vote on next week.
Thanks. Dmitry.
Very nice!
Just a question: Does the RFC also impact calls to internal functions? (With internal functions we don't have the problem as they're typically immediately aborted, but it would be inconsistent with userland functions to have once a warning, once an exception)
Judging from the patch this isn't the case? (at least I see no related changes)
Thus I think the scope of the RFC is a bit too small. [and at least it should be explicitly mentioned in the RFC if you decide against that].
Bob
Am 01.06.2016 um 12:55 schrieb Dmitry Stogov dmitry@zend.com:
hi,
Please take a look into the proposal.
https://wiki.php.net/rfc/too_few_args
The RFC is extremely simple (both proposal and implementation) and almost completely described by the email subject.
I think, this mini-RFC doesn't need 2-weeks discussion period, so I'm going to start the vote on next week.
Thanks. Dmitry.
Very nice!Just a question: Does the RFC also impact calls to internal functions? (With internal functions we don't have the problem as they're typically immediately aborted, but it would be inconsistent with userland functions to have once a warning, once an exception)
Judging from the patch this isn't the case? (at least I see no related changes)
Thus I think the scope of the RFC is a bit too small. [and at least it should be explicitly mentioned in the RFC if you decide against that].
Bob
The RFC doesn't propose to change behavior of internal functions.
In case of wrong number of arguments, they are not executed anyway.
It may make sense to change their behavior as well, but I don't see a
big value.
Thanks. Dmitry.
Am 02.06.2016 um 14:11 schrieb Dmitry Stogov dmitry@zend.com:
Am 01.06.2016 um 12:55 schrieb Dmitry Stogov dmitry@zend.com:
hi,
Please take a look into the proposal.
https://wiki.php.net/rfc/too_few_args
The RFC is extremely simple (both proposal and implementation) and almost completely described by the email subject.
I think, this mini-RFC doesn't need 2-weeks discussion period, so I'm going to start the vote on next week.
Thanks. Dmitry.
Very nice!Just a question: Does the RFC also impact calls to internal functions? (With internal functions we don't have the problem as they're typically immediately aborted, but it would be inconsistent with userland functions to have once a warning, once an exception)
Judging from the patch this isn't the case? (at least I see no related changes)
Thus I think the scope of the RFC is a bit too small. [and at least it should be explicitly mentioned in the RFC if you decide against that].
Bob
The RFC doesn't propose to change behavior of internal functions.
In case of wrong number of arguments, they are not executed anyway.
It may make sense to change their behavior as well, but I don't see a big value.Thanks. Dmitry.
Right, then the RFC should explicitly mention it. It only talks about "function calls" in general right now, but doesn't restrict the scope to userland functions only.
The value is basically in having equal and consistent behavior (in failure case) for all functions.
I do not see it a must, but it would be a very-nice-to-have in my eyes.
Bob