From 8f518e0e693492b5af2361128adefa0f4023ffea Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Fri, 27 Dec 2024 14:24:57 -0800 Subject: [PATCH] feat(php): improve return typehint when repeatedfield --- php/BUILD.bazel | 1 + php/src/Google/Protobuf/Any.php | 2 +- php/src/Google/Protobuf/Api.php | 20 +- php/src/Google/Protobuf/BoolValue.php | 2 +- php/src/Google/Protobuf/BytesValue.php | 2 +- php/src/Google/Protobuf/DoubleValue.php | 2 +- php/src/Google/Protobuf/Duration.php | 2 +- php/src/Google/Protobuf/Enum.php | 14 +- php/src/Google/Protobuf/EnumValue.php | 8 +- php/src/Google/Protobuf/Field.php | 8 +- php/src/Google/Protobuf/FieldMask.php | 8 +- php/src/Google/Protobuf/FloatValue.php | 2 +- php/src/Google/Protobuf/GPBEmpty.php | 2 +- php/src/Google/Protobuf/Int32Value.php | 2 +- php/src/Google/Protobuf/Int64Value.php | 2 +- .../Protobuf/Internal/DescriptorProto.php | 50 ++-- .../DescriptorProto/ExtensionRange.php | 2 +- .../DescriptorProto/ReservedRange.php | 2 +- .../Protobuf/Internal/EnumDescriptorProto.php | 20 +- .../EnumDescriptorProto/EnumReservedRange.php | 2 +- .../Google/Protobuf/Internal/EnumOptions.php | 8 +- .../Internal/EnumValueDescriptorProto.php | 2 +- .../Protobuf/Internal/EnumValueOptions.php | 8 +- .../Internal/ExtensionRangeOptions.php | 14 +- .../ExtensionRangeOptions/Declaration.php | 2 +- .../Google/Protobuf/Internal/FeatureSet.php | 2 +- .../Protobuf/Internal/FeatureSetDefaults.php | 8 +- .../FeatureSetEditionDefault.php | 2 +- .../Internal/FieldDescriptorProto.php | 2 +- .../Google/Protobuf/Internal/FieldOptions.php | 20 +- .../Internal/FieldOptions/EditionDefault.php | 2 +- .../Internal/FieldOptions/FeatureSupport.php | 2 +- .../Protobuf/Internal/FileDescriptorProto.php | 44 +-- .../Protobuf/Internal/FileDescriptorSet.php | 8 +- .../Google/Protobuf/Internal/FileOptions.php | 8 +- .../Protobuf/Internal/GeneratedCodeInfo.php | 8 +- .../Internal/GeneratedCodeInfo/Annotation.php | 8 +- .../Protobuf/Internal/MessageOptions.php | 8 +- .../Internal/MethodDescriptorProto.php | 2 +- .../Protobuf/Internal/MethodOptions.php | 8 +- .../Internal/OneofDescriptorProto.php | 2 +- .../Google/Protobuf/Internal/OneofOptions.php | 8 +- .../Protobuf/Internal/RepeatedField.php | 253 +---------------- .../Internal/ServiceDescriptorProto.php | 8 +- .../Protobuf/Internal/ServiceOptions.php | 8 +- .../Protobuf/Internal/SourceCodeInfo.php | 8 +- .../Internal/SourceCodeInfo/Location.php | 20 +- .../Protobuf/Internal/UninterpretedOption.php | 8 +- .../Internal/UninterpretedOption/NamePart.php | 2 +- php/src/Google/Protobuf/ListValue.php | 8 +- php/src/Google/Protobuf/Method.php | 8 +- php/src/Google/Protobuf/Mixin.php | 2 +- php/src/Google/Protobuf/Option.php | 2 +- php/src/Google/Protobuf/RepeatedField.php | 260 ++++++++++++++++++ php/src/Google/Protobuf/SourceContext.php | 2 +- php/src/Google/Protobuf/StringValue.php | 2 +- php/src/Google/Protobuf/Struct.php | 2 +- php/src/Google/Protobuf/Timestamp.php | 2 +- php/src/Google/Protobuf/Type.php | 20 +- php/src/Google/Protobuf/UInt32Value.php | 2 +- php/src/Google/Protobuf/UInt64Value.php | 2 +- php/src/Google/Protobuf/Value.php | 2 +- php/tests/GeneratedPhpdocTest.php | 65 ++++- .../protobuf/compiler/php/php_generator.cc | 50 ++-- 64 files changed, 567 insertions(+), 498 deletions(-) create mode 100644 php/src/Google/Protobuf/RepeatedField.php diff --git a/php/BUILD.bazel b/php/BUILD.bazel index f1a0728d18834..237cb468384c1 100644 --- a/php/BUILD.bazel +++ b/php/BUILD.bazel @@ -52,6 +52,7 @@ _RUNTIME_SOURCES = [ "src/Google/Protobuf/Internal/RepeatedFieldIter.php", "src/Google/Protobuf/Internal/TimestampBase.php", "src/Google/Protobuf/OneofDescriptor.php", + "src/Google/Protobuf/RepeatedField.php", ] filegroup( diff --git a/php/src/Google/Protobuf/Any.php b/php/src/Google/Protobuf/Any.php index 2f245ca2f6130..3f8180832502f 100644 --- a/php/src/Google/Protobuf/Any.php +++ b/php/src/Google/Protobuf/Any.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * `Any` contains an arbitrary serialized protocol buffer message along with a diff --git a/php/src/Google/Protobuf/Api.php b/php/src/Google/Protobuf/Api.php index f39e81aab63f8..341c56984d862 100644 --- a/php/src/Google/Protobuf/Api.php +++ b/php/src/Google/Protobuf/Api.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Api is a light-weight descriptor for an API Interface. @@ -93,9 +93,9 @@ class Api extends \Google\Protobuf\Internal\Message * @type string $name * The fully qualified name of this interface, including package name * followed by the interface's simple name. - * @type array<\Google\Protobuf\Method>|\Google\Protobuf\Internal\RepeatedField $methods + * @type \Google\Protobuf\Method[] $methods * The methods of this interface, in unspecified order. - * @type array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $options + * @type \Google\Protobuf\Option[] $options * Any metadata attached to the interface. * @type string $version * A version string for this interface. If specified, must have the form @@ -118,7 +118,7 @@ class Api extends \Google\Protobuf\Internal\Message * @type \Google\Protobuf\SourceContext $source_context * Source context for the protocol buffer service represented by this * message. - * @type array<\Google\Protobuf\Mixin>|\Google\Protobuf\Internal\RepeatedField $mixins + * @type \Google\Protobuf\Mixin[] $mixins * Included interfaces. See [Mixin][]. * @type int $syntax * The source syntax of the service. @@ -161,7 +161,7 @@ public function setName($var) * The methods of this interface, in unspecified order. * * Generated from protobuf field repeated .google.protobuf.Method methods = 2; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Method> */ public function getMethods() { @@ -172,7 +172,7 @@ public function getMethods() * The methods of this interface, in unspecified order. * * Generated from protobuf field repeated .google.protobuf.Method methods = 2; - * @param array<\Google\Protobuf\Method>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Method[] $var * @return $this */ public function setMethods($var) @@ -187,7 +187,7 @@ public function setMethods($var) * Any metadata attached to the interface. * * Generated from protobuf field repeated .google.protobuf.Option options = 3; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Option> */ public function getOptions() { @@ -198,7 +198,7 @@ public function getOptions() * Any metadata attached to the interface. * * Generated from protobuf field repeated .google.protobuf.Option options = 3; - * @param array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Option[] $var * @return $this */ public function setOptions($var) @@ -309,7 +309,7 @@ public function setSourceContext($var) * Included interfaces. See [Mixin][]. * * Generated from protobuf field repeated .google.protobuf.Mixin mixins = 6; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Mixin> */ public function getMixins() { @@ -320,7 +320,7 @@ public function getMixins() * Included interfaces. See [Mixin][]. * * Generated from protobuf field repeated .google.protobuf.Mixin mixins = 6; - * @param array<\Google\Protobuf\Mixin>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Mixin[] $var * @return $this */ public function setMixins($var) diff --git a/php/src/Google/Protobuf/BoolValue.php b/php/src/Google/Protobuf/BoolValue.php index c0096c36ac78c..c575d7a9c21be 100644 --- a/php/src/Google/Protobuf/BoolValue.php +++ b/php/src/Google/Protobuf/BoolValue.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Wrapper message for `bool`. diff --git a/php/src/Google/Protobuf/BytesValue.php b/php/src/Google/Protobuf/BytesValue.php index 574eed0380295..c840b460af057 100644 --- a/php/src/Google/Protobuf/BytesValue.php +++ b/php/src/Google/Protobuf/BytesValue.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Wrapper message for `bytes`. diff --git a/php/src/Google/Protobuf/DoubleValue.php b/php/src/Google/Protobuf/DoubleValue.php index 740dddd9e9865..7619938d91171 100644 --- a/php/src/Google/Protobuf/DoubleValue.php +++ b/php/src/Google/Protobuf/DoubleValue.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Wrapper message for `double`. diff --git a/php/src/Google/Protobuf/Duration.php b/php/src/Google/Protobuf/Duration.php index f63169b121de1..62d7d876979a1 100644 --- a/php/src/Google/Protobuf/Duration.php +++ b/php/src/Google/Protobuf/Duration.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * A Duration represents a signed, fixed-length span of time represented diff --git a/php/src/Google/Protobuf/Enum.php b/php/src/Google/Protobuf/Enum.php index 4befa14de5cb3..296b0a019f246 100644 --- a/php/src/Google/Protobuf/Enum.php +++ b/php/src/Google/Protobuf/Enum.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Enum type definition. @@ -61,9 +61,9 @@ class Enum extends \Google\Protobuf\Internal\Message * * @type string $name * Enum type name. - * @type array<\Google\Protobuf\EnumValue>|\Google\Protobuf\Internal\RepeatedField $enumvalue + * @type \Google\Protobuf\EnumValue[] $enumvalue * Enum value definitions. - * @type array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $options + * @type \Google\Protobuf\Option[] $options * Protocol buffer options. * @type \Google\Protobuf\SourceContext $source_context * The source context. @@ -108,7 +108,7 @@ public function setName($var) * Enum value definitions. * * Generated from protobuf field repeated .google.protobuf.EnumValue enumvalue = 2; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\EnumValue> */ public function getEnumvalue() { @@ -119,7 +119,7 @@ public function getEnumvalue() * Enum value definitions. * * Generated from protobuf field repeated .google.protobuf.EnumValue enumvalue = 2; - * @param array<\Google\Protobuf\EnumValue>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\EnumValue[] $var * @return $this */ public function setEnumvalue($var) @@ -134,7 +134,7 @@ public function setEnumvalue($var) * Protocol buffer options. * * Generated from protobuf field repeated .google.protobuf.Option options = 3; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Option> */ public function getOptions() { @@ -145,7 +145,7 @@ public function getOptions() * Protocol buffer options. * * Generated from protobuf field repeated .google.protobuf.Option options = 3; - * @param array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Option[] $var * @return $this */ public function setOptions($var) diff --git a/php/src/Google/Protobuf/EnumValue.php b/php/src/Google/Protobuf/EnumValue.php index 3914d285d47d7..a782640b8b090 100644 --- a/php/src/Google/Protobuf/EnumValue.php +++ b/php/src/Google/Protobuf/EnumValue.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Enum value definition. @@ -45,7 +45,7 @@ class EnumValue extends \Google\Protobuf\Internal\Message * Enum value name. * @type int $number * Enum value number. - * @type array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $options + * @type \Google\Protobuf\Option[] $options * Protocol buffer options. * } */ @@ -110,7 +110,7 @@ public function setNumber($var) * Protocol buffer options. * * Generated from protobuf field repeated .google.protobuf.Option options = 3; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Option> */ public function getOptions() { @@ -121,7 +121,7 @@ public function getOptions() * Protocol buffer options. * * Generated from protobuf field repeated .google.protobuf.Option options = 3; - * @param array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Option[] $var * @return $this */ public function setOptions($var) diff --git a/php/src/Google/Protobuf/Field.php b/php/src/Google/Protobuf/Field.php index c2b635c60d957..405a2c0ad8464 100644 --- a/php/src/Google/Protobuf/Field.php +++ b/php/src/Google/Protobuf/Field.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * A single field of a message type. @@ -101,7 +101,7 @@ class Field extends \Google\Protobuf\Internal\Message * types. The first type has index 1; zero means the type is not in the list. * @type bool $packed * Whether to use alternative packed wire representation. - * @type array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $options + * @type \Google\Protobuf\Option[] $options * The protocol buffer options. * @type string $json_name * The field JSON name. @@ -304,7 +304,7 @@ public function setPacked($var) * The protocol buffer options. * * Generated from protobuf field repeated .google.protobuf.Option options = 9; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Option> */ public function getOptions() { @@ -315,7 +315,7 @@ public function getOptions() * The protocol buffer options. * * Generated from protobuf field repeated .google.protobuf.Option options = 9; - * @param array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Option[] $var * @return $this */ public function setOptions($var) diff --git a/php/src/Google/Protobuf/FieldMask.php b/php/src/Google/Protobuf/FieldMask.php index 2661c307046b6..f0b734e6113a7 100644 --- a/php/src/Google/Protobuf/FieldMask.php +++ b/php/src/Google/Protobuf/FieldMask.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * `FieldMask` represents a set of symbolic field paths, for example: @@ -179,7 +179,7 @@ class FieldMask extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array|\Google\Protobuf\Internal\RepeatedField $paths + * @type string[] $paths * The set of field mask paths. * } */ @@ -192,7 +192,7 @@ public function __construct($data = NULL) { * The set of field mask paths. * * Generated from protobuf field repeated string paths = 1; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getPaths() { @@ -203,7 +203,7 @@ public function getPaths() * The set of field mask paths. * * Generated from protobuf field repeated string paths = 1; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param string[] $var * @return $this */ public function setPaths($var) diff --git a/php/src/Google/Protobuf/FloatValue.php b/php/src/Google/Protobuf/FloatValue.php index 7bfa1aeecb602..8b1e16e60e086 100644 --- a/php/src/Google/Protobuf/FloatValue.php +++ b/php/src/Google/Protobuf/FloatValue.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Wrapper message for `float`. diff --git a/php/src/Google/Protobuf/GPBEmpty.php b/php/src/Google/Protobuf/GPBEmpty.php index 24db6dc6770f6..e3a3e015c48b3 100644 --- a/php/src/Google/Protobuf/GPBEmpty.php +++ b/php/src/Google/Protobuf/GPBEmpty.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * A generic empty message that you can re-use to avoid defining duplicated diff --git a/php/src/Google/Protobuf/Int32Value.php b/php/src/Google/Protobuf/Int32Value.php index 58622cfa0b339..5c206114151b0 100644 --- a/php/src/Google/Protobuf/Int32Value.php +++ b/php/src/Google/Protobuf/Int32Value.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Wrapper message for `int32`. diff --git a/php/src/Google/Protobuf/Int64Value.php b/php/src/Google/Protobuf/Int64Value.php index 437cfba0ed61b..ec24644192e2b 100644 --- a/php/src/Google/Protobuf/Int64Value.php +++ b/php/src/Google/Protobuf/Int64Value.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Wrapper message for `int64`. diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php index 6ce36334f9e54..8a5fefb6662c8 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Describes a message type. @@ -69,15 +69,15 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * @type array<\Google\Protobuf\Internal\FieldDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $field - * @type array<\Google\Protobuf\Internal\FieldDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $extension - * @type array<\Google\Protobuf\Internal\DescriptorProto>|\Google\Protobuf\Internal\RepeatedField $nested_type - * @type array<\Google\Protobuf\Internal\EnumDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $enum_type - * @type array<\Google\Protobuf\Internal\DescriptorProto\ExtensionRange>|\Google\Protobuf\Internal\RepeatedField $extension_range - * @type array<\Google\Protobuf\Internal\OneofDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $oneof_decl + * @type \Google\Protobuf\Internal\FieldDescriptorProto[] $field + * @type \Google\Protobuf\Internal\FieldDescriptorProto[] $extension + * @type \Google\Protobuf\Internal\DescriptorProto[] $nested_type + * @type \Google\Protobuf\Internal\EnumDescriptorProto[] $enum_type + * @type \Google\Protobuf\Internal\DescriptorProto\ExtensionRange[] $extension_range + * @type \Google\Protobuf\Internal\OneofDescriptorProto[] $oneof_decl * @type \Google\Protobuf\Internal\MessageOptions $options - * @type array<\Google\Protobuf\Internal\DescriptorProto\ReservedRange>|\Google\Protobuf\Internal\RepeatedField $reserved_range - * @type array|\Google\Protobuf\Internal\RepeatedField $reserved_name + * @type \Google\Protobuf\Internal\DescriptorProto\ReservedRange[] $reserved_range + * @type string[] $reserved_name * Reserved field names, which may not be used by fields in the same message. * A given name may only be reserved once. * } @@ -121,7 +121,7 @@ public function setName($var) /** * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto field = 2; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\FieldDescriptorProto> */ public function getField() { @@ -130,7 +130,7 @@ public function getField() /** * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto field = 2; - * @param array<\Google\Protobuf\Internal\FieldDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\FieldDescriptorProto[] $var * @return $this */ public function setField($var) @@ -143,7 +143,7 @@ public function setField($var) /** * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto extension = 6; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\FieldDescriptorProto> */ public function getExtension() { @@ -152,7 +152,7 @@ public function getExtension() /** * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto extension = 6; - * @param array<\Google\Protobuf\Internal\FieldDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\FieldDescriptorProto[] $var * @return $this */ public function setExtension($var) @@ -165,7 +165,7 @@ public function setExtension($var) /** * Generated from protobuf field repeated .google.protobuf.DescriptorProto nested_type = 3; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\DescriptorProto> */ public function getNestedType() { @@ -174,7 +174,7 @@ public function getNestedType() /** * Generated from protobuf field repeated .google.protobuf.DescriptorProto nested_type = 3; - * @param array<\Google\Protobuf\Internal\DescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\DescriptorProto[] $var * @return $this */ public function setNestedType($var) @@ -187,7 +187,7 @@ public function setNestedType($var) /** * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\EnumDescriptorProto> */ public function getEnumType() { @@ -196,7 +196,7 @@ public function getEnumType() /** * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - * @param array<\Google\Protobuf\Internal\EnumDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\EnumDescriptorProto[] $var * @return $this */ public function setEnumType($var) @@ -209,7 +209,7 @@ public function setEnumType($var) /** * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\DescriptorProto\ExtensionRange> */ public function getExtensionRange() { @@ -218,7 +218,7 @@ public function getExtensionRange() /** * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - * @param array<\Google\Protobuf\Internal\DescriptorProto\ExtensionRange>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\DescriptorProto\ExtensionRange[] $var * @return $this */ public function setExtensionRange($var) @@ -231,7 +231,7 @@ public function setExtensionRange($var) /** * Generated from protobuf field repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\OneofDescriptorProto> */ public function getOneofDecl() { @@ -240,7 +240,7 @@ public function getOneofDecl() /** * Generated from protobuf field repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; - * @param array<\Google\Protobuf\Internal\OneofDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\OneofDescriptorProto[] $var * @return $this */ public function setOneofDecl($var) @@ -285,7 +285,7 @@ public function setOptions($var) /** * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\DescriptorProto\ReservedRange> */ public function getReservedRange() { @@ -294,7 +294,7 @@ public function getReservedRange() /** * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; - * @param array<\Google\Protobuf\Internal\DescriptorProto\ReservedRange>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\DescriptorProto\ReservedRange[] $var * @return $this */ public function setReservedRange($var) @@ -310,7 +310,7 @@ public function setReservedRange($var) * A given name may only be reserved once. * * Generated from protobuf field repeated string reserved_name = 10; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getReservedName() { @@ -322,7 +322,7 @@ public function getReservedName() * A given name may only be reserved once. * * Generated from protobuf field repeated string reserved_name = 10; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param string[] $var * @return $this */ public function setReservedName($var) diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php index 387c6c78b1432..a2e142df1f409 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.DescriptorProto.ExtensionRange diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php index 63ff8604810ce..61a1e7be7976c 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Range of reserved tag numbers. Reserved tag numbers may not be used by diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php index d0d22a2022dae..02864ed1be318 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Describes an enum type. @@ -53,13 +53,13 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * @type array<\Google\Protobuf\Internal\EnumValueDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $value + * @type \Google\Protobuf\Internal\EnumValueDescriptorProto[] $value * @type \Google\Protobuf\Internal\EnumOptions $options - * @type array<\Google\Protobuf\Internal\EnumDescriptorProto\EnumReservedRange>|\Google\Protobuf\Internal\RepeatedField $reserved_range + * @type \Google\Protobuf\Internal\EnumDescriptorProto\EnumReservedRange[] $reserved_range * Range of reserved numeric values. Reserved numeric values may not be used * by enum values in the same enum declaration. Reserved ranges may not * overlap. - * @type array|\Google\Protobuf\Internal\RepeatedField $reserved_name + * @type string[] $reserved_name * Reserved enum value names, which may not be reused. A given name may only * be reserved once. * } @@ -103,7 +103,7 @@ public function setName($var) /** * Generated from protobuf field repeated .google.protobuf.EnumValueDescriptorProto value = 2; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\EnumValueDescriptorProto> */ public function getValue() { @@ -112,7 +112,7 @@ public function getValue() /** * Generated from protobuf field repeated .google.protobuf.EnumValueDescriptorProto value = 2; - * @param array<\Google\Protobuf\Internal\EnumValueDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\EnumValueDescriptorProto[] $var * @return $this */ public function setValue($var) @@ -161,7 +161,7 @@ public function setOptions($var) * overlap. * * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\EnumDescriptorProto\EnumReservedRange> */ public function getReservedRange() { @@ -174,7 +174,7 @@ public function getReservedRange() * overlap. * * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; - * @param array<\Google\Protobuf\Internal\EnumDescriptorProto\EnumReservedRange>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\EnumDescriptorProto\EnumReservedRange[] $var * @return $this */ public function setReservedRange($var) @@ -190,7 +190,7 @@ public function setReservedRange($var) * be reserved once. * * Generated from protobuf field repeated string reserved_name = 5; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getReservedName() { @@ -202,7 +202,7 @@ public function getReservedName() * be reserved once. * * Generated from protobuf field repeated string reserved_name = 5; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param string[] $var * @return $this */ public function setReservedName($var) diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php index 8c33acc3d51c8..b8234cf81a69a 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Range of reserved numeric values. Reserved values may not be used by diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php index 71a952f85129b..f971465a5ed14 100644 --- a/php/src/Google/Protobuf/Internal/EnumOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumOptions.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.EnumOptions @@ -86,7 +86,7 @@ class EnumOptions extends \Google\Protobuf\Internal\Message * WARNING: This field should only be used by protobuf plugins or special * cases like the proto compiler. Other uses are discouraged and * developers should rely on the protoreflect APIs for their client language. - * @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option + * @type \Google\Protobuf\Internal\UninterpretedOption[] $uninterpreted_option * The parser stores options it doesn't recognize here. See above. * } */ @@ -277,7 +277,7 @@ public function setFeatures($var) * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\UninterpretedOption> */ public function getUninterpretedOption() { @@ -288,7 +288,7 @@ public function getUninterpretedOption() * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @param array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\UninterpretedOption[] $var * @return $this */ public function setUninterpretedOption($var) diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php index 822e1de59bdde..fce650fdb8cbe 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Describes a value within an enum. diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php index 76af9882aca34..30cf2fa8985ff 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.EnumValueOptions @@ -77,7 +77,7 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message * credentials. * @type \Google\Protobuf\Internal\FieldOptions\FeatureSupport $feature_support * Information about the support window of a feature value. - * @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option + * @type \Google\Protobuf\Internal\UninterpretedOption[] $uninterpreted_option * The parser stores options it doesn't recognize here. See above. * } */ @@ -250,7 +250,7 @@ public function setFeatureSupport($var) * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\UninterpretedOption> */ public function getUninterpretedOption() { @@ -261,7 +261,7 @@ public function getUninterpretedOption() * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @param array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\UninterpretedOption[] $var * @return $this */ public function setUninterpretedOption($var) diff --git a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php index 2a969afb47737..4d85c3121c13f 100644 --- a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php +++ b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.ExtensionRangeOptions @@ -51,9 +51,9 @@ class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option + * @type \Google\Protobuf\Internal\UninterpretedOption[] $uninterpreted_option * The parser stores options it doesn't recognize here. See above. - * @type array<\Google\Protobuf\Internal\ExtensionRangeOptions\Declaration>|\Google\Protobuf\Internal\RepeatedField $declaration + * @type \Google\Protobuf\Internal\ExtensionRangeOptions\Declaration[] $declaration * For external users: DO NOT USE. We are in the process of open sourcing * extension declaration and executing internal cleanups before it can be * used externally. @@ -74,7 +74,7 @@ public function __construct($data = NULL) { * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\UninterpretedOption> */ public function getUninterpretedOption() { @@ -85,7 +85,7 @@ public function getUninterpretedOption() * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @param array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\UninterpretedOption[] $var * @return $this */ public function setUninterpretedOption($var) @@ -102,7 +102,7 @@ public function setUninterpretedOption($var) * used externally. * * Generated from protobuf field repeated .google.protobuf.ExtensionRangeOptions.Declaration declaration = 2 [retention = RETENTION_SOURCE]; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\ExtensionRangeOptions\Declaration> */ public function getDeclaration() { @@ -115,7 +115,7 @@ public function getDeclaration() * used externally. * * Generated from protobuf field repeated .google.protobuf.ExtensionRangeOptions.Declaration declaration = 2 [retention = RETENTION_SOURCE]; - * @param array<\Google\Protobuf\Internal\ExtensionRangeOptions\Declaration>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\ExtensionRangeOptions\Declaration[] $var * @return $this */ public function setDeclaration($var) diff --git a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions/Declaration.php b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions/Declaration.php index 6e54295e2e197..632692118052b 100644 --- a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions/Declaration.php +++ b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions/Declaration.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.ExtensionRangeOptions.Declaration diff --git a/php/src/Google/Protobuf/Internal/FeatureSet.php b/php/src/Google/Protobuf/Internal/FeatureSet.php index 4f354f1d07af2..021eb1e310c88 100644 --- a/php/src/Google/Protobuf/Internal/FeatureSet.php +++ b/php/src/Google/Protobuf/Internal/FeatureSet.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * TODO Enums in C++ gencode (and potentially other languages) are diff --git a/php/src/Google/Protobuf/Internal/FeatureSetDefaults.php b/php/src/Google/Protobuf/Internal/FeatureSetDefaults.php index 765c292a2615e..5e0e6e06537a2 100644 --- a/php/src/Google/Protobuf/Internal/FeatureSetDefaults.php +++ b/php/src/Google/Protobuf/Internal/FeatureSetDefaults.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * A compiled specification for the defaults of a set of features. These @@ -46,7 +46,7 @@ class FeatureSetDefaults extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array<\Google\Protobuf\Internal\FeatureSetDefaults\FeatureSetEditionDefault>|\Google\Protobuf\Internal\RepeatedField $defaults + * @type \Google\Protobuf\Internal\FeatureSetDefaults\FeatureSetEditionDefault[] $defaults * @type int $minimum_edition * The minimum supported edition (inclusive) when this was constructed. * Editions before this will not have defaults. @@ -62,7 +62,7 @@ public function __construct($data = NULL) { /** * Generated from protobuf field repeated .google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault defaults = 1; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\FeatureSetDefaults\FeatureSetEditionDefault> */ public function getDefaults() { @@ -71,7 +71,7 @@ public function getDefaults() /** * Generated from protobuf field repeated .google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault defaults = 1; - * @param array<\Google\Protobuf\Internal\FeatureSetDefaults\FeatureSetEditionDefault>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\FeatureSetDefaults\FeatureSetEditionDefault[] $var * @return $this */ public function setDefaults($var) diff --git a/php/src/Google/Protobuf/Internal/FeatureSetDefaults/FeatureSetEditionDefault.php b/php/src/Google/Protobuf/Internal/FeatureSetDefaults/FeatureSetEditionDefault.php index 1b6259a5d94f6..d8b766c8b83f3 100644 --- a/php/src/Google/Protobuf/Internal/FeatureSetDefaults/FeatureSetEditionDefault.php +++ b/php/src/Google/Protobuf/Internal/FeatureSetDefaults/FeatureSetEditionDefault.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * A map from every known edition with a unique set of defaults to its diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php index e493f53eb4dbd..f10018e7dbc77 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Describes a field within a message. diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php index 69b96b2596f81..0e6bff555965f 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.FieldOptions @@ -209,15 +209,15 @@ class FieldOptions extends \Google\Protobuf\Internal\Message * Indicate that the field value should not be printed out when using debug * formats, e.g. when the field contains sensitive credentials. * @type int $retention - * @type array|\Google\Protobuf\Internal\RepeatedField $targets - * @type array<\Google\Protobuf\Internal\FieldOptions\EditionDefault>|\Google\Protobuf\Internal\RepeatedField $edition_defaults + * @type int[] $targets + * @type \Google\Protobuf\Internal\FieldOptions\EditionDefault[] $edition_defaults * @type \Google\Protobuf\Internal\FeatureSet $features * Any features defined in the specific edition. * WARNING: This field should only be used by protobuf plugins or special * cases like the proto compiler. Other uses are discouraged and * developers should rely on the protoreflect APIs for their client language. * @type \Google\Protobuf\Internal\FieldOptions\FeatureSupport $feature_support - * @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option + * @type \Google\Protobuf\Internal\UninterpretedOption[] $uninterpreted_option * The parser stores options it doesn't recognize here. See above. * } */ @@ -638,7 +638,7 @@ public function setRetention($var) /** * Generated from protobuf field repeated .google.protobuf.FieldOptions.OptionTargetType targets = 19; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getTargets() { @@ -647,7 +647,7 @@ public function getTargets() /** * Generated from protobuf field repeated .google.protobuf.FieldOptions.OptionTargetType targets = 19; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param int[] $var * @return $this */ public function setTargets($var) @@ -660,7 +660,7 @@ public function setTargets($var) /** * Generated from protobuf field repeated .google.protobuf.FieldOptions.EditionDefault edition_defaults = 20; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\FieldOptions\EditionDefault> */ public function getEditionDefaults() { @@ -669,7 +669,7 @@ public function getEditionDefaults() /** * Generated from protobuf field repeated .google.protobuf.FieldOptions.EditionDefault edition_defaults = 20; - * @param array<\Google\Protobuf\Internal\FieldOptions\EditionDefault>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\FieldOptions\EditionDefault[] $var * @return $this */ public function setEditionDefaults($var) @@ -758,7 +758,7 @@ public function setFeatureSupport($var) * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\UninterpretedOption> */ public function getUninterpretedOption() { @@ -769,7 +769,7 @@ public function getUninterpretedOption() * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @param array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\UninterpretedOption[] $var * @return $this */ public function setUninterpretedOption($var) diff --git a/php/src/Google/Protobuf/Internal/FieldOptions/EditionDefault.php b/php/src/Google/Protobuf/Internal/FieldOptions/EditionDefault.php index 5acc9938afe56..a5804bade8db8 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions/EditionDefault.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions/EditionDefault.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.FieldOptions.EditionDefault diff --git a/php/src/Google/Protobuf/Internal/FieldOptions/FeatureSupport.php b/php/src/Google/Protobuf/Internal/FieldOptions/FeatureSupport.php index 63dfa7eebfb39..940c72302aec5 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions/FeatureSupport.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions/FeatureSupport.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Information about the support window of a feature. diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php index b01cf6e3072c3..840324625d7a5 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Describes a complete .proto file. @@ -111,18 +111,18 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * file name, relative to root of source tree * @type string $package * e.g. "foo", "foo.bar", etc. - * @type array|\Google\Protobuf\Internal\RepeatedField $dependency + * @type string[] $dependency * Names of files imported by this file. - * @type array|\Google\Protobuf\Internal\RepeatedField $public_dependency + * @type int[] $public_dependency * Indexes of the public imported files in the dependency list above. - * @type array|\Google\Protobuf\Internal\RepeatedField $weak_dependency + * @type int[] $weak_dependency * Indexes of the weak imported files in the dependency list. * For Google-internal migration only. Do not use. - * @type array<\Google\Protobuf\Internal\DescriptorProto>|\Google\Protobuf\Internal\RepeatedField $message_type + * @type \Google\Protobuf\Internal\DescriptorProto[] $message_type * All top-level definitions in this file. - * @type array<\Google\Protobuf\Internal\EnumDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $enum_type - * @type array<\Google\Protobuf\Internal\ServiceDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $service - * @type array<\Google\Protobuf\Internal\FieldDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $extension + * @type \Google\Protobuf\Internal\EnumDescriptorProto[] $enum_type + * @type \Google\Protobuf\Internal\ServiceDescriptorProto[] $service + * @type \Google\Protobuf\Internal\FieldDescriptorProto[] $extension * @type \Google\Protobuf\Internal\FileOptions $options * @type \Google\Protobuf\Internal\SourceCodeInfo $source_code_info * This field contains optional information about the original source code. @@ -224,7 +224,7 @@ public function setPackage($var) * Names of files imported by this file. * * Generated from protobuf field repeated string dependency = 3; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getDependency() { @@ -235,7 +235,7 @@ public function getDependency() * Names of files imported by this file. * * Generated from protobuf field repeated string dependency = 3; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param string[] $var * @return $this */ public function setDependency($var) @@ -250,7 +250,7 @@ public function setDependency($var) * Indexes of the public imported files in the dependency list above. * * Generated from protobuf field repeated int32 public_dependency = 10; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getPublicDependency() { @@ -261,7 +261,7 @@ public function getPublicDependency() * Indexes of the public imported files in the dependency list above. * * Generated from protobuf field repeated int32 public_dependency = 10; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param int[] $var * @return $this */ public function setPublicDependency($var) @@ -277,7 +277,7 @@ public function setPublicDependency($var) * For Google-internal migration only. Do not use. * * Generated from protobuf field repeated int32 weak_dependency = 11; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getWeakDependency() { @@ -289,7 +289,7 @@ public function getWeakDependency() * For Google-internal migration only. Do not use. * * Generated from protobuf field repeated int32 weak_dependency = 11; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param int[] $var * @return $this */ public function setWeakDependency($var) @@ -304,7 +304,7 @@ public function setWeakDependency($var) * All top-level definitions in this file. * * Generated from protobuf field repeated .google.protobuf.DescriptorProto message_type = 4; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\DescriptorProto> */ public function getMessageType() { @@ -315,7 +315,7 @@ public function getMessageType() * All top-level definitions in this file. * * Generated from protobuf field repeated .google.protobuf.DescriptorProto message_type = 4; - * @param array<\Google\Protobuf\Internal\DescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\DescriptorProto[] $var * @return $this */ public function setMessageType($var) @@ -328,7 +328,7 @@ public function setMessageType($var) /** * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\EnumDescriptorProto> */ public function getEnumType() { @@ -337,7 +337,7 @@ public function getEnumType() /** * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - * @param array<\Google\Protobuf\Internal\EnumDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\EnumDescriptorProto[] $var * @return $this */ public function setEnumType($var) @@ -350,7 +350,7 @@ public function setEnumType($var) /** * Generated from protobuf field repeated .google.protobuf.ServiceDescriptorProto service = 6; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\ServiceDescriptorProto> */ public function getService() { @@ -359,7 +359,7 @@ public function getService() /** * Generated from protobuf field repeated .google.protobuf.ServiceDescriptorProto service = 6; - * @param array<\Google\Protobuf\Internal\ServiceDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\ServiceDescriptorProto[] $var * @return $this */ public function setService($var) @@ -372,7 +372,7 @@ public function setService($var) /** * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto extension = 7; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\FieldDescriptorProto> */ public function getExtension() { @@ -381,7 +381,7 @@ public function getExtension() /** * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto extension = 7; - * @param array<\Google\Protobuf\Internal\FieldDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\FieldDescriptorProto[] $var * @return $this */ public function setExtension($var) diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php index 6337846661b16..60d5f4bfba1be 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * The protocol compiler can output a FileDescriptorSet containing the .proto @@ -30,7 +30,7 @@ class FileDescriptorSet extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array<\Google\Protobuf\Internal\FileDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $file + * @type \Google\Protobuf\Internal\FileDescriptorProto[] $file * } */ public function __construct($data = NULL) { @@ -40,7 +40,7 @@ public function __construct($data = NULL) { /** * Generated from protobuf field repeated .google.protobuf.FileDescriptorProto file = 1; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\FileDescriptorProto> */ public function getFile() { @@ -49,7 +49,7 @@ public function getFile() /** * Generated from protobuf field repeated .google.protobuf.FileDescriptorProto file = 1; - * @param array<\Google\Protobuf\Internal\FileDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\FileDescriptorProto[] $var * @return $this */ public function setFile($var) diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php index a130d5a67afac..91c94237a122c 100644 --- a/php/src/Google/Protobuf/Internal/FileOptions.php +++ b/php/src/Google/Protobuf/Internal/FileOptions.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.FileOptions @@ -280,7 +280,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * WARNING: This field should only be used by protobuf plugins or special * cases like the proto compiler. Other uses are discouraged and * developers should rely on the protoreflect APIs for their client language. - * @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option + * @type \Google\Protobuf\Internal\UninterpretedOption[] $uninterpreted_option * The parser stores options it doesn't recognize here. * See the documentation for the "Options" section above. * } @@ -1111,7 +1111,7 @@ public function setFeatures($var) * See the documentation for the "Options" section above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\UninterpretedOption> */ public function getUninterpretedOption() { @@ -1123,7 +1123,7 @@ public function getUninterpretedOption() * See the documentation for the "Options" section above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @param array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\UninterpretedOption[] $var * @return $this */ public function setUninterpretedOption($var) diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php index 0fe4a433b65af..6af52740bd91e 100644 --- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Describes the relationship between generated code and its original source @@ -34,7 +34,7 @@ class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array<\Google\Protobuf\Internal\GeneratedCodeInfo\Annotation>|\Google\Protobuf\Internal\RepeatedField $annotation + * @type \Google\Protobuf\Internal\GeneratedCodeInfo\Annotation[] $annotation * An Annotation connects some span of text in generated code to an element * of its generating .proto file. * } @@ -49,7 +49,7 @@ public function __construct($data = NULL) { * of its generating .proto file. * * Generated from protobuf field repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\GeneratedCodeInfo\Annotation> */ public function getAnnotation() { @@ -61,7 +61,7 @@ public function getAnnotation() * of its generating .proto file. * * Generated from protobuf field repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; - * @param array<\Google\Protobuf\Internal\GeneratedCodeInfo\Annotation>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\GeneratedCodeInfo\Annotation[] $var * @return $this */ public function setAnnotation($var) diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php index 6a3b60c103213..a7fdb42e9fa12 100644 --- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.GeneratedCodeInfo.Annotation @@ -55,7 +55,7 @@ class Annotation extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array|\Google\Protobuf\Internal\RepeatedField $path + * @type int[] $path * Identifies the element in the original source .proto file. This field * is formatted the same as SourceCodeInfo.Location.path. * @type string $source_file @@ -80,7 +80,7 @@ public function __construct($data = NULL) { * is formatted the same as SourceCodeInfo.Location.path. * * Generated from protobuf field repeated int32 path = 1 [packed = true]; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getPath() { @@ -92,7 +92,7 @@ public function getPath() * is formatted the same as SourceCodeInfo.Location.path. * * Generated from protobuf field repeated int32 path = 1 [packed = true]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param int[] $var * @return $this */ public function setPath($var) diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php index 23ba7b4a25db9..d09e6fab50603 100644 --- a/php/src/Google/Protobuf/Internal/MessageOptions.php +++ b/php/src/Google/Protobuf/Internal/MessageOptions.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.MessageOptions @@ -170,7 +170,7 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * WARNING: This field should only be used by protobuf plugins or special * cases like the proto compiler. Other uses are discouraged and * developers should rely on the protoreflect APIs for their client language. - * @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option + * @type \Google\Protobuf\Internal\UninterpretedOption[] $uninterpreted_option * The parser stores options it doesn't recognize here. See above. * } */ @@ -501,7 +501,7 @@ public function setFeatures($var) * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\UninterpretedOption> */ public function getUninterpretedOption() { @@ -512,7 +512,7 @@ public function getUninterpretedOption() * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @param array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\UninterpretedOption[] $var * @return $this */ public function setUninterpretedOption($var) diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php index 93276e3930c85..59ab867812e8b 100644 --- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Describes a method of a service. diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php index da27df21aa3c5..aae2a3d1705ae 100644 --- a/php/src/Google/Protobuf/Internal/MethodOptions.php +++ b/php/src/Google/Protobuf/Internal/MethodOptions.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.MethodOptions @@ -62,7 +62,7 @@ class MethodOptions extends \Google\Protobuf\Internal\Message * WARNING: This field should only be used by protobuf plugins or special * cases like the proto compiler. Other uses are discouraged and * developers should rely on the protoreflect APIs for their client language. - * @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option + * @type \Google\Protobuf\Internal\UninterpretedOption[] $uninterpreted_option * The parser stores options it doesn't recognize here. See above. * } */ @@ -191,7 +191,7 @@ public function setFeatures($var) * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\UninterpretedOption> */ public function getUninterpretedOption() { @@ -202,7 +202,7 @@ public function getUninterpretedOption() * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @param array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\UninterpretedOption[] $var * @return $this */ public function setUninterpretedOption($var) diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php index da55bb4f42c50..16da70fa35aea 100644 --- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Describes a oneof. diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php index 2d94ac48985b9..1d68a13aae2d4 100644 --- a/php/src/Google/Protobuf/Internal/OneofOptions.php +++ b/php/src/Google/Protobuf/Internal/OneofOptions.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.OneofOptions @@ -43,7 +43,7 @@ class OneofOptions extends \Google\Protobuf\Internal\Message * WARNING: This field should only be used by protobuf plugins or special * cases like the proto compiler. Other uses are discouraged and * developers should rely on the protoreflect APIs for their client language. - * @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option + * @type \Google\Protobuf\Internal\UninterpretedOption[] $uninterpreted_option * The parser stores options it doesn't recognize here. See above. * } */ @@ -98,7 +98,7 @@ public function setFeatures($var) * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\UninterpretedOption> */ public function getUninterpretedOption() { @@ -109,7 +109,7 @@ public function getUninterpretedOption() * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @param array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\UninterpretedOption[] $var * @return $this */ public function setUninterpretedOption($var) diff --git a/php/src/Google/Protobuf/Internal/RepeatedField.php b/php/src/Google/Protobuf/Internal/RepeatedField.php index 3d9e66d488e71..cd6ef02cbe602 100644 --- a/php/src/Google/Protobuf/Internal/RepeatedField.php +++ b/php/src/Google/Protobuf/Internal/RepeatedField.php @@ -1,254 +1,13 @@ container = []; - $this->type = $type; - if ($this->type == GPBType::MESSAGE) { - $pool = DescriptorPool::getGeneratedPool(); - $desc = $pool->getDescriptorByClassName($klass); - if ($desc == NULL) { - new $klass; // No msg class instance has been created before. - $desc = $pool->getDescriptorByClassName($klass); - } - $this->klass = $desc->getClass(); - $this->legacy_klass = $desc->getLegacyClass(); - } - } - - /** - * @ignore - */ - public function getType() - { - return $this->type; - } - - /** - * @ignore - */ - public function getClass() - { - return $this->klass; - } - - /** - * @ignore - */ - public function getLegacyClass() - { - return $this->legacy_klass; - } - - /** - * Return the element at the given index. - * - * This will also be called for: $ele = $arr[0] - * - * @param integer $offset The index of the element to be fetched. - * @return mixed The stored element at given index. - * @throws \ErrorException Invalid type for index. - * @throws \ErrorException Non-existing index. - * @todo need to add return type mixed (require update php version to 8.0) - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset]; - } - - /** - * Assign the element at the given index. - * - * This will also be called for: $arr []= $ele and $arr[0] = ele - * - * @param int|null $offset The index of the element to be assigned. - * @param mixed $value The element to be assigned. - * @return void - * @throws \ErrorException Invalid type for index. - * @throws \ErrorException Non-existing index. - * @throws \ErrorException Incorrect type of the element. - * @todo need to add return type void (require update php version to 7.1) - */ - #[\ReturnTypeWillChange] - public function offsetSet($offset, $value) - { - switch ($this->type) { - case GPBType::SFIXED32: - case GPBType::SINT32: - case GPBType::INT32: - case GPBType::ENUM: - GPBUtil::checkInt32($value); - break; - case GPBType::FIXED32: - case GPBType::UINT32: - GPBUtil::checkUint32($value); - break; - case GPBType::SFIXED64: - case GPBType::SINT64: - case GPBType::INT64: - GPBUtil::checkInt64($value); - break; - case GPBType::FIXED64: - case GPBType::UINT64: - GPBUtil::checkUint64($value); - break; - case GPBType::FLOAT: - GPBUtil::checkFloat($value); - break; - case GPBType::DOUBLE: - GPBUtil::checkDouble($value); - break; - case GPBType::BOOL: - GPBUtil::checkBool($value); - break; - case GPBType::BYTES: - GPBUtil::checkString($value, false); - break; - case GPBType::STRING: - GPBUtil::checkString($value, true); - break; - case GPBType::MESSAGE: - if (is_null($value)) { - throw new \TypeError("RepeatedField element cannot be null."); - } - GPBUtil::checkMessage($value, $this->klass); - break; - default: - break; - } - if (is_null($offset)) { - $this->container[] = $value; - } else { - $count = count($this->container); - if (!is_numeric($offset) || $offset < 0 || $offset >= $count) { - trigger_error( - "Cannot modify element at the given index", - E_USER_ERROR); - return; - } - $this->container[$offset] = $value; - } - } - - /** - * Remove the element at the given index. - * - * This will also be called for: unset($arr) - * - * @param integer $offset The index of the element to be removed. - * @return void - * @throws \ErrorException Invalid type for index. - * @throws \ErrorException The element to be removed is not at the end of the - * RepeatedField. - * @todo need to add return type void (require update php version to 7.1) - */ - #[\ReturnTypeWillChange] - public function offsetUnset($offset) - { - $count = count($this->container); - if (!is_numeric($offset) || $count === 0 || $offset < 0 || $offset >= $count) { - trigger_error( - "Cannot remove element at the given index", - E_USER_ERROR); - return; - } - array_splice($this->container, $offset, 1); - } - - /** - * Check the existence of the element at the given index. - * - * This will also be called for: isset($arr) - * - * @param integer $offset The index of the element to be removed. - * @return bool True if the element at the given offset exists. - * @throws \ErrorException Invalid type for index. - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * @ignore - */ - public function getIterator(): Traversable - { - return new RepeatedFieldIter($this->container); - } - - /** - * Return the number of stored elements. - * - * This will also be called for: count($arr) - * - * @return integer The number of stored elements. - */ - public function count(): int - { - return count($this->container); - } - - public function __debugInfo() - { - return array_map( - function ($item) { - if ($item instanceof Message || $item instanceof RepeatedField) { - return $item->__debugInfo(); - } - return $item; - }, - iterator_to_array($this) - ); - } + class RepeatedField {} } +class_exists(\Google\Protobuf\RepeatedField::class); +@trigger_error('Google\Protobuf\Internal\RepeatedField is deprecated and will be removed in the next major release. Use Google\Protobuf\RepeatedField instead', E_USER_DEPRECATED); diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php index bcc44f0e23243..27b274b2241e6 100644 --- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Describes a service. @@ -38,7 +38,7 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * @type array<\Google\Protobuf\Internal\MethodDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $method + * @type \Google\Protobuf\Internal\MethodDescriptorProto[] $method * @type \Google\Protobuf\Internal\ServiceOptions $options * } */ @@ -81,7 +81,7 @@ public function setName($var) /** * Generated from protobuf field repeated .google.protobuf.MethodDescriptorProto method = 2; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\MethodDescriptorProto> */ public function getMethod() { @@ -90,7 +90,7 @@ public function getMethod() /** * Generated from protobuf field repeated .google.protobuf.MethodDescriptorProto method = 2; - * @param array<\Google\Protobuf\Internal\MethodDescriptorProto>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\MethodDescriptorProto[] $var * @return $this */ public function setMethod($var) diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php index 56b44585a2cb2..d478bb2c3bd64 100644 --- a/php/src/Google/Protobuf/Internal/ServiceOptions.php +++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.ServiceOptions @@ -57,7 +57,7 @@ class ServiceOptions extends \Google\Protobuf\Internal\Message * Depending on the target platform, this can emit Deprecated annotations * for the service, or it will be completely ignored; in the very least, * this is a formalization for deprecating services. - * @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option + * @type \Google\Protobuf\Internal\UninterpretedOption[] $uninterpreted_option * The parser stores options it doesn't recognize here. See above. * } */ @@ -154,7 +154,7 @@ public function setDeprecated($var) * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\UninterpretedOption> */ public function getUninterpretedOption() { @@ -165,7 +165,7 @@ public function getUninterpretedOption() * The parser stores options it doesn't recognize here. See above. * * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - * @param array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\UninterpretedOption[] $var * @return $this */ public function setUninterpretedOption($var) diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php index d6419f5a96543..b194a0416ea1d 100644 --- a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Encapsulates information about the original source file from which a @@ -72,7 +72,7 @@ class SourceCodeInfo extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array<\Google\Protobuf\Internal\SourceCodeInfo\Location>|\Google\Protobuf\Internal\RepeatedField $location + * @type \Google\Protobuf\Internal\SourceCodeInfo\Location[] $location * A Location identifies a piece of source code in a .proto file which * corresponds to a particular definition. This information is intended * to be useful to IDEs, code indexers, documentation generators, and similar @@ -165,7 +165,7 @@ public function __construct($data = NULL) { * be recorded in the future. * * Generated from protobuf field repeated .google.protobuf.SourceCodeInfo.Location location = 1; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\SourceCodeInfo\Location> */ public function getLocation() { @@ -216,7 +216,7 @@ public function getLocation() * be recorded in the future. * * Generated from protobuf field repeated .google.protobuf.SourceCodeInfo.Location location = 1; - * @param array<\Google\Protobuf\Internal\SourceCodeInfo\Location>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\SourceCodeInfo\Location[] $var * @return $this */ public function setLocation($var) diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php index 5253dbc4ffd39..87d3452a147cd 100644 --- a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Generated from protobuf message google.protobuf.SourceCodeInfo.Location @@ -108,7 +108,7 @@ class Location extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array|\Google\Protobuf\Internal\RepeatedField $path + * @type int[] $path * Identifies which part of the FileDescriptorProto was defined at this * location. * Each element is a field number or an index. They form a path from @@ -130,7 +130,7 @@ class Location extends \Google\Protobuf\Internal\Message * [ 4, 3, 2, 7 ] * this path refers to the whole field declaration (from the beginning * of the label to the terminating semicolon). - * @type array|\Google\Protobuf\Internal\RepeatedField $span + * @type int[] $span * Always has exactly three or four elements: start line, start column, * end line (optional, otherwise assumed same as start line), end column. * These are packed into a single field for efficiency. Note that line @@ -174,7 +174,7 @@ class Location extends \Google\Protobuf\Internal\Message * optional int32 grault = 6; * // ignored detached comments. * @type string $trailing_comments - * @type array|\Google\Protobuf\Internal\RepeatedField $leading_detached_comments + * @type string[] $leading_detached_comments * } */ public function __construct($data = NULL) { @@ -206,7 +206,7 @@ public function __construct($data = NULL) { * of the label to the terminating semicolon). * * Generated from protobuf field repeated int32 path = 1 [packed = true]; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getPath() { @@ -237,7 +237,7 @@ public function getPath() * of the label to the terminating semicolon). * * Generated from protobuf field repeated int32 path = 1 [packed = true]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param int[] $var * @return $this */ public function setPath($var) @@ -256,7 +256,7 @@ public function setPath($var) * 1 to each before displaying to a user. * * Generated from protobuf field repeated int32 span = 2 [packed = true]; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getSpan() { @@ -271,7 +271,7 @@ public function getSpan() * 1 to each before displaying to a user. * * Generated from protobuf field repeated int32 span = 2 [packed = true]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param int[] $var * @return $this */ public function setSpan($var) @@ -422,7 +422,7 @@ public function setTrailingComments($var) /** * Generated from protobuf field repeated string leading_detached_comments = 6; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getLeadingDetachedComments() { @@ -431,7 +431,7 @@ public function getLeadingDetachedComments() /** * Generated from protobuf field repeated string leading_detached_comments = 6; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param string[] $var * @return $this */ public function setLeadingDetachedComments($var) diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php index 156534e4f2247..b365b6c0cd654 100644 --- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * A message representing a option the parser does not recognize. This only @@ -61,7 +61,7 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array<\Google\Protobuf\Internal\UninterpretedOption\NamePart>|\Google\Protobuf\Internal\RepeatedField $name + * @type \Google\Protobuf\Internal\UninterpretedOption\NamePart[] $name * @type string $identifier_value * The value of the uninterpreted option, in whatever type the tokenizer * identified it as during parsing. Exactly one of these should be set. @@ -79,7 +79,7 @@ public function __construct($data = NULL) { /** * Generated from protobuf field repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Internal\UninterpretedOption\NamePart> */ public function getName() { @@ -88,7 +88,7 @@ public function getName() /** * Generated from protobuf field repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - * @param array<\Google\Protobuf\Internal\UninterpretedOption\NamePart>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Internal\UninterpretedOption\NamePart[] $var * @return $this */ public function setName($var) diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php index 784a9cff9e804..547e3f4c31527 100644 --- a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php @@ -7,9 +7,9 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * The name of the uninterpreted option. Each string represents a segment in diff --git a/php/src/Google/Protobuf/ListValue.php b/php/src/Google/Protobuf/ListValue.php index af0845f4b4daf..5d8b8b391c831 100644 --- a/php/src/Google/Protobuf/ListValue.php +++ b/php/src/Google/Protobuf/ListValue.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * `ListValue` is a wrapper around a repeated field of values. @@ -30,7 +30,7 @@ class ListValue extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array<\Google\Protobuf\Value>|\Google\Protobuf\Internal\RepeatedField $values + * @type \Google\Protobuf\Value[] $values * Repeated field of dynamically typed values. * } */ @@ -43,7 +43,7 @@ public function __construct($data = NULL) { * Repeated field of dynamically typed values. * * Generated from protobuf field repeated .google.protobuf.Value values = 1; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Value> */ public function getValues() { @@ -54,7 +54,7 @@ public function getValues() * Repeated field of dynamically typed values. * * Generated from protobuf field repeated .google.protobuf.Value values = 1; - * @param array<\Google\Protobuf\Value>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Value[] $var * @return $this */ public function setValues($var) diff --git a/php/src/Google/Protobuf/Method.php b/php/src/Google/Protobuf/Method.php index 6c92edf677e98..5e55a764cd168 100644 --- a/php/src/Google/Protobuf/Method.php +++ b/php/src/Google/Protobuf/Method.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Method represents a method of an API interface. @@ -75,7 +75,7 @@ class Method extends \Google\Protobuf\Internal\Message * The URL of the output message type. * @type bool $response_streaming * If true, the response is streamed. - * @type array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $options + * @type \Google\Protobuf\Option[] $options * Any metadata attached to the method. * @type int $syntax * The source syntax of this method. @@ -220,7 +220,7 @@ public function setResponseStreaming($var) * Any metadata attached to the method. * * Generated from protobuf field repeated .google.protobuf.Option options = 6; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Option> */ public function getOptions() { @@ -231,7 +231,7 @@ public function getOptions() * Any metadata attached to the method. * * Generated from protobuf field repeated .google.protobuf.Option options = 6; - * @param array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Option[] $var * @return $this */ public function setOptions($var) diff --git a/php/src/Google/Protobuf/Mixin.php b/php/src/Google/Protobuf/Mixin.php index f01a4d24f1897..0250b8e82d25c 100644 --- a/php/src/Google/Protobuf/Mixin.php +++ b/php/src/Google/Protobuf/Mixin.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Declares an API Interface to be included in this interface. The including diff --git a/php/src/Google/Protobuf/Option.php b/php/src/Google/Protobuf/Option.php index aeb8368916b25..7674fda8348ba 100644 --- a/php/src/Google/Protobuf/Option.php +++ b/php/src/Google/Protobuf/Option.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * A protocol buffer option, which can be attached to a message, field, diff --git a/php/src/Google/Protobuf/RepeatedField.php b/php/src/Google/Protobuf/RepeatedField.php new file mode 100644 index 0000000000000..ffe76e5487c93 --- /dev/null +++ b/php/src/Google/Protobuf/RepeatedField.php @@ -0,0 +1,260 @@ + + * @implements \IteratorAggregate + */ +class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable +{ + + /** + * @ignore + */ + private $container; + /** + * @ignore + */ + private $type; + /** + * @ignore + * @var string|class-string + */ + private $klass; + /** + * @ignore + */ + private $legacy_klass; + + /** + * Constructs an instance of RepeatedField. + * + * @param integer $type Type of the stored element. + * @param string|class-string $klass Message/Enum class name (message/enum fields only). + * @ignore + */ + public function __construct($type, $klass = null) + { + $this->container = []; + $this->type = $type; + if ($this->type == GPBType::MESSAGE) { + $pool = DescriptorPool::getGeneratedPool(); + $desc = $pool->getDescriptorByClassName($klass); + if ($desc == NULL) { + new $klass; // No msg class instance has been created before. + $desc = $pool->getDescriptorByClassName($klass); + } + $this->klass = $desc->getClass(); + $this->legacy_klass = $desc->getLegacyClass(); + } + } + + /** + * @ignore + */ + public function getType() + { + return $this->type; + } + + /** + * @ignore + * @return string|class-string + */ + public function getClass() + { + return $this->klass; + } + + /** + * @ignore + */ + public function getLegacyClass() + { + return $this->legacy_klass; + } + + /** + * Return the element at the given index. + * + * This will also be called for: $ele = $arr[0] + * + * @param integer $offset The index of the element to be fetched. + * @return T The stored element at given index. + * @throws \ErrorException Invalid type for index. + * @throws \ErrorException Non-existing index. + * @todo need to add return type mixed (require update php version to 8.0) + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset]; + } + + /** + * Assign the element at the given index. + * + * This will also be called for: $arr []= $ele and $arr[0] = ele + * + * @param int|null $offset The index of the element to be assigned. + * @param T $value The element to be assigned. + * @return void + * @throws \ErrorException Invalid type for index. + * @throws \ErrorException Non-existing index. + * @throws \ErrorException Incorrect type of the element. + * @todo need to add return type void (require update php version to 7.1) + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + switch ($this->type) { + case GPBType::SFIXED32: + case GPBType::SINT32: + case GPBType::INT32: + case GPBType::ENUM: + GPBUtil::checkInt32($value); + break; + case GPBType::FIXED32: + case GPBType::UINT32: + GPBUtil::checkUint32($value); + break; + case GPBType::SFIXED64: + case GPBType::SINT64: + case GPBType::INT64: + GPBUtil::checkInt64($value); + break; + case GPBType::FIXED64: + case GPBType::UINT64: + GPBUtil::checkUint64($value); + break; + case GPBType::FLOAT: + GPBUtil::checkFloat($value); + break; + case GPBType::DOUBLE: + GPBUtil::checkDouble($value); + break; + case GPBType::BOOL: + GPBUtil::checkBool($value); + break; + case GPBType::BYTES: + GPBUtil::checkString($value, false); + break; + case GPBType::STRING: + GPBUtil::checkString($value, true); + break; + case GPBType::MESSAGE: + if (is_null($value)) { + throw new \TypeError("RepeatedField element cannot be null."); + } + GPBUtil::checkMessage($value, $this->klass); + break; + default: + break; + } + if (is_null($offset)) { + $this->container[] = $value; + } else { + $count = count($this->container); + if (!is_numeric($offset) || $offset < 0 || $offset >= $count) { + trigger_error( + "Cannot modify element at the given index", + E_USER_ERROR); + return; + } + $this->container[$offset] = $value; + } + } + + /** + * Remove the element at the given index. + * + * This will also be called for: unset($arr) + * + * @param integer $offset The index of the element to be removed. + * @return void + * @throws \ErrorException Invalid type for index. + * @throws \ErrorException The element to be removed is not at the end of the + * RepeatedField. + * @todo need to add return type void (require update php version to 7.1) + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + $count = count($this->container); + if (!is_numeric($offset) || $count === 0 || $offset < 0 || $offset >= $count) { + trigger_error( + "Cannot remove element at the given index", + E_USER_ERROR); + return; + } + array_splice($this->container, $offset, 1); + } + + /** + * Check the existence of the element at the given index. + * + * This will also be called for: isset($arr) + * + * @param integer $offset The index of the element to be removed. + * @return bool True if the element at the given offset exists. + * @throws \ErrorException Invalid type for index. + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * @ignore + */ + public function getIterator(): Traversable + { + return new RepeatedFieldIter($this->container); + } + + /** + * Return the number of stored elements. + * + * This will also be called for: count($arr) + * + * @return integer The number of stored elements. + */ + public function count(): int + { + return count($this->container); + } + + public function __debugInfo() + { + return array_map( + function ($item) { + if ($item instanceof Message || $item instanceof RepeatedField) { + return $item->__debugInfo(); + } + return $item; + }, + iterator_to_array($this) + ); + } +} diff --git a/php/src/Google/Protobuf/SourceContext.php b/php/src/Google/Protobuf/SourceContext.php index cdb5670e48daf..3cebbdecde589 100644 --- a/php/src/Google/Protobuf/SourceContext.php +++ b/php/src/Google/Protobuf/SourceContext.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * `SourceContext` represents information about the source of a diff --git a/php/src/Google/Protobuf/StringValue.php b/php/src/Google/Protobuf/StringValue.php index 807fef57ac90c..f5b80dc9445cb 100644 --- a/php/src/Google/Protobuf/StringValue.php +++ b/php/src/Google/Protobuf/StringValue.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Wrapper message for `string`. diff --git a/php/src/Google/Protobuf/Struct.php b/php/src/Google/Protobuf/Struct.php index 38c608908975b..0c433a9144af4 100644 --- a/php/src/Google/Protobuf/Struct.php +++ b/php/src/Google/Protobuf/Struct.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * `Struct` represents a structured data value, consisting of fields diff --git a/php/src/Google/Protobuf/Timestamp.php b/php/src/Google/Protobuf/Timestamp.php index 489e21d36e29e..54d675cb243c8 100644 --- a/php/src/Google/Protobuf/Timestamp.php +++ b/php/src/Google/Protobuf/Timestamp.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * A Timestamp represents a point in time independent of any time zone or local diff --git a/php/src/Google/Protobuf/Type.php b/php/src/Google/Protobuf/Type.php index 6167ba4484b68..c274909abea6d 100644 --- a/php/src/Google/Protobuf/Type.php +++ b/php/src/Google/Protobuf/Type.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * A protocol buffer message type. @@ -67,11 +67,11 @@ class Type extends \Google\Protobuf\Internal\Message * * @type string $name * The fully qualified message name. - * @type array<\Google\Protobuf\Field>|\Google\Protobuf\Internal\RepeatedField $fields + * @type \Google\Protobuf\Field[] $fields * The list of fields. - * @type array|\Google\Protobuf\Internal\RepeatedField $oneofs + * @type string[] $oneofs * The list of types appearing in `oneof` definitions in this type. - * @type array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $options + * @type \Google\Protobuf\Option[] $options * The protocol buffer options. * @type \Google\Protobuf\SourceContext $source_context * The source context. @@ -116,7 +116,7 @@ public function setName($var) * The list of fields. * * Generated from protobuf field repeated .google.protobuf.Field fields = 2; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Field> */ public function getFields() { @@ -127,7 +127,7 @@ public function getFields() * The list of fields. * * Generated from protobuf field repeated .google.protobuf.Field fields = 2; - * @param array<\Google\Protobuf\Field>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Field[] $var * @return $this */ public function setFields($var) @@ -142,7 +142,7 @@ public function setFields($var) * The list of types appearing in `oneof` definitions in this type. * * Generated from protobuf field repeated string oneofs = 3; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField */ public function getOneofs() { @@ -153,7 +153,7 @@ public function getOneofs() * The list of types appearing in `oneof` definitions in this type. * * Generated from protobuf field repeated string oneofs = 3; - * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @param string[] $var * @return $this */ public function setOneofs($var) @@ -168,7 +168,7 @@ public function setOneofs($var) * The protocol buffer options. * * Generated from protobuf field repeated .google.protobuf.Option options = 4; - * @return \Google\Protobuf\Internal\RepeatedField + * @return RepeatedField<\Google\Protobuf\Option> */ public function getOptions() { @@ -179,7 +179,7 @@ public function getOptions() * The protocol buffer options. * * Generated from protobuf field repeated .google.protobuf.Option options = 4; - * @param array<\Google\Protobuf\Option>|\Google\Protobuf\Internal\RepeatedField $var + * @param \Google\Protobuf\Option[] $var * @return $this */ public function setOptions($var) diff --git a/php/src/Google/Protobuf/UInt32Value.php b/php/src/Google/Protobuf/UInt32Value.php index a71db921744f4..028689f92ef21 100644 --- a/php/src/Google/Protobuf/UInt32Value.php +++ b/php/src/Google/Protobuf/UInt32Value.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Wrapper message for `uint32`. diff --git a/php/src/Google/Protobuf/UInt64Value.php b/php/src/Google/Protobuf/UInt64Value.php index 3b41fe81348f3..db52ec1acd401 100644 --- a/php/src/Google/Protobuf/UInt64Value.php +++ b/php/src/Google/Protobuf/UInt64Value.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * Wrapper message for `uint64`. diff --git a/php/src/Google/Protobuf/Value.php b/php/src/Google/Protobuf/Value.php index 710f39fdf1d9b..85e4c1e526bb9 100644 --- a/php/src/Google/Protobuf/Value.php +++ b/php/src/Google/Protobuf/Value.php @@ -6,8 +6,8 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\RepeatedField; /** * `Value` represents a dynamically typed value which can be either diff --git a/php/tests/GeneratedPhpdocTest.php b/php/tests/GeneratedPhpdocTest.php index 78ac623d9fae6..e32d12fe316e7 100644 --- a/php/tests/GeneratedPhpdocTest.php +++ b/php/tests/GeneratedPhpdocTest.php @@ -108,27 +108,62 @@ public function providePhpDocForGettersAndSetters() [ [ 'getRepeatedInt32', - 'getRepeatedInt64', 'getRepeatedUint32', - 'getRepeatedUint64', 'getRepeatedSint32', - 'getRepeatedSint64', 'getRepeatedFixed32', - 'getRepeatedFixed64', 'getRepeatedSfixed32', + 'getRepeatedEnum', + 'getRepeatedNoNamespaceEnum', + ], + '@return RepeatedField' + ], + [ + [ + 'getRepeatedInt64', + 'getRepeatedUint64', + 'getRepeatedSint64', + 'getRepeatedFixed64', 'getRepeatedSfixed64', + ], + '@return RepeatedField|RepeatedField' + ], + [ + [ 'getRepeatedFloat', 'getRepeatedDouble', + ], + '@return RepeatedField' + ], + [ + [ 'getRepeatedBool', + ], + '@return RepeatedField' + ], + [ + [ 'getRepeatedString', 'getRepeatedBytes', - 'getRepeatedEnum', + ], + '@return RepeatedField' + ], + [ + [ 'getRepeatedMessage', + ], + '@return RepeatedField<\Foo\TestMessage\Sub>' + ], + [ + [ 'getRepeatedRecursive', + ], + '@return RepeatedField<\Foo\TestMessage>' + ], + [ + [ 'getRepeatedNoNamespaceMessage', - 'getRepeatedNoNamespaceEnum', ], - '@return \Google\Protobuf\Internal\RepeatedField' + '@return RepeatedField<\NoNamespaceMessage>' ], [ [ @@ -163,7 +198,7 @@ public function providePhpDocForGettersAndSetters() 'setRepeatedEnum', 'setRepeatedNoNamespaceEnum', ], - '@param array|\Google\Protobuf\Internal\RepeatedField $var' + '@param int[] $var' ], [ [ @@ -173,45 +208,45 @@ public function providePhpDocForGettersAndSetters() 'setRepeatedFixed64', 'setRepeatedSfixed64', ], - '@param array|array|\Google\Protobuf\Internal\RepeatedField $var' + '@param int[]|string[] $var' ], [ [ 'setRepeatedFloat', 'setRepeatedDouble', ], - '@param array|\Google\Protobuf\Internal\RepeatedField $var' + '@param float[] $var' ], [ [ 'setRepeatedBool', ], - '@param array|\Google\Protobuf\Internal\RepeatedField $var' + '@param bool[] $var' ], [ [ 'setRepeatedString', 'setRepeatedBytes', ], - '@param array|\Google\Protobuf\Internal\RepeatedField $var' + '@param string[] $var' ], [ [ 'setRepeatedMessage', ], - '@param array<\Foo\TestMessage\Sub>|\Google\Protobuf\Internal\RepeatedField $var' + '@param \Foo\TestMessage\Sub[] $var' ], [ [ 'setRepeatedRecursive', ], - '@param array<\Foo\TestMessage>|\Google\Protobuf\Internal\RepeatedField $var' + '@param \Foo\TestMessage[] $var' ], [ [ 'setRepeatedNoNamespaceMessage', ], - '@param array<\NoNamespaceMessage>|\Google\Protobuf\Internal\RepeatedField $var' + '@param \NoNamespaceMessage[] $var' ], [ [ diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index f9b27a8ea5f3b..f47398fa1fd81 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -378,10 +378,9 @@ std::string PhpSetterTypeName(const FieldDescriptor* field, // accommodate for edge case with multiple types. size_t start_pos = type.find('|'); if (start_pos != std::string::npos) { - type.replace(start_pos, 1, ">|array<"); + type.replace(start_pos, 1, "[]|"); } - type = absl::StrCat("array<", type, - ">|\\Google\\Protobuf\\Internal\\RepeatedField"); + type = absl::StrCat(type, "[]"); } return type; } @@ -398,9 +397,7 @@ std::string PhpGetterTypeName(const FieldDescriptor* field, if (field->is_map()) { return "\\Google\\Protobuf\\Internal\\MapField"; } - if (field->is_repeated()) { - return "\\Google\\Protobuf\\Internal\\RepeatedField"; - } + std::string type; switch (field->type()) { case FieldDescriptor::TYPE_INT32: case FieldDescriptor::TYPE_UINT32: @@ -408,29 +405,46 @@ std::string PhpGetterTypeName(const FieldDescriptor* field, case FieldDescriptor::TYPE_FIXED32: case FieldDescriptor::TYPE_SFIXED32: case FieldDescriptor::TYPE_ENUM: - return "int"; + type = "int"; + break; case FieldDescriptor::TYPE_INT64: case FieldDescriptor::TYPE_UINT64: case FieldDescriptor::TYPE_SINT64: case FieldDescriptor::TYPE_FIXED64: case FieldDescriptor::TYPE_SFIXED64: - return "int|string"; + type = "int|string"; + break; case FieldDescriptor::TYPE_DOUBLE: case FieldDescriptor::TYPE_FLOAT: - return "float"; + type = "float"; + break; case FieldDescriptor::TYPE_BOOL: - return "bool"; + type = "bool"; + break; case FieldDescriptor::TYPE_STRING: case FieldDescriptor::TYPE_BYTES: - return "string"; + type = "string"; + break; case FieldDescriptor::TYPE_MESSAGE: - return absl::StrCat("\\", FullClassName(field->message_type(), options)); + type = absl::StrCat("\\", FullClassName(field->message_type(), options)); + break; case FieldDescriptor::TYPE_GROUP: - return "null"; + type = "null"; + break; default: assert(false); - return ""; + type = ""; + break; } + if (field->is_repeated()) { + // accommodate for edge case with multiple types. + size_t start_pos = type.find('|'); + if (start_pos != std::string::npos) { + type.replace(start_pos, 1, ">|RepeatedField<"); + } + type = absl::StrCat("RepeatedField<", type, ">"); + } + return type; } std::string PhpGetterTypeName(const FieldDescriptor* field, @@ -1083,15 +1097,15 @@ void GenerateUseDeclaration(const Options& options, io::Printer* printer) { if (!options.is_descriptor) { printer->Print( "use Google\\Protobuf\\Internal\\GPBType;\n" - "use Google\\Protobuf\\Internal\\RepeatedField;\n" - "use Google\\Protobuf\\Internal\\GPBUtil;\n\n"); + "use Google\\Protobuf\\Internal\\GPBUtil;\n" + "use Google\\Protobuf\\RepeatedField;\n\n"); } else { printer->Print( "use Google\\Protobuf\\Internal\\GPBType;\n" "use Google\\Protobuf\\Internal\\GPBWire;\n" - "use Google\\Protobuf\\Internal\\RepeatedField;\n" "use Google\\Protobuf\\Internal\\InputStream;\n" - "use Google\\Protobuf\\Internal\\GPBUtil;\n\n"); + "use Google\\Protobuf\\Internal\\GPBUtil;\n" + "use Google\\Protobuf\\RepeatedField;\n\n"); } }