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: enable edition for php #16712

Closed
wants to merge 6 commits into from

Conversation

bshaffer
Copy link
Contributor

@bshaffer bshaffer commented May 2, 2024

Expose editions for PHP

  • Skips TextFormatOutput tests, as text payload is not supported for PHP
  • Skips TestAllTypesEdition2023 tests, as editions-specific features are not yet supported for PHP
  • Skips TestAllTypesProto2 tests for Editions, as proto2 is not supported in PHP

Additionally, refactors conformance_php.php by using switch statements for readability, and adding consistent whitespace formatting.

@bshaffer bshaffer requested review from a team as code owners May 2, 2024 01:11
@bshaffer bshaffer requested review from haberman and removed request for a team May 2, 2024 01:11
@bshaffer bshaffer added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 2, 2024
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 2, 2024
BUILD.bazel Outdated Show resolved Hide resolved
@@ -37,7 +37,13 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
std::string* error) const override;

uint64_t GetSupportedFeatures() const override {
return FEATURE_PROTO3_OPTIONAL;
return Feature::FEATURE_PROTO3_OPTIONAL | Feature::FEATURE_SUPPORTS_EDITIONS;
Copy link
Member

Choose a reason for hiding this comment

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

We probably should hold off on advertising support until it's ready. Any protos under google/protobuf are allowlisted, and we could tweak php_proto_library to pass --experimental editions if that doesn't work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I'm doing something wrong, but when I remove FEATURE_SUPPORT_EDITIONS, I get the following error:

test_messages_proto3_editions.proto: is an editions file, but code generator --php_out hasn't been updated to support editions yet.  Please ask the owner of this code generator to add support or switch back to proto2/proto3.

Copy link
Member

@mkruskal-google mkruskal-google May 2, 2024

Choose a reason for hiding this comment

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

protoc will skip this check for any proto path under "google/protobuf/" and "upb/". We should probably add "editions/" to that list too

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, you could modify internal_php_proto_library to accept an experimental_editions argument and have it set --experimental_editions on protoc

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 looked into both of these and, to do the first, editions/ does not bypass the check because the filename being passed in is test_messages_proto3_editions.proto (the editions/ path is not part of the filename, I am not sure why). As for the second, I cannot find a way to set custom flags on the protoc binary, so it seems like I'd have to modify _proto_gen, which I am not super excited about doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay! Using the same flags added by Objective C in 6c7c5a5, I removed the editions flag from PHP and added the experimental_editions flag for protoc (3b212ea)

@bshaffer bshaffer requested a review from mkruskal-google May 2, 2024 17:12
@bshaffer bshaffer added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 2, 2024
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 2, 2024
@bshaffer bshaffer added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 2, 2024
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 2, 2024
@bshaffer bshaffer added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 6, 2024
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 6, 2024
@bshaffer bshaffer added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 6, 2024
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 6, 2024
copybara-service bot pushed a commit that referenced this pull request May 6, 2024
Expose editions for PHP

 - Skips `TextFormatOutput` tests, as text payload is not supported for PHP
 - Skips `TestAllTypesEdition2023` tests, as editions-specific features are not yet supported for PHP
 - Skips `TestAllTypesProto2` tests for Editions, as proto2 is not supported in PHP

Additionally, refactors `conformance_php.php` by using `switch` statements for readability, and adding consistent whitespace formatting.

Closes #16712

COPYBARA_INTEGRATE_REVIEW=#16712 from bshaffer:php-editions a1c41ad
FUTURE_COPYBARA_INTEGRATE_REVIEW=#16712 from bshaffer:php-editions a1c41ad
PiperOrigin-RevId: 631193005
copybara-service bot pushed a commit that referenced this pull request May 7, 2024
Expose editions for PHP

 - Skips `TextFormatOutput` tests, as text payload is not supported for PHP
 - Skips `TestAllTypesEdition2023` tests, as editions-specific features are not yet supported for PHP
 - Skips `TestAllTypesProto2` tests for Editions, as proto2 is not supported in PHP

Additionally, refactors `conformance_php.php` by using `switch` statements for readability, and adding consistent whitespace formatting.

Closes #16712

COPYBARA_INTEGRATE_REVIEW=#16712 from bshaffer:php-editions a1c41ad
FUTURE_COPYBARA_INTEGRATE_REVIEW=#16712 from bshaffer:php-editions a1c41ad
PiperOrigin-RevId: 631193005
copybara-service bot pushed a commit that referenced this pull request May 8, 2024
COPYBARA_INTEGRATE_REVIEW=#16712 from bshaffer:php-editions a1c41ad
PiperOrigin-RevId: 631824623
@haberman
Copy link
Member

It looks like these changes were submitted in 01744cc#diff-5ebd764f133e72efb1415d478675b92c7b091b3bf007045c2256aa8742267c75, so I'm closing this PR now.

@haberman haberman closed this May 10, 2024
deannagarcia pushed a commit to deannagarcia/protobuf that referenced this pull request Jun 20, 2024
COPYBARA_INTEGRATE_REVIEW=protocolbuffers#16712 from bshaffer:php-editions a1c41ad
PiperOrigin-RevId: 631824623
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.

3 participants