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

Inaccurate error with different types in PHPDoc and typehint #6187

Merged
merged 2 commits into from
Jul 26, 2021

Conversation

orklah
Copy link
Collaborator

@orklah orklah commented Jul 26, 2021

This fixes #6128

After running the snippet in the original issue, we now get this result:

ERROR: MismatchingDocblockReturnType - sandbox.php:4:12 - Docblock has incorrect return type 'string', should be 'int|null' (see https://psalm.dev/142)

ERROR: InvalidReturnType - sandbox.php:4:12 - The declared return type 'string' for getInt is incorrect, got 'int|null' (see https://psalm.dev/011)

The MismatchingDocblockReturnType is indeed fixed. Note that a new error is emitted that basically sees the error from another point of view. Not sure if that's expected. EDIT: I believe it's expected. I tried and when there are three different types (signature + docblock + code), the two errors are consistent so it's not just a duplicate

I also fixed a bug I made in ReturnTypeCollector a few months ago that was messing with the second error

I didn't add test because it's changing wording and I don't think we already have tests that do so.

@weirdan weirdan merged commit ae0c8f5 into vimeo:master Jul 26, 2021
@weirdan
Copy link
Collaborator

weirdan commented Jul 26, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inaccurate error with different types in PHPDoc and typehint
2 participants