Fix PhpDoc comments for message accessors to include "|null". (#8136)
Message accessors will return null when when the field is not
set, so this should be reflected in the PhpDoc.
Also updated the code generator for the well-known types to reflect
the edits made in https://github.com/protocolbuffers/protobuf/pull/8105.
Also explicitly check for upb_msg_has() in the oneof accessor, so
we are not implicitly relying on unset message fields returning NULL
at the upb level.
diff --git a/php/src/Google/Protobuf/Api.php b/php/src/Google/Protobuf/Api.php
index 7733975..7cbb30e 100644
--- a/php/src/Google/Protobuf/Api.php
+++ b/php/src/Google/Protobuf/Api.php
@@ -271,7 +271,7 @@
* message.
*
* Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 5;</code>
- * @return \Google\Protobuf\SourceContext
+ * @return \Google\Protobuf\SourceContext|null
*/
public function getSourceContext()
{
diff --git a/php/src/Google/Protobuf/Enum.php b/php/src/Google/Protobuf/Enum.php
index ed5afc4..2e0ac99 100644
--- a/php/src/Google/Protobuf/Enum.php
+++ b/php/src/Google/Protobuf/Enum.php
@@ -151,7 +151,7 @@
* The source context.
*
* Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 4;</code>
- * @return \Google\Protobuf\SourceContext
+ * @return \Google\Protobuf\SourceContext|null
*/
public function getSourceContext()
{
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php
index e0822d7..ff308e7 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php
@@ -252,7 +252,7 @@
/**
* Generated from protobuf field <code>optional .google.protobuf.MessageOptions options = 7;</code>
- * @return \Google\Protobuf\Internal\MessageOptions
+ * @return \Google\Protobuf\Internal\MessageOptions|null
*/
public function getOptions()
{
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
index 1594913..bbe4a6a 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
@@ -124,7 +124,7 @@
/**
* Generated from protobuf field <code>optional .google.protobuf.ExtensionRangeOptions options = 3;</code>
- * @return \Google\Protobuf\Internal\ExtensionRangeOptions
+ * @return \Google\Protobuf\Internal\ExtensionRangeOptions|null
*/
public function getOptions()
{
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
index 85dc246..b9b6342 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
@@ -124,7 +124,7 @@
/**
* Generated from protobuf field <code>optional .google.protobuf.EnumOptions options = 3;</code>
- * @return \Google\Protobuf\Internal\EnumOptions
+ * @return \Google\Protobuf\Internal\EnumOptions|null
*/
public function getOptions()
{
diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
index 01097b6..eff1452 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
@@ -112,7 +112,7 @@
/**
* Generated from protobuf field <code>optional .google.protobuf.EnumValueOptions options = 3;</code>
- * @return \Google\Protobuf\Internal\EnumValueOptions
+ * @return \Google\Protobuf\Internal\EnumValueOptions|null
*/
public function getOptions()
{
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
index 5c8823f..94e5fe1 100644
--- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
@@ -511,7 +511,7 @@
/**
* Generated from protobuf field <code>optional .google.protobuf.FieldOptions options = 8;</code>
- * @return \Google\Protobuf\Internal\FieldOptions
+ * @return \Google\Protobuf\Internal\FieldOptions|null
*/
public function getOptions()
{
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
index 96e2c6a..d96c7a7 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
@@ -371,7 +371,7 @@
/**
* Generated from protobuf field <code>optional .google.protobuf.FileOptions options = 8;</code>
- * @return \Google\Protobuf\Internal\FileOptions
+ * @return \Google\Protobuf\Internal\FileOptions|null
*/
public function getOptions()
{
@@ -408,7 +408,7 @@
* development tools.
*
* Generated from protobuf field <code>optional .google.protobuf.SourceCodeInfo source_code_info = 9;</code>
- * @return \Google\Protobuf\Internal\SourceCodeInfo
+ * @return \Google\Protobuf\Internal\SourceCodeInfo|null
*/
public function getSourceCodeInfo()
{
diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
index e2ea8ea..5814f08 100644
--- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
@@ -176,7 +176,7 @@
/**
* Generated from protobuf field <code>optional .google.protobuf.MethodOptions options = 4;</code>
- * @return \Google\Protobuf\Internal\MethodOptions
+ * @return \Google\Protobuf\Internal\MethodOptions|null
*/
public function getOptions()
{
diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
index 5ae36ce..33cf487 100644
--- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
@@ -75,7 +75,7 @@
/**
* Generated from protobuf field <code>optional .google.protobuf.OneofOptions options = 2;</code>
- * @return \Google\Protobuf\Internal\OneofOptions
+ * @return \Google\Protobuf\Internal\OneofOptions|null
*/
public function getOptions()
{
diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
index 9c2cc8f..f60561c 100644
--- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
@@ -102,7 +102,7 @@
/**
* Generated from protobuf field <code>optional .google.protobuf.ServiceOptions options = 3;</code>
- * @return \Google\Protobuf\Internal\ServiceOptions
+ * @return \Google\Protobuf\Internal\ServiceOptions|null
*/
public function getOptions()
{
diff --git a/php/src/Google/Protobuf/Option.php b/php/src/Google/Protobuf/Option.php
index 9b2cc6c..5166a08 100644
--- a/php/src/Google/Protobuf/Option.php
+++ b/php/src/Google/Protobuf/Option.php
@@ -97,7 +97,7 @@
* value using the google.protobuf.Int32Value type.
*
* Generated from protobuf field <code>.google.protobuf.Any value = 2;</code>
- * @return \Google\Protobuf\Any
+ * @return \Google\Protobuf\Any|null
*/
public function getValue()
{
diff --git a/php/src/Google/Protobuf/Type.php b/php/src/Google/Protobuf/Type.php
index f606866..3f28359 100644
--- a/php/src/Google/Protobuf/Type.php
+++ b/php/src/Google/Protobuf/Type.php
@@ -185,7 +185,7 @@
* The source context.
*
* Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 5;</code>
- * @return \Google\Protobuf\SourceContext
+ * @return \Google\Protobuf\SourceContext|null
*/
public function getSourceContext()
{
diff --git a/php/src/Google/Protobuf/Value.php b/php/src/Google/Protobuf/Value.php
index 20db3cc..7bebb99 100644
--- a/php/src/Google/Protobuf/Value.php
+++ b/php/src/Google/Protobuf/Value.php
@@ -174,7 +174,7 @@
* Represents a structured value.
*
* Generated from protobuf field <code>.google.protobuf.Struct struct_value = 5;</code>
- * @return \Google\Protobuf\Struct
+ * @return \Google\Protobuf\Struct|null
*/
public function getStructValue()
{
@@ -205,7 +205,7 @@
* Represents a repeated `Value`.
*
* Generated from protobuf field <code>.google.protobuf.ListValue list_value = 6;</code>
- * @return \Google\Protobuf\ListValue
+ * @return \Google\Protobuf\ListValue|null
*/
public function getListValue()
{