Unverified Commit 7f84a943 authored by Paul Yang's avatar Paul Yang Committed by GitHub

Make php message class final to avoid mocking (#6277)

* Make php message class final

Because proto messages are just data object, they should not be mocked.
Explicitly make them final to avoid accidental usage.

* Update generated descriptors
parent 98f0447a
......@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.DescriptorProto</code>
*/
class DescriptorProto extends \Google\Protobuf\Internal\Message
final class DescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.DescriptorProto.ExtensionRange</code>
*/
class ExtensionRange extends \Google\Protobuf\Internal\Message
final class ExtensionRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
......
......@@ -17,7 +17,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.DescriptorProto.ReservedRange</code>
*/
class ReservedRange extends \Google\Protobuf\Internal\Message
final class ReservedRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
......
......@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.EnumDescriptorProto</code>
*/
class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
final class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
......
......@@ -19,7 +19,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.EnumDescriptorProto.EnumReservedRange</code>
*/
class EnumReservedRange extends \Google\Protobuf\Internal\Message
final class EnumReservedRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.EnumOptions</code>
*/
class EnumOptions extends \Google\Protobuf\Internal\Message
final class EnumOptions extends \Google\Protobuf\Internal\Message
{
/**
* Set this option to true to allow mapping different tag names to the same
......
......@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.EnumValueDescriptorProto</code>
*/
class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
final class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.EnumValueOptions</code>
*/
class EnumValueOptions extends \Google\Protobuf\Internal\Message
final class EnumValueOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this enum value deprecated?
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.ExtensionRangeOptions</code>
*/
class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message
final class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message
{
/**
* The parser stores options it doesn't recognize here. See above.
......
......@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.FieldDescriptorProto</code>
*/
class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
final class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.FieldOptions</code>
*/
class FieldOptions extends \Google\Protobuf\Internal\Message
final class FieldOptions extends \Google\Protobuf\Internal\Message
{
/**
* The ctype option instructs the C++ code generator to use a different
......
......@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.FileDescriptorProto</code>
*/
class FileDescriptorProto extends \Google\Protobuf\Internal\Message
final class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* file name, relative to root of source tree
......
......@@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.FileDescriptorSet</code>
*/
class FileDescriptorSet extends \Google\Protobuf\Internal\Message
final class FileDescriptorSet extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code>
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.FileOptions</code>
*/
class FileOptions extends \Google\Protobuf\Internal\Message
final class FileOptions extends \Google\Protobuf\Internal\Message
{
/**
* Sets the Java package where classes generated from this .proto will be
......
......@@ -17,7 +17,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.GeneratedCodeInfo</code>
*/
class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
final class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
{
/**
* An Annotation connects some span of text in generated code to an element
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.GeneratedCodeInfo.Annotation</code>
*/
class Annotation extends \Google\Protobuf\Internal\Message
final class Annotation extends \Google\Protobuf\Internal\Message
{
/**
* Identifies the element in the original source .proto file. This field
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.MessageOptions</code>
*/
class MessageOptions extends \Google\Protobuf\Internal\Message
final class MessageOptions extends \Google\Protobuf\Internal\Message
{
/**
* Set true to use the old proto1 MessageSet wire format for extensions.
......
......@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.MethodDescriptorProto</code>
*/
class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
final class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.MethodOptions</code>
*/
class MethodOptions extends \Google\Protobuf\Internal\Message
final class MethodOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this method deprecated?
......
......@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.OneofDescriptorProto</code>
*/
class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
final class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.OneofOptions</code>
*/
class OneofOptions extends \Google\Protobuf\Internal\Message
final class OneofOptions extends \Google\Protobuf\Internal\Message
{
/**
* The parser stores options it doesn't recognize here. See above.
......
......@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.ServiceDescriptorProto</code>
*/
class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
final class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.ServiceOptions</code>
*/
class ServiceOptions extends \Google\Protobuf\Internal\Message
final class ServiceOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this service deprecated?
......
......@@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.SourceCodeInfo</code>
*/
class SourceCodeInfo extends \Google\Protobuf\Internal\Message
final class SourceCodeInfo extends \Google\Protobuf\Internal\Message
{
/**
* A Location identifies a piece of source code in a .proto file which
......
......@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.SourceCodeInfo.Location</code>
*/
class Location extends \Google\Protobuf\Internal\Message
final class Location extends \Google\Protobuf\Internal\Message
{
/**
* Identifies which part of the FileDescriptorProto was defined at this
......
......@@ -20,7 +20,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.UninterpretedOption</code>
*/
class UninterpretedOption extends \Google\Protobuf\Internal\Message
final class UninterpretedOption extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption.NamePart name = 2;</code>
......
......@@ -19,7 +19,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.UninterpretedOption.NamePart</code>
*/
class NamePart extends \Google\Protobuf\Internal\Message
final class NamePart extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>required string name_part = 1;</code>
......
......@@ -1307,7 +1307,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
}
printer.Print(
"class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n"
"final class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n"
"{\n",
"name", fullname);
Indent(&printer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment