@@ -103,17 +103,6 @@ std::string DescriptorFullName(const DescriptorType* desc, bool is_internal) {
103103 return std::string (full_name);
104104}
105105
106- template <typename DescriptorType>
107- std::string LegacyGeneratedClassName (const DescriptorType* desc) {
108- std::string classname = desc->name ();
109- const Descriptor* containing = desc->containing_type ();
110- while (containing != NULL ) {
111- classname = containing->name () + ' _' + classname;
112- containing = containing->containing_type ();
113- }
114- return ClassNamePrefix (classname, desc) + classname;
115- }
116-
117106std::string ConstantNamePrefix (absl::string_view classname) {
118107 bool is_reserved = false ;
119108
@@ -170,17 +159,6 @@ std::string FullClassName(const DescriptorType* desc, bool is_descriptor) {
170159 return FullClassName (desc, options);
171160}
172161
173- template <typename DescriptorType>
174- std::string LegacyFullClassName (const DescriptorType* desc,
175- const Options& options) {
176- std::string classname = LegacyGeneratedClassName (desc);
177- std::string php_namespace = RootPhpNamespace (desc, options);
178- if (!php_namespace.empty ()) {
179- return absl::StrCat (php_namespace, " \\ " , classname);
180- }
181- return classname;
182- }
183-
184162std::string PhpNamePrefix (absl::string_view classname) {
185163 if (IsReservedName (classname)) return " PB" ;
186164 return " " ;
@@ -321,34 +299,6 @@ std::string GeneratedClassFileName(const DescriptorType* desc,
321299 return absl::StrCat (result, " .php" );
322300}
323301
324- template <typename DescriptorType>
325- std::string LegacyGeneratedClassFileName (const DescriptorType* desc,
326- const Options& options) {
327- std::string result = LegacyFullClassName (desc, options);
328-
329- for (int i = 0 ; i < result.size (); i++) {
330- if (result[i] == ' \\ ' ) {
331- result[i] = ' /' ;
332- }
333- }
334- return absl::StrCat (result, " .php" );
335- }
336-
337- template <typename DescriptorType>
338- std::string LegacyReadOnlyGeneratedClassFileName (std::string php_namespace,
339- const DescriptorType* desc) {
340- if (!php_namespace.empty ()) {
341- for (int i = 0 ; i < php_namespace.size (); i++) {
342- if (php_namespace[i] == ' \\ ' ) {
343- php_namespace[i] = ' /' ;
344- }
345- }
346- return absl::StrCat (php_namespace, " /" , desc->name (), " .php" );
347- }
348-
349- return absl::StrCat (desc->name (), " .php" );
350- }
351-
352302std::string IntToString (int32_t value) {
353303 std::ostringstream os;
354304 os << value;
@@ -1168,83 +1118,6 @@ void GenerateMetadataFile(const FileDescriptor* file, const Options& options,
11681118 printer.Print (" }\n\n " );
11691119}
11701120
1171- template <typename DescriptorType>
1172- void LegacyGenerateClassFile (const FileDescriptor* file,
1173- const DescriptorType* desc, const Options& options,
1174- GeneratorContext* generator_context) {
1175- std::string filename = LegacyGeneratedClassFileName (desc, options);
1176- std::unique_ptr<io::ZeroCopyOutputStream> output (
1177- generator_context->Open (filename));
1178- io::Printer printer (output.get (), ' ^' );
1179-
1180- GenerateHead (file, &printer);
1181-
1182- std::string php_namespace = RootPhpNamespace (desc, options);
1183- if (!php_namespace.empty ()) {
1184- printer.Print (" namespace ^name^;\n\n " , " name" , php_namespace);
1185- }
1186- std::string newname = FullClassName (desc, options);
1187- printer.Print (" if (false) {\n " );
1188- Indent (&printer);
1189- printer.Print (" /**\n " );
1190- printer.Print (" * This class is deprecated. Use ^new^ instead.\n " , " new" ,
1191- newname);
1192- printer.Print (" * @deprecated\n " );
1193- printer.Print (" */\n " );
1194- printer.Print (" class ^old^ {}\n " , " old" , LegacyGeneratedClassName (desc));
1195- Outdent (&printer);
1196- printer.Print (" }\n " );
1197- printer.Print (" class_exists(^new^::class);\n " , " new" ,
1198- GeneratedClassName (desc));
1199- printer.Print (
1200- " @trigger_error('^old^ is deprecated and will be removed in "
1201- " the next major release. Use ^fullname^ instead', "
1202- " E_USER_DEPRECATED);\n\n " ,
1203- " old" , LegacyFullClassName (desc, options), " fullname" , newname);
1204- }
1205-
1206- template <typename DescriptorType>
1207- void LegacyReadOnlyGenerateClassFile (const FileDescriptor* file,
1208- const DescriptorType* desc,
1209- const Options& options,
1210- GeneratorContext* generator_context) {
1211- std::string fullname = FullClassName (desc, options);
1212- std::string php_namespace;
1213- std::string classname;
1214- int lastindex = fullname.find_last_of (" \\ " );
1215-
1216- if (lastindex != std::string::npos) {
1217- php_namespace = fullname.substr (0 , lastindex);
1218- classname = fullname.substr (lastindex + 1 );
1219- } else {
1220- php_namespace = " " ;
1221- classname = fullname;
1222- }
1223-
1224- std::string filename =
1225- LegacyReadOnlyGeneratedClassFileName (php_namespace, desc);
1226- std::unique_ptr<io::ZeroCopyOutputStream> output (
1227- generator_context->Open (filename));
1228- io::Printer printer (output.get (), ' ^' );
1229-
1230- GenerateHead (file, &printer);
1231-
1232- if (!php_namespace.empty ()) {
1233- printer.Print (" namespace ^name^;\n\n " , " name" , php_namespace);
1234- }
1235-
1236- printer.Print (
1237- " class_exists(^new^::class); // autoload the new class, which "
1238- " will also create an alias to the deprecated class\n " ,
1239- " new" , classname);
1240- printer.Print (
1241- " @trigger_error(__NAMESPACE__ . '\\ ^old^ is deprecated and will be "
1242- " removed in "
1243- " the next major release. Use ^fullname^ instead', "
1244- " E_USER_DEPRECATED);\n\n " ,
1245- " old" , desc->name (), " fullname" , classname);
1246- }
1247-
12481121bool GenerateEnumFile (const FileDescriptor* file, const EnumDescriptor* en,
12491122 const Options& options,
12501123 GeneratorContext* generator_context, std::string* error) {
@@ -1369,28 +1242,6 @@ bool GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
13691242 Outdent (&printer);
13701243 printer.Print (" }\n\n " );
13711244
1372- // write legacy alias for backwards compatibility with nested messages and
1373- // enums
1374- if (en->containing_type () != NULL ) {
1375- printer.Print (
1376- " // Adding a class alias for backwards compatibility with the previous "
1377- " class name.\n " );
1378- printer.Print (" class_alias(^new^::class, \\ ^old^::class);\n\n " , " new" ,
1379- fullname, " old" , LegacyFullClassName (en, options));
1380- }
1381-
1382- // Write legacy file for backwards compatibility with "readonly" keywword
1383- std::string lower = en->name ();
1384- std::transform (lower.begin (), lower.end (), lower.begin (), ::tolower);
1385- if (lower == " readonly" ) {
1386- printer.Print (
1387- " // Adding a class alias for backwards compatibility with the "
1388- " \" readonly\" keyword.\n " );
1389- printer.Print (" class_alias(^new^::class, __NAMESPACE__ . '\\ ^old^');\n\n " ,
1390- " new" , fullname, " old" , en->name ());
1391- LegacyReadOnlyGenerateClassFile (file, en, options, generator_context);
1392- }
1393-
13941245 return true ;
13951246}
13961247
@@ -1494,28 +1345,6 @@ bool GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
14941345 Outdent (&printer);
14951346 printer.Print (" }\n\n " );
14961347
1497- // write legacy alias for backwards compatibility with nested messages and
1498- // enums
1499- if (message->containing_type () != NULL ) {
1500- printer.Print (
1501- " // Adding a class alias for backwards compatibility with the previous "
1502- " class name.\n " );
1503- printer.Print (" class_alias(^new^::class, \\ ^old^::class);\n\n " , " new" ,
1504- fullname, " old" , LegacyFullClassName (message, options));
1505- }
1506-
1507- // Write legacy file for backwards compatibility with "readonly" keywword
1508- std::string lower = message->name ();
1509- std::transform (lower.begin (), lower.end (), lower.begin (), ::tolower);
1510- if (lower == " readonly" ) {
1511- printer.Print (
1512- " // Adding a class alias for backwards compatibility with the "
1513- " \" readonly\" keyword.\n " );
1514- printer.Print (" class_alias(^new^::class, __NAMESPACE__ . '\\ ^old^');\n\n " ,
1515- " new" , fullname, " old" , message->name ());
1516- LegacyReadOnlyGenerateClassFile (file, message, options, generator_context);
1517- }
1518-
15191348 // Nested messages and enums.
15201349 for (int i = 0 ; i < message->nested_type_count (); i++) {
15211350 if (!GenerateMessageFile (file, message->nested_type (i), options,
0 commit comments