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
Fix count_chars stubs #7094
Fix count_chars stubs #7094
Conversation
Not sure either, never really looked at how Psalm finds the correct signature for a specific case. I'd like some tests on this is possible FunctionCallTest::providerValidCodeParse would be a fine place for those. In particular, I'd like to try what Psalm outputs for a call when Psalm doesn't know the literal value of $mode (a simple int for example) |
@orklah Thanks for the hint. Can you help me a little bit with writing the test properly? I am not very familiar with this syntax. |
yeah, basically, you have a providerValidCodeParse and a providerInvalidCodeParse. The first one is used to check that a snippet does not output errors while the second checks that you correctly emit a specific error. For your tests, providerValidCodeParse is more on point. You have to create a new offset in the big array. In the array you have:
So, for example psalm/tests/FunctionCallTest.php Line 1738 in 8fb2e0f
This test execute the snippet in PHP 8.1, check that $a and $b have the right types and will not tolerate any error. (If you see |
67d4b2d
to
d274550
Compare
Can you add a test that shows what happens if you provide |
Isn't my second test showing this? I pass 5 which produces a warning saying that it should be 3|4 |
you pass the literal For example
|
d274550
to
f270d38
Compare
Well, the error message is kinda weird (incomplete at least) but I guess I'm fine with it. Can you fix the test and I think we're good to merge |
f270d38
to
098238f
Compare
Thanks! That's great! |
I am not sure why it doesn't work properly when they are all separated but it seems to work when they are combined with OR operator.
I don't know if there are tests I should write for this...