-
Notifications
You must be signed in to change notification settings - Fork 506
Improve sprintf
return type inference
#3168
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
Conversation
8dd5fb7
to
a0824ef
Compare
// XXX should be string because of invalid arguments count | ||
assertType('non-falsy-string&numeric-string', sprintf('%10$14F', $mixed, $s)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after #3126 is merged we have the necessary PrintfHelper
to decide about the invalid number of arguments/placeholders
the composer error is valid, as we previously inferred a non-empty-string return type, even though the sprintf pattern is not known at static analysis time. other errors are the same ones are unrelated |
This pull request has been marked as ready for review. |
cfc5771
to
fc9baf6
Compare
the reported phpstan error is interesstig.. it seems - depending on some unknown factor - reports that we are catching a non-throwable but ignoring this very same error by identifer leads to a "No error with identifier catch.notThrowable is reported on line 200." see the 2 variants at (its unrelated to this PR though) |
I think its related to this |
There's an opportunity to grab the code from Hoa packages and make a small single modern library with no magic and simple PSR-4 autoloading and replace Hoa in phpstan-src. I might look into it this summer. |
15bbfa6
to
fc9baf6
Compare
ok, what can we do to fix the build until then? |
Try to rebase on top of: 3233155 |
looks great, thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry. I see the diff of src/Type/Php/SprintfFunctionDynamicReturnTypeExtension.php
and my brain just freezes. I'm not able to review this. Can you do this in smaller steps, or maybe not move that many things around?
"Make the change easy, then make the easy change."
closes phpstan/phpstan#11201
closes phpstan/phpstan#10493