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

Update return type for mockPost() #226

Merged
merged 4 commits into from
Jul 20, 2023

Conversation

wvega-godaddy
Copy link
Contributor

@wvega-godaddy wvega-godaddy commented Jul 19, 2023

Summary

The return type must be a WP_Post and a mockery mock at the same time. I believe that the method needs to use an intersection type instead of an union one.

Details

Unfortunately, WP_Post cannot be used in an intersection type, because the class is declared as final (related discussions in PHPStan's repo). The current version of mockPost() was always returning Mockery\LegacyMockInterface so I think it still makes sense to update the return type.

I also updated the return type of mockWp() to return an intersection of WP and Mockery mock interfaces. Since WP is not final, we can use the intersection type directly.

Contributor checklist

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly
  • I have added tests to cover changes introduced by this pull request
  • All new and existing tests pass

Reviewer checklist

  • Code changes review
  • Documentation changes review
  • Unit tests pass
  • Static analysis passes

@coveralls
Copy link

coveralls commented Jul 19, 2023

Coverage Status

coverage: 65.646%. remained the same when pulling 5691885 on chore/update-returned-type-for-mock-post into db23b60 on trunk.

@unfulvio-godaddy unfulvio-godaddy added this to the v1.0.0 milestone Jul 20, 2023
@unfulvio-godaddy unfulvio-godaddy merged commit 0ca2039 into trunk Jul 20, 2023
6 checks passed
@unfulvio-godaddy unfulvio-godaddy deleted the chore/update-returned-type-for-mock-post branch July 20, 2023 05:19
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.

4 participants