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
pull/6176/head^2
Paul Yang 6 years ago committed by GitHub
parent 98f0447a6f
commit 7f84a94366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. BIN
      csharp/src/Google.Protobuf.Test/testprotos.pb
  2. 2
      php/src/Google/Protobuf/Internal/DescriptorProto.php
  3. 2
      php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
  4. 2
      php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
  5. 2
      php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
  6. 2
      php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
  7. 2
      php/src/Google/Protobuf/Internal/EnumOptions.php
  8. 2
      php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
  9. 2
      php/src/Google/Protobuf/Internal/EnumValueOptions.php
  10. 2
      php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
  11. 2
      php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
  12. 2
      php/src/Google/Protobuf/Internal/FieldOptions.php
  13. 2
      php/src/Google/Protobuf/Internal/FileDescriptorProto.php
  14. 2
      php/src/Google/Protobuf/Internal/FileDescriptorSet.php
  15. 2
      php/src/Google/Protobuf/Internal/FileOptions.php
  16. 2
      php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
  17. 2
      php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
  18. 2
      php/src/Google/Protobuf/Internal/MessageOptions.php
  19. 2
      php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
  20. 2
      php/src/Google/Protobuf/Internal/MethodOptions.php
  21. 2
      php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
  22. 2
      php/src/Google/Protobuf/Internal/OneofOptions.php
  23. 2
      php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
  24. 2
      php/src/Google/Protobuf/Internal/ServiceOptions.php
  25. 2
      php/src/Google/Protobuf/Internal/SourceCodeInfo.php
  26. 2
      php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
  27. 2
      php/src/Google/Protobuf/Internal/UninterpretedOption.php
  28. 2
      php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
  29. 2
      src/google/protobuf/compiler/php/php_generator.cc

@ -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);

Loading…
Cancel
Save