From 5f477fc4405e0cab48666790bf6fbedbd24b73ed Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Fri, 11 Mar 2022 09:16:35 -0600 Subject: [PATCH 1/2] remove legacy generate class file --- .../protobuf/compiler/php/php_generator.cc | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index b9110440f9..62b66ef898 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -1265,43 +1265,6 @@ void GenerateMetadataFile(const FileDescriptor* file, const Options& options, printer.Print("}\n\n"); } -template -void LegacyGenerateClassFile(const FileDescriptor* file, - const DescriptorType* desc, const Options& options, - GeneratorContext* generator_context) { - std::string filename = LegacyGeneratedClassFileName(desc, options); - std::unique_ptr output( - generator_context->Open(filename)); - io::Printer printer(output.get(), '^'); - - GenerateHead(file, &printer); - - std::string php_namespace = RootPhpNamespace(desc, options); - if (!php_namespace.empty()) { - printer.Print( - "namespace ^name^;\n\n", - "name", php_namespace); - } - std::string newname = FullClassName(desc, options); - printer.Print("if (false) {\n"); - Indent(&printer); - printer.Print("/**\n"); - printer.Print(" * This class is deprecated. Use ^new^ instead.\n", - "new", newname); - printer.Print(" * @deprecated\n"); - printer.Print(" */\n"); - printer.Print("class ^old^ {}\n", - "old", LegacyGeneratedClassName(desc)); - Outdent(&printer); - printer.Print("}\n"); - printer.Print("class_exists(^new^::class);\n", - "new", GeneratedClassNameImpl(desc)); - printer.Print("@trigger_error('^old^ is deprecated and will be removed in " - "the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n", - "old", LegacyFullClassName(desc, options), - "fullname", newname); -} - void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, const Options& options, GeneratorContext* generator_context) { @@ -1403,7 +1366,6 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, "class_alias(^new^::class, \\^old^::class);\n\n", "new", fullname, "old", LegacyFullClassName(en, options)); - LegacyGenerateClassFile(file, en, options, generator_context); } } @@ -1518,7 +1480,6 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, "class_alias(^new^::class, \\^old^::class);\n\n", "new", fullname, "old", LegacyFullClassName(message, options)); - LegacyGenerateClassFile(file, message, options, generator_context); } // Nested messages and enums. From fa11ed47192b6fd11458546c91c1d0e1bee71ad5 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 14 Mar 2022 21:16:12 -0600 Subject: [PATCH 2/2] remove unused LegacyGeneratedClassFileName --- .../protobuf/compiler/php/php_generator.cc | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 62b66ef898..3192a89106 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -407,19 +407,6 @@ std::string GeneratedClassFileName(const DescriptorType* desc, return result + ".php"; } -template -std::string LegacyGeneratedClassFileName(const DescriptorType* desc, - const Options& options) { - std::string result = LegacyFullClassName(desc, options); - - for (int i = 0; i < result.size(); i++) { - if (result[i] == '\\') { - result[i] = '/'; - } - } - return result + ".php"; -} - std::string GeneratedServiceFileName(const ServiceDescriptor* service, const Options& options) { std::string result = FullClassName(service, options) + "Interface"; @@ -1358,7 +1345,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, Outdent(&printer); printer.Print("}\n\n"); - // write legacy file for backwards compatibility with nested messages and enums + // write legacy alias for backwards compatibility with nested messages and enums if (en->containing_type() != NULL) { printer.Print( "// Adding a class alias for backwards compatibility with the previous class name.\n"); @@ -1472,7 +1459,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, Outdent(&printer); printer.Print("}\n\n"); - // write legacy file for backwards compatibility with nested messages and enums + // write legacy alias for backwards compatibility with nested messages and enums if (message->containing_type() != NULL) { printer.Print( "// Adding a class alias for backwards compatibility with the previous class name.\n");