From d807712f1a27767e05b89e256cbebecb684af70a Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Fri, 15 Jul 2022 12:09:24 -0700 Subject: [PATCH] address review comments --- php/src/Google/Protobuf/Internal/Descriptor.php | 6 +++--- php/src/Google/Protobuf/Internal/DescriptorPool.php | 2 +- php/src/Google/Protobuf/Internal/GPBUtil.php | 4 ++-- src/google/protobuf/compiler/php/php_generator.cc | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/php/src/Google/Protobuf/Internal/Descriptor.php b/php/src/Google/Protobuf/Internal/Descriptor.php index b7d59cbf9b..51a34d6bc9 100644 --- a/php/src/Google/Protobuf/Internal/Descriptor.php +++ b/php/src/Google/Protobuf/Internal/Descriptor.php @@ -163,12 +163,12 @@ class Descriptor return $this->legacy_klass; } - public function setPreviouslyReservedClass($klass) + public function setPreviouslyUnreservedClass($klass) { $this->previous_klass = $klass; } - public function getPreviouslyReservedClass() + public function getPreviouslyUnreservedClass() { return $this->previous_klass; } @@ -204,7 +204,7 @@ class Descriptor $desc->setFullName($fullname); $desc->setClass($classname); $desc->setLegacyClass($legacy_classname); - $desc->setPreviouslyReservedClass($previous_classname); + $desc->setPreviouslyUnreservedClass($previous_classname); $desc->setOptions($proto->getOptions()); foreach ($proto->getField() as $field_proto) { diff --git a/php/src/Google/Protobuf/Internal/DescriptorPool.php b/php/src/Google/Protobuf/Internal/DescriptorPool.php index 9709a1c80e..1be00e2ffd 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorPool.php +++ b/php/src/Google/Protobuf/Internal/DescriptorPool.php @@ -96,7 +96,7 @@ class DescriptorPool $descriptor->getClass(); $this->class_to_desc[$descriptor->getClass()] = $descriptor; $this->class_to_desc[$descriptor->getLegacyClass()] = $descriptor; - $this->class_to_desc[$descriptor->getPreviouslyReservedClass()] = $descriptor; + $this->class_to_desc[$descriptor->getPreviouslyUnreservedClass()] = $descriptor; foreach ($descriptor->getNestedType() as $nested_type) { $this->addDescriptor($nested_type); } diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php index 0e5cd2a7e6..ffea900837 100644 --- a/php/src/Google/Protobuf/Internal/GPBUtil.php +++ b/php/src/Google/Protobuf/Internal/GPBUtil.php @@ -304,7 +304,7 @@ class GPBUtil return ""; } - public static function getPreviouslyUnreservedClassNamePrefix( + private static function getPreviouslyUnreservedClassNamePrefix( $classname, $file_proto) { @@ -344,7 +344,7 @@ class GPBUtil return implode('\\', $parts); } - public static function getPreviouslyUnreservedClassNameWithoutPackage( + private static function getPreviouslyUnreservedClassNameWithoutPackage( $name, $file_proto) { diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 6884e75035..adfd54e5ac 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -1330,7 +1330,8 @@ void LegacyReadOnlyGenerateClassFile(const FileDescriptor* file, "name", php_namespace); } std::string newname = FullClassName(desc, options); - printer.Print("class_exists(^new^::class);\n", + printer.Print("class_exists(^new^::class); // autoload the new class, which " + "will also create an alias to the deprecated class\n", "new", GeneratedClassNameImpl(desc)); printer.Print("@trigger_error(__NAMESPACE__ . '\\^old^ is deprecated and will be removed in " "the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n",