-
-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support calls to functions with variadic parameters #814
base: master
Are you sure you want to change the base?
Conversation
@AJenbo thanks for your PR, do you have the possibility to add a test that failed before this PR and is fixed with this PR? I assign this PR to you, but feel free to say if you need help creating the tests. |
Sure, will try and get around to it some time this week. |
Oh, I forgot all about this one. I'll try come up with a same that show the issue. |
No fair you guys merged another fix for this just a month later, and the didn't even trace down what the cause was 😂 |
Codecov Report
@@ Coverage Diff @@
## master #814 +/- ##
=========================================
Coverage 88.65% 88.65%
- Complexity 1055 1056 +1
=========================================
Files 95 95
Lines 2661 2663 +2
=========================================
+ Hits 2359 2361 +2
Misses 302 302
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Ok, I added a test, removed the "be quiet" fix, and made this one more explicit as to what it is doing. Hope that makes it good enough to merge :) |
Hi, thanks to this I discovered that a parameter can be both variadic and reference 🤯 The test is good as it's what also missed in #818 but I did not succeed to find a case that would explain why we need specific stuff for PHP < 5.6 or why I tried: #973 (min) #974 (isset) By the way I added there a test for variadic+reference but current fixes still don't support it, so we need an other fix for that. class Test
{
public function foo(string $format, mixed &...$values): string
{
$values[1] = 9;
return sprintf($format, ...$values);
}
public function bar()
{
$variadic1 = 1;
$this->print("Text %d", $variadic1, $variadic2);
return $variadic2;
}
}
$t = new Test();
echo $t->bar(); |
Without
I think it also better allow you to realize why the count might be higher, rather then just ignoring a case that appears like it should never happen. |
That's also what I believed reading the code but as you can see here it's still producing a violation: #973 (in both PHP <= 5.6 and > 5.6) |
@AJenbo can this be updated to be mergable into 3.0.0? |
Sure, though there isn't anything BC in it. |
Type: bugfix
Breaking change: no
Previously this would often fail on usage of sprintf() and other function that takes variadic parameters.