PHP namespaces for nested messages and enums#4536
PHP namespaces for nested messages and enums#4536TeBoring merged 26 commits intoprotocolbuffers:php-generated-devfrom
Conversation
|
ping @TeBoring |
There was a problem hiding this comment.
Shall we merge the above branch and here?
There was a problem hiding this comment.
Could you add a test in which containing message has reserved name? For example:
message Empty {
message Nested {}
}
|
Previously, we didn't take into account reserved name in namespace. Can we also fix it? |
|
In https://github.com/google/protobuf/blob/master/php/tests/compatibility_test.sh, we need a test to verify the new runtime can work with old generated code. |
7d15c80 to
3f276bb
Compare
There was a problem hiding this comment.
Can we do
if (!php_namespace.empty() ||
(!file->options().has_php_namespace() && !file->package().empty()) ||
lastindex != string::npos) {
...
}
There was a problem hiding this comment.
Actually, I think we just need to check lastindex != string::npos
|
Ping @TeBoring |
f073b35 to
a77d3a9
Compare
d07aac6 to
54c9685
Compare
54c9685 to
46311fc
Compare
|
I think in php_generattor.cc, you need to replace |
| $this->markTestSkipped('Protobuf extension fails when phpunit runs in a separate process'); | ||
| } | ||
| $this->legacyEnum(new NestedEnum); | ||
| $this->legacyEnum(new TestLegacyMessage\NestedEnum); |
There was a problem hiding this comment.
Why not simply set new TestLegacyMessage_NestedEnum?
There was a problem hiding this comment.
I think you just need new TestLegacyMessage_NestedEnum
| $this->markTestSkipped('Protobuf extension fails when phpunit runs in a separate process'); | ||
| } | ||
| $this->legacyMessage(new Sub); | ||
| $this->legacyMessage(new TestLegacyMessage\NestedMessage); |
There was a problem hiding this comment.
Use TestLegacyMessage_NestedMessage
|
Currently, it still generate |
|
here is an example of the deprecated class file and message. I would love to get @dwsupplee and @michaelbausor 's thoughts on this! |
|
What is the purpose of this line: https://gist.github.com/bshaffer/906dcfbf1e05cd44ac74f0279e185ad3#file-testmessage_sub-php-L7 |
|
@michaelbausor Yes, it ensures that if someone creates the deprecated class, the new class is loaded and the call to |
Namespace for nested message/enum in c extension
|
@michaelbausor and @dwsupplee, if you have other issues, we can fix them in another PR. |
* uses namespaces for nested messages and enums * fixes namespaces for PHP dist * fixes namespace for Descriptors, adds Cardinality and Kind * fixes nested namespaces for reserved words and adds tests * adds tests and generator fix for php class prefixes * fixes escaping of protobuf packages, enum comments, misc others * nice refactor of generated code * adds class files for backwards compatibility * simplifies code with templates * adds compatibility files to makefile * cleanup of generator and fixes nested namespace bug * regenerates proto types * remove internal BC classes * adds deprecated warning, adds methods back * simplifies if statement * fixes dist files * addresses review comments * adds back TYPE_URL_PREFIX constant * adds @deprecated to old nested class files * skips tests which require a separate process when protobuf.so is enabled * Adds tests for legacy nested classes that do not require separate processes to test * uses legacy names for GPBUtil message check * adds block for IDE @deprecated message * Namespace for nested message/enum in c extension * Remove unused code
* uses namespaces for nested messages and enums * fixes namespaces for PHP dist * fixes namespace for Descriptors, adds Cardinality and Kind * fixes nested namespaces for reserved words and adds tests * adds tests and generator fix for php class prefixes * fixes escaping of protobuf packages, enum comments, misc others * nice refactor of generated code * adds class files for backwards compatibility * simplifies code with templates * adds compatibility files to makefile * cleanup of generator and fixes nested namespace bug * regenerates proto types * remove internal BC classes * adds deprecated warning, adds methods back * simplifies if statement * fixes dist files * addresses review comments * adds back TYPE_URL_PREFIX constant * adds @deprecated to old nested class files * skips tests which require a separate process when protobuf.so is enabled * Adds tests for legacy nested classes that do not require separate processes to test * uses legacy names for GPBUtil message check * adds block for IDE @deprecated message * Namespace for nested message/enum in c extension * Remove unused code
The proto
Will result in the files
With namespaces corresponding to the classes, e.g.