address review comments

pull/10041/head
Brent Shaffer 2 years ago
parent 4f28c5ab4e
commit d807712f1a
  1. 6
      php/src/Google/Protobuf/Internal/Descriptor.php
  2. 2
      php/src/Google/Protobuf/Internal/DescriptorPool.php
  3. 4
      php/src/Google/Protobuf/Internal/GPBUtil.php
  4. 3
      src/google/protobuf/compiler/php/php_generator.cc

@ -163,12 +163,12 @@ class Descriptor
return $this->legacy_klass; return $this->legacy_klass;
} }
public function setPreviouslyReservedClass($klass) public function setPreviouslyUnreservedClass($klass)
{ {
$this->previous_klass = $klass; $this->previous_klass = $klass;
} }
public function getPreviouslyReservedClass() public function getPreviouslyUnreservedClass()
{ {
return $this->previous_klass; return $this->previous_klass;
} }
@ -204,7 +204,7 @@ class Descriptor
$desc->setFullName($fullname); $desc->setFullName($fullname);
$desc->setClass($classname); $desc->setClass($classname);
$desc->setLegacyClass($legacy_classname); $desc->setLegacyClass($legacy_classname);
$desc->setPreviouslyReservedClass($previous_classname); $desc->setPreviouslyUnreservedClass($previous_classname);
$desc->setOptions($proto->getOptions()); $desc->setOptions($proto->getOptions());
foreach ($proto->getField() as $field_proto) { foreach ($proto->getField() as $field_proto) {

@ -96,7 +96,7 @@ class DescriptorPool
$descriptor->getClass(); $descriptor->getClass();
$this->class_to_desc[$descriptor->getClass()] = $descriptor; $this->class_to_desc[$descriptor->getClass()] = $descriptor;
$this->class_to_desc[$descriptor->getLegacyClass()] = $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) { foreach ($descriptor->getNestedType() as $nested_type) {
$this->addDescriptor($nested_type); $this->addDescriptor($nested_type);
} }

@ -304,7 +304,7 @@ class GPBUtil
return ""; return "";
} }
public static function getPreviouslyUnreservedClassNamePrefix( private static function getPreviouslyUnreservedClassNamePrefix(
$classname, $classname,
$file_proto) $file_proto)
{ {
@ -344,7 +344,7 @@ class GPBUtil
return implode('\\', $parts); return implode('\\', $parts);
} }
public static function getPreviouslyUnreservedClassNameWithoutPackage( private static function getPreviouslyUnreservedClassNameWithoutPackage(
$name, $name,
$file_proto) $file_proto)
{ {

@ -1330,7 +1330,8 @@ void LegacyReadOnlyGenerateClassFile(const FileDescriptor* file,
"name", php_namespace); "name", php_namespace);
} }
std::string newname = FullClassName(desc, options); 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)); "new", GeneratedClassNameImpl(desc));
printer.Print("@trigger_error(__NAMESPACE__ . '\\^old^ is deprecated and will be removed in " 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", "the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n",

Loading…
Cancel
Save