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
Allow testing expected CallMap return types #8166
Conversation
I added this because I didn't realized until after fixing the array_* function signatures that return types were ignored. I wanted a way to check those and also allow for other functions with parameter-only fixes. |
f4df504
to
06d6d89
Compare
e7cddec
to
8075cc4
Compare
The tests are failing because the ignore list was generated with only some extensions enabled. Need to add the failing functions to the ignore list. |
24f2779
to
84dae7f
Compare
Looks like the |
|
||
if ($functionIgnored) { | ||
try { | ||
/** @var array<string, string> $callMapEntry */ |
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.
can you document this with an @param maybe?
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.
Added one for the CallMap entry. I don't think there's a way to define the shape so it's just array<int|string, string>
I am traveling until Friday so you can make changes or wait until I'm back for further issues.
f912271
to
c93deff
Compare
cefdefd
to
b4aced9
Compare
@orklah Fixed the psalm errors and updated some parameter annotations. If I have time, I will come back for another round of clean up and try to get the class methods working as well. For now, this only adds return type testing for functions. We need an equality check for the types instead of using |
psalm.xml.dist
Outdated
@@ -166,5 +166,12 @@ | |||
<directory name="vendor/nikic/php-parser" /> | |||
</errorLevel> | |||
</MixedAssignment> | |||
|
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.
Could you suppress them with an @psalm-suppress instead please? Putting them here would mean any future usage of those outside of tests would not get flagged by Psalm so I'd like to avoid this
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.
done
b4aced9
to
b1e3094
Compare
That's something I plan to do with longer term type system improvements. There's |
The main issue this causes is nullable types aren't checked. If the PHP type is An example that is
|
Oh, I didn't notice that in the diff because it was already there. You can just do |
Thanks! |
FYI, a quick test shows this doesn't work with certain subsets such as for |
This test the CallMap return type against the reflected return type similar to the way parameter types are checked.
Because we already have an ignore list where users were only fixing parameters, this adds a separate ignore list that includes functions where only the return type is ignored. If a function is in the original
$ignoredFunctions
list, it skips all checks.Cleaned up some of the debug testing code to handle unexpected types without killing the test script.
Return types that include
resource
fail when compared to the reflected type so they are ignored until that is resolved.