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

PHP: Add Enum methods for converting to/from strings #5342

Merged
merged 11 commits into from
Nov 29, 2018

Conversation

michaelbausor
Copy link
Contributor

This PR migrates the changes in #4534 and rebases them onto master branch. cc @TeBoring @fiboknacky

@TeBoring
Copy link
Contributor

It seems some tests are broken. Could you help take a look?

@michaelbausor
Copy link
Contributor Author

@TeBoring updated to not use EnumTrait, PTAL

@TeBoring
Copy link
Contributor

It seems the test is still broken. Basically, GPBUtil should also be avoided in generated code.

@TeBoring
Copy link
Contributor

Doesn't simply expand the GPBUtil method in the generated code work?

@michaelbausor
Copy link
Contributor Author

Yes, it does. I thought that using GPBUtil would work, but it seems not (I'll look into why my local testing caught the earlier error with EnumTrait, but not this one GPBUtil).

@michaelbausor
Copy link
Contributor Author

Updated, PTAL

@TeBoring
Copy link
Contributor

Still some broken tests. Please take a look.

return [
['\Google\Protobuf\Field\Cardinality'],
['\Google\Protobuf\Field\Kind'],
['\Google\Protobuf\Internal\FieldDescriptorProto\Label'],
Copy link
Contributor

Choose a reason for hiding this comment

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

These messages under Google\Protobuf\Internal are internal only and don't have implementation in c extension.
We don't need to test them.

@@ -4,6 +4,8 @@

namespace Google\Protobuf;

use UnexpectedValueException;
Copy link
Contributor

Choose a reason for hiding this comment

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

I got warning: The use statement with non-compound name 'UnexpectedValueException' has no effect
Remove that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found that I got this warning only for the no-namespace enum. Is that what you found? I have added a commit to remove the use statement from the no-namespace case.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes. For NoNamespace enum

@TeBoring
Copy link
Contributor

Implemented c extension in the last commit.

@TeBoring
Copy link
Contributor

@michaelbausor Do you want to take another look?

Copy link
Contributor Author

@michaelbausor michaelbausor left a comment

Choose a reason for hiding this comment

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

LGTM

@TeBoring TeBoring merged commit 0b9af83 into protocolbuffers:master Nov 29, 2018
@bshaffer
Copy link
Contributor

bshaffer commented Dec 1, 2018

Hooray! nice work guys!

@beccasaurus
Copy link

@michaelbausor et al – any update on when this will make it into the PHP protobuf library?

Tried using this today and there is no method ::name on my enum class, presuming I'm calling it correctly.

@TeBoring
Copy link
Contributor

TeBoring commented Feb 18, 2019 via email

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

Successfully merging this pull request may close these issues.

6 participants