Skip to content
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

Printf with precision format is not recognized #9677

Closed
fmarchalemisys opened this issue Jul 24, 2023 · 2 comments
Closed

Printf with precision format is not recognized #9677

fmarchalemisys opened this issue Jul 24, 2023 · 2 comments

Comments

@fmarchalemisys
Copy link

Bug report

This issue follows #9674.

As per the php doc regarding the precision in printf-like functions:

Note: If the period is specified without an explicit value for precision, 0 is assumed. If * is used, the precision is supplied as an additional integer value preceding the one formatted by the specifier.

If a * is used as the precision of a float number, phpstan complains about Call to printf contains 0 placeholders, 3 values given..

printf("%*.*f", 6, 2, 1);

PR #2543 fixed the variable width but issue #9674 failed to mention the variable precision.

Code snippet that reproduces the problem

https://phpstan.org/r/067797e9-18f6-4e48-874d-11f496dd6a1f

Expected output

Phpstan should detect the variable precision and accept one argument in addition to the width and the value to format.

Note that the width may be an actual digit:

printf("%6.*f", 2, 1);

Did PHPStan help you today? Did it make you happy in any way?

No response

@staabm
Copy link
Contributor

staabm commented Jul 25, 2023

Fixed by phpstan/phpstan-src#2544

@github-actions
Copy link

github-actions bot commented Sep 6, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants