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

SprintfReturnTypeProvider crashes with unknown sprintf format #9874

Closed
fancyweb opened this issue Jun 5, 2023 · 3 comments · Fixed by #9877
Closed

SprintfReturnTypeProvider crashes with unknown sprintf format #9874

fancyweb opened this issue Jun 5, 2023 · 3 comments · Fixed by #9877

Comments

@fancyweb
Copy link

fancyweb commented Jun 5, 2023

Hello, SprintfReturnTypeProvider crashes when sprintf is used with an invalid format, eg:

$a = 'a';
sprintf('foo "%" bar', $a);

https://psalm.dev/r/eef72f64c3

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/eef72f64c3
<?php

$a = 'a';
sprintf('foo "%" bar', $a);
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ReturnTypeProvider/SprintfReturnTypeProvider.php: Unknown format specifier """

@orklah
Copy link
Collaborator

orklah commented Jun 5, 2023

@kkmuffme can you take a look?

@kkmuffme
Copy link
Contributor

kkmuffme commented Jun 6, 2023

Yeah, I know, it's just an artefact of #9817. The current PR was just the basic starting point, will PR a fix for this and the referenced issue today.

kkmuffme added a commit to kkmuffme/psalm that referenced this issue Jun 6, 2023
* check args for (s)printf for Invalid/TooMany/TooFew
* don't change the return type when we cannot infer it more specifically (nullable return)
* fix vimeo#9874
* implement vimeo#9817
* add tests
kkmuffme added a commit to kkmuffme/psalm that referenced this issue Jun 7, 2023
* check args for (s)printf for Invalid/TooMany/TooFew
* don't change the return type when we cannot infer it more specifically (nullable return)
* fix vimeo#9874
* implement vimeo#9817
* add tests
kkmuffme added a commit to kkmuffme/psalm that referenced this issue Jun 9, 2023
* check args for (s)printf for Invalid/TooMany/TooFew
* don't change the return type when we cannot infer it more specifically (nullable return)
* fix vimeo#9874
* implement vimeo#9817
* add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants