diff --git a/csharp/src/Google.Protobuf.Test/testprotos.pb b/csharp/src/Google.Protobuf.Test/testprotos.pb
index bc3979e965..71256aea77 100644
Binary files a/csharp/src/Google.Protobuf.Test/testprotos.pb and b/csharp/src/Google.Protobuf.Test/testprotos.pb differ
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php
index 3b215d52ae..2d52831451 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.DescriptorProto
*/
-class DescriptorProto extends \Google\Protobuf\Internal\Message
+final class DescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field optional string name = 1;
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
index a2057fd5d1..fb98f7d5a0 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.DescriptorProto.ExtensionRange
*/
-class ExtensionRange extends \Google\Protobuf\Internal\Message
+final class ExtensionRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
index 73c964faa0..fa46419a53 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
@@ -17,7 +17,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.DescriptorProto.ReservedRange
*/
-class ReservedRange extends \Google\Protobuf\Internal\Message
+final class ReservedRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
index da30fa9906..b7c3a208be 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.EnumDescriptorProto
*/
-class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
+final class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field optional string name = 1;
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
index e1079585ec..0103a1b301 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
@@ -19,7 +19,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.EnumDescriptorProto.EnumReservedRange
*/
-class EnumReservedRange extends \Google\Protobuf\Internal\Message
+final class EnumReservedRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php
index 3d74c81c21..4c73d52740 100644
--- a/php/src/Google/Protobuf/Internal/EnumOptions.php
+++ b/php/src/Google/Protobuf/Internal/EnumOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.EnumOptions
*/
-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
diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
index 50bda008e8..d5a0a9afb5 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.EnumValueDescriptorProto
*/
-class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
+final class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field optional string name = 1;
diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
index a267c6d5e2..50ac904ff9 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.EnumValueOptions
*/
-class EnumValueOptions extends \Google\Protobuf\Internal\Message
+final class EnumValueOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this enum value deprecated?
diff --git a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
index 00fbebecaf..97ad2c055f 100644
--- a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
+++ b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.ExtensionRangeOptions
*/
-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.
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
index e578197515..6f8643c8d7 100644
--- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.FieldDescriptorProto
*/
-class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
+final class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field optional string name = 1;
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php
index 751c278d78..47d1951d16 100644
--- a/php/src/Google/Protobuf/Internal/FieldOptions.php
+++ b/php/src/Google/Protobuf/Internal/FieldOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.FieldOptions
*/
-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
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
index cb10aa7939..e95205476c 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.FileDescriptorProto
*/
-class FileDescriptorProto extends \Google\Protobuf\Internal\Message
+final class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* file name, relative to root of source tree
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
index 9907b17d73..c9a38808fb 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
@@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.FileDescriptorSet
*/
-class FileDescriptorSet extends \Google\Protobuf\Internal\Message
+final class FileDescriptorSet extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field repeated .google.protobuf.FileDescriptorProto file = 1;
diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php
index 6fea195ec1..9110005016 100644
--- a/php/src/Google/Protobuf/Internal/FileOptions.php
+++ b/php/src/Google/Protobuf/Internal/FileOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.FileOptions
*/
-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
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
index f5a65bea46..c99d77afa3 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
@@ -17,7 +17,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.GeneratedCodeInfo
*/
-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
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
index 09f958d251..8cc3cdf457 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.GeneratedCodeInfo.Annotation
*/
-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
diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php
index 4453942110..9032c97e9b 100644
--- a/php/src/Google/Protobuf/Internal/MessageOptions.php
+++ b/php/src/Google/Protobuf/Internal/MessageOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.MessageOptions
*/
-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.
diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
index 1bd5dd3e1c..25a2c166fd 100644
--- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.MethodDescriptorProto
*/
-class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
+final class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field optional string name = 1;
diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php
index a2c729a9bb..a9c093ad5d 100644
--- a/php/src/Google/Protobuf/Internal/MethodOptions.php
+++ b/php/src/Google/Protobuf/Internal/MethodOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.MethodOptions
*/
-class MethodOptions extends \Google\Protobuf\Internal\Message
+final class MethodOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this method deprecated?
diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
index 9ecfe5cbfe..a703fcb702 100644
--- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.OneofDescriptorProto
*/
-class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
+final class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field optional string name = 1;
diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php
index 46b516f301..749051f31f 100644
--- a/php/src/Google/Protobuf/Internal/OneofOptions.php
+++ b/php/src/Google/Protobuf/Internal/OneofOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.OneofOptions
*/
-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.
diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
index 8de7afd0bc..9534f0480e 100644
--- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.ServiceDescriptorProto
*/
-class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
+final class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field optional string name = 1;
diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php
index 67162f3764..55bf7a7758 100644
--- a/php/src/Google/Protobuf/Internal/ServiceOptions.php
+++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.ServiceOptions
*/
-class ServiceOptions extends \Google\Protobuf\Internal\Message
+final class ServiceOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this service deprecated?
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
index dfeb69ff69..3ddd892262 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
@@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.SourceCodeInfo
*/
-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
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
index bad247a11f..470d64c6e2 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message google.protobuf.SourceCodeInfo.Location
*/
-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
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
index 3b517ec552..39273d62fa 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
@@ -20,7 +20,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.UninterpretedOption
*/
-class UninterpretedOption extends \Google\Protobuf\Internal\Message
+final class UninterpretedOption extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
index 92ee4b44b9..a2f9250f93 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
@@ -19,7 +19,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message google.protobuf.UninterpretedOption.NamePart
*/
-class NamePart extends \Google\Protobuf\Internal\Message
+final class NamePart extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field required string name_part = 1;
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc
index c47ea33f79..60d7d8b73b 100644
--- a/src/google/protobuf/compiler/php/php_generator.cc
+++ b/src/google/protobuf/compiler/php/php_generator.cc
@@ -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);