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

feat: Support inheritance for body #361

Merged
merged 1 commit into from Nov 20, 2023

Conversation

tienvx
Copy link
Contributor

@tienvx tienvx commented Nov 17, 2023

This feature is useful for implementing compatibility suite.

Copy link

@JP-Ellis JP-Ellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect it is my lack of understanding of PHP, but at least to me, the use of a match (true) is confusing.

Would it not be clearer to have:

if ($body instanceof Bytes) { ... }
else if ($body instance of Text) { ... }
// ...
else {
  throw new InteractionBodyNotAddedException();
}

Then again, if the match (true) pattern is common for PHP, then I'm happy to approve it.

@tienvx
Copy link
Contributor Author

tienvx commented Nov 17, 2023

There are 3 ways of doing this:

  • if/elseif/else
  • switch (true)
  • match (true)

The reason is very simple: I personally prefer match (true) because it's new feature from PHP 8, and it's shorter than switch (true). I personally don't like using if/elseif/else in this case.

@JP-Ellis
Copy link

Thanks for explaining this! Indeed it was my misunderstanding of PHP.

@tienvx tienvx merged commit 43d05fa into pact-foundation:ffi Nov 20, 2023
26 checks passed
@tienvx tienvx deleted the match-instanceof branch November 20, 2023 14:11
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.

None yet

2 participants