|
@@ -215,9 +215,10 @@ class GPBUtil
|
|
"Expect repeated field of different type.");
|
|
"Expect repeated field of different type.");
|
|
}
|
|
}
|
|
if ($var->getType() === GPBType::MESSAGE &&
|
|
if ($var->getType() === GPBType::MESSAGE &&
|
|
- $var->getClass() !== $klass) {
|
|
|
|
|
|
+ $var->getClass() !== $klass &&
|
|
|
|
+ $var->getLegacyClass() !== $klass) {
|
|
throw new \Exception(
|
|
throw new \Exception(
|
|
- "Expect repeated field of different message.");
|
|
|
|
|
|
+ "Expect repeated field of " . $klass . ".");
|
|
}
|
|
}
|
|
return $var;
|
|
return $var;
|
|
}
|
|
}
|
|
@@ -242,9 +243,10 @@ class GPBUtil
|
|
throw new \Exception("Expect map field of value type.");
|
|
throw new \Exception("Expect map field of value type.");
|
|
}
|
|
}
|
|
if ($var->getValueType() === GPBType::MESSAGE &&
|
|
if ($var->getValueType() === GPBType::MESSAGE &&
|
|
- $var->getValueClass() !== $klass) {
|
|
|
|
|
|
+ $var->getValueClass() !== $klass &&
|
|
|
|
+ $var->getLegacyValueClass() !== $klass) {
|
|
throw new \Exception(
|
|
throw new \Exception(
|
|
- "Expect map field of different value message.");
|
|
|
|
|
|
+ "Expect map field of " . $klass . ".");
|
|
}
|
|
}
|
|
return $var;
|
|
return $var;
|
|
}
|
|
}
|
|
@@ -299,6 +301,14 @@ class GPBUtil
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static function getLegacyClassNameWithoutPackage(
|
|
|
|
+ $name,
|
|
|
|
+ $file_proto)
|
|
|
|
+ {
|
|
|
|
+ $classname = implode('_', explode('.', $name));
|
|
|
|
+ return static::getClassNamePrefix($classname, $file_proto) . $classname;
|
|
|
|
+ }
|
|
|
|
+
|
|
public static function getClassNameWithoutPackage(
|
|
public static function getClassNameWithoutPackage(
|
|
$name,
|
|
$name,
|
|
$file_proto)
|
|
$file_proto)
|
|
@@ -316,6 +326,7 @@ class GPBUtil
|
|
$file_proto,
|
|
$file_proto,
|
|
&$message_name_without_package,
|
|
&$message_name_without_package,
|
|
&$classname,
|
|
&$classname,
|
|
|
|
+ &$legacy_classname,
|
|
&$fullname)
|
|
&$fullname)
|
|
{
|
|
{
|
|
// Full name needs to start with '.'.
|
|
// Full name needs to start with '.'.
|
|
@@ -334,21 +345,28 @@ class GPBUtil
|
|
|
|
|
|
$class_name_without_package =
|
|
$class_name_without_package =
|
|
static::getClassNameWithoutPackage($message_name_without_package, $file_proto);
|
|
static::getClassNameWithoutPackage($message_name_without_package, $file_proto);
|
|
|
|
+ $legacy_class_name_without_package =
|
|
|
|
+ static::getLegacyClassNameWithoutPackage(
|
|
|
|
+ $message_name_without_package, $file_proto);
|
|
|
|
|
|
$option = $file_proto->getOptions();
|
|
$option = $file_proto->getOptions();
|
|
if (!is_null($option) && $option->hasPhpNamespace()) {
|
|
if (!is_null($option) && $option->hasPhpNamespace()) {
|
|
$namespace = $option->getPhpNamespace();
|
|
$namespace = $option->getPhpNamespace();
|
|
if ($namespace !== "") {
|
|
if ($namespace !== "") {
|
|
$classname = $namespace . "\\" . $class_name_without_package;
|
|
$classname = $namespace . "\\" . $class_name_without_package;
|
|
|
|
+ $legacy_classname =
|
|
|
|
+ $namespace . "\\" . $legacy_class_name_without_package;
|
|
return;
|
|
return;
|
|
} else {
|
|
} else {
|
|
$classname = $class_name_without_package;
|
|
$classname = $class_name_without_package;
|
|
|
|
+ $legacy_classname = $legacy_class_name_without_package;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if ($package === "") {
|
|
if ($package === "") {
|
|
$classname = $class_name_without_package;
|
|
$classname = $class_name_without_package;
|
|
|
|
+ $legacy_classname = $legacy_class_name_without_package;
|
|
} else {
|
|
} else {
|
|
$parts = array_map('ucwords', explode('.', $package));
|
|
$parts = array_map('ucwords', explode('.', $package));
|
|
foreach ($parts as $i => $part) {
|
|
foreach ($parts as $i => $part) {
|
|
@@ -358,6 +376,9 @@ class GPBUtil
|
|
implode('\\', $parts) .
|
|
implode('\\', $parts) .
|
|
"\\".self::getClassNamePrefix($class_name_without_package,$file_proto).
|
|
"\\".self::getClassNamePrefix($class_name_without_package,$file_proto).
|
|
$class_name_without_package;
|
|
$class_name_without_package;
|
|
|
|
+ $legacy_classname =
|
|
|
|
+ implode('\\', array_map('ucwords', explode('.', $package))).
|
|
|
|
+ "\\".$legacy_class_name_without_package;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|