-
Notifications
You must be signed in to change notification settings - Fork 653
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
SprintfReturnTypeProvider not working well with array unpacking #9873
Comments
Hey @fancyweb, can you reproduce the issue on https://psalm.dev ? |
Some real code that shows the bug: https://github.com/symfony/symfony/pull/50565/files |
I found these snippets: https://psalm.dev/r/260236cf5b<?php
$a = ['foo', 'bar', 'ccc'];
sprintf('%s %s %s', ...$a);
|
This is partially (= the fatal error) fixed in #9877, however in this case you should probably use vsprintf instead of sprintf anyway. |
@orklah @kkmuffme PR not full resolved this issue, look this case: https://psalm.dev/r/308b6b4ae5 |
I found these snippets: https://psalm.dev/r/308b6b4ae5<?php
$a = ['Some %s error', 1];
echo sprintf(...$a);
|
Fixed in #9975 |
…ancyweb) This PR was merged into the 5.4 branch. Discussion ---------- [Routing] Use vsprintf instead of sprintf + unpacking | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - A very small PR "reverting" #50565 and applying vimeo/psalm#9873 (comment) suggestion of using vsprintf instead. Targeting 5.4 since it "reverts" the last one but we could also decide to target 6.4. Commits ------- 2f6a355 [Routing] Use vsprintf instead of sprintf + unpacking
Hello, SprintfReturnTypeProvider crashes when sprintf is used with array unpacking because it considers there's one arg only, eg:
The text was updated successfully, but these errors were encountered: