Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Phpstan fixes #204
Phpstan fixes #204
Changes from all commits
0b444ec
2917a0e
61af3d7
c1909b5
7b39397
bd75130
4f9d5f5
aa68208
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why is this needed if the method has
@return
on it?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.
Even with the |AccessToken, the AbstractProvider::getAccessToken that OAuth2Client::getAccessToken calls still only returns an AccessTokenInterface. However, OAuth2Client::fetchUserFromToken as well as the AbstractProvider::getResourceOwner that it calls, take the hard classes.
In 7.4 the types can be wider/narrower where it makes sense, but in the meantime, we have to suggest to PHPStan that it's it's also the hard class that fetchUserFromToken expects.
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.
Yea, that's a mess. I guess checking if it's not an instance of
AccessToken
and throwing an exception is more honest?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.
It could only be one of those two, depending on the version and so if the interface was available (and described only in the docblock return types). The tree of code it runs from that point should only be methods described by the Interface, which is perfectly handled by the AccessToken class anyway.
So, the comment does for PHPStan, what PHP 7.4 would be able to do for itself - widening the acceptable type.