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

sprintf 'h' and 'H' placeholders not recognised (new in PHP 8) #4717

Closed
sjbartley opened this issue Mar 18, 2021 · 6 comments
Closed

sprintf 'h' and 'H' placeholders not recognised (new in PHP 8) #4717

sjbartley opened this issue Mar 18, 2021 · 6 comments
Labels
Milestone

Comments

@sjbartley
Copy link

sjbartley commented Mar 18, 2021

Bug report

The new (PHP 8) sprintf() placeholders %h and %H are not recognised.

Code snippet that reproduces the problem

$f = 4.0/3;
$s = 'Bug';
echo sprintf('%s qty = %h', $s, $f);

See https://phpstan.org/r/6bb27f99-6ae5-4e08-831a-f91b995b20cf#

Expected output

The above snippet outputs 'Bug qty = 1.33333'.

PhpStan should not raise any errors to do with the sprintf() expression, but currently reports 'Call to sprintf contains 1 placeholder, 2 values given.'

@mergeable
Copy link

mergeable bot commented Mar 18, 2021

This bug report is missing a link to reproduction on phpstan.org.

It will most likely be closed after manual review.

@sjbartley
Copy link
Author

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Mar 18, 2021
@phpstan-bot
Copy link
Contributor

@sjbartley After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
+PHP 8.0
+==========
+
+No errors
+
+PHP 7.1 – 7.4 (1 error)
+==========
+
 5: Call to sprintf contains 1 placeholder, 2 values given.
Full report

PHP 8.0

No errors

PHP 7.1 – 7.4 (1 error)

Line Error
5 Call to sprintf contains 1 placeholder, 2 values given.

@phpstan-bot
Copy link
Contributor

@sjbartley After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
+PHP 8.0
+==========
+
+No errors
+
+PHP 7.1 – 7.4 (1 error)
+==========
+
 5: Call to sprintf contains 1 placeholder, 2 values given.
Full report

PHP 8.0

No errors

PHP 7.1 – 7.4 (1 error)

Line Error
5 Call to sprintf contains 1 placeholder, 2 values given.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@0cbbfba

@github-actions
Copy link

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 Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants