No need to generate addtional has method for proto2 (#7802)

* No need to generate addtional has method for proto2

* Also remove has property
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php
index 7cc689d..e0822d7 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php
@@ -20,48 +20,39 @@
     /**
      * Generated from protobuf field <code>optional string name = 1;</code>
      */
-    protected $name = '';
-    private $has_name = false;
+    protected $name = null;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code>
      */
     private $field;
-    private $has_field = false;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code>
      */
     private $extension;
-    private $has_extension = false;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code>
      */
     private $nested_type;
-    private $has_nested_type = false;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code>
      */
     private $enum_type;
-    private $has_enum_type = false;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code>
      */
     private $extension_range;
-    private $has_extension_range = false;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code>
      */
     private $oneof_decl;
-    private $has_oneof_decl = false;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.MessageOptions options = 7;</code>
      */
     protected $options = null;
-    private $has_options = false;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code>
      */
     private $reserved_range;
-    private $has_reserved_range = false;
     /**
      * Reserved field names, which may not be used by fields in the same message.
      * A given name may only be reserved once.
@@ -69,7 +60,6 @@
      * Generated from protobuf field <code>repeated string reserved_name = 10;</code>
      */
     private $reserved_name;
-    private $has_reserved_name = false;
 
     /**
      * Constructor.
@@ -102,7 +92,17 @@
      */
     public function getName()
     {
-        return $this->name;
+        return isset($this->name) ? $this->name : '';
+    }
+
+    public function hasName()
+    {
+        return isset($this->name);
+    }
+
+    public function clearName()
+    {
+        unset($this->name);
     }
 
     /**
@@ -114,16 +114,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->name = $var;
-        $this->has_name = true;
 
         return $this;
     }
 
-    public function hasName()
-    {
-        return $this->has_name;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -142,16 +136,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
         $this->field = $arr;
-        $this->has_field = true;
 
         return $this;
     }
 
-    public function hasField()
-    {
-        return $this->has_field;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -170,16 +158,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
         $this->extension = $arr;
-        $this->has_extension = true;
 
         return $this;
     }
 
-    public function hasExtension()
-    {
-        return $this->has_extension;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -198,16 +180,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class);
         $this->nested_type = $arr;
-        $this->has_nested_type = true;
 
         return $this;
     }
 
-    public function hasNestedType()
-    {
-        return $this->has_nested_type;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -226,16 +202,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class);
         $this->enum_type = $arr;
-        $this->has_enum_type = true;
 
         return $this;
     }
 
-    public function hasEnumType()
-    {
-        return $this->has_enum_type;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -254,16 +224,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto\ExtensionRange::class);
         $this->extension_range = $arr;
-        $this->has_extension_range = true;
 
         return $this;
     }
 
-    public function hasExtensionRange()
-    {
-        return $this->has_extension_range;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -282,23 +246,27 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class);
         $this->oneof_decl = $arr;
-        $this->has_oneof_decl = true;
 
         return $this;
     }
 
-    public function hasOneofDecl()
-    {
-        return $this->has_oneof_decl;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.MessageOptions options = 7;</code>
      * @return \Google\Protobuf\Internal\MessageOptions
      */
     public function getOptions()
     {
-        return $this->options;
+        return isset($this->options) ? $this->options : null;
+    }
+
+    public function hasOptions()
+    {
+        return isset($this->options);
+    }
+
+    public function clearOptions()
+    {
+        unset($this->options);
     }
 
     /**
@@ -310,16 +278,10 @@
     {
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class);
         $this->options = $var;
-        $this->has_options = true;
 
         return $this;
     }
 
-    public function hasOptions()
-    {
-        return $this->has_options;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -338,16 +300,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto\ReservedRange::class);
         $this->reserved_range = $arr;
-        $this->has_reserved_range = true;
 
         return $this;
     }
 
-    public function hasReservedRange()
-    {
-        return $this->has_reserved_range;
-    }
-
     /**
      * Reserved field names, which may not be used by fields in the same message.
      * A given name may only be reserved once.
@@ -372,15 +328,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
         $this->reserved_name = $arr;
-        $this->has_reserved_name = true;
 
         return $this;
     }
 
-    public function hasReservedName()
-    {
-        return $this->has_reserved_name;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
index 82b5695..1594913 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
@@ -20,20 +20,17 @@
      *
      * Generated from protobuf field <code>optional int32 start = 1;</code>
      */
-    protected $start = 0;
-    private $has_start = false;
+    protected $start = null;
     /**
      * Exclusive.
      *
      * Generated from protobuf field <code>optional int32 end = 2;</code>
      */
-    protected $end = 0;
-    private $has_end = false;
+    protected $end = null;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.ExtensionRangeOptions options = 3;</code>
      */
     protected $options = null;
-    private $has_options = false;
 
     /**
      * Constructor.
@@ -61,7 +58,17 @@
      */
     public function getStart()
     {
-        return $this->start;
+        return isset($this->start) ? $this->start : 0;
+    }
+
+    public function hasStart()
+    {
+        return isset($this->start);
+    }
+
+    public function clearStart()
+    {
+        unset($this->start);
     }
 
     /**
@@ -75,16 +82,10 @@
     {
         GPBUtil::checkInt32($var);
         $this->start = $var;
-        $this->has_start = true;
 
         return $this;
     }
 
-    public function hasStart()
-    {
-        return $this->has_start;
-    }
-
     /**
      * Exclusive.
      *
@@ -93,7 +94,17 @@
      */
     public function getEnd()
     {
-        return $this->end;
+        return isset($this->end) ? $this->end : 0;
+    }
+
+    public function hasEnd()
+    {
+        return isset($this->end);
+    }
+
+    public function clearEnd()
+    {
+        unset($this->end);
     }
 
     /**
@@ -107,23 +118,27 @@
     {
         GPBUtil::checkInt32($var);
         $this->end = $var;
-        $this->has_end = true;
 
         return $this;
     }
 
-    public function hasEnd()
-    {
-        return $this->has_end;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.ExtensionRangeOptions options = 3;</code>
      * @return \Google\Protobuf\Internal\ExtensionRangeOptions
      */
     public function getOptions()
     {
-        return $this->options;
+        return isset($this->options) ? $this->options : null;
+    }
+
+    public function hasOptions()
+    {
+        return isset($this->options);
+    }
+
+    public function clearOptions()
+    {
+        unset($this->options);
     }
 
     /**
@@ -135,16 +150,10 @@
     {
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ExtensionRangeOptions::class);
         $this->options = $var;
-        $this->has_options = true;
 
         return $this;
     }
 
-    public function hasOptions()
-    {
-        return $this->has_options;
-    }
-
 }
 
 // Adding a class alias for backwards compatibility with the previous class name.
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
index 8022151..f099cc3 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
@@ -24,15 +24,13 @@
      *
      * Generated from protobuf field <code>optional int32 start = 1;</code>
      */
-    protected $start = 0;
-    private $has_start = false;
+    protected $start = null;
     /**
      * Exclusive.
      *
      * Generated from protobuf field <code>optional int32 end = 2;</code>
      */
-    protected $end = 0;
-    private $has_end = false;
+    protected $end = null;
 
     /**
      * Constructor.
@@ -59,7 +57,17 @@
      */
     public function getStart()
     {
-        return $this->start;
+        return isset($this->start) ? $this->start : 0;
+    }
+
+    public function hasStart()
+    {
+        return isset($this->start);
+    }
+
+    public function clearStart()
+    {
+        unset($this->start);
     }
 
     /**
@@ -73,16 +81,10 @@
     {
         GPBUtil::checkInt32($var);
         $this->start = $var;
-        $this->has_start = true;
 
         return $this;
     }
 
-    public function hasStart()
-    {
-        return $this->has_start;
-    }
-
     /**
      * Exclusive.
      *
@@ -91,7 +93,17 @@
      */
     public function getEnd()
     {
-        return $this->end;
+        return isset($this->end) ? $this->end : 0;
+    }
+
+    public function hasEnd()
+    {
+        return isset($this->end);
+    }
+
+    public function clearEnd()
+    {
+        unset($this->end);
     }
 
     /**
@@ -105,16 +117,10 @@
     {
         GPBUtil::checkInt32($var);
         $this->end = $var;
-        $this->has_end = true;
 
         return $this;
     }
 
-    public function hasEnd()
-    {
-        return $this->has_end;
-    }
-
 }
 
 // Adding a class alias for backwards compatibility with the previous class name.
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
index f5c7fe1..85dc246 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
@@ -20,18 +20,15 @@
     /**
      * Generated from protobuf field <code>optional string name = 1;</code>
      */
-    protected $name = '';
-    private $has_name = false;
+    protected $name = null;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code>
      */
     private $value;
-    private $has_value = false;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.EnumOptions options = 3;</code>
      */
     protected $options = null;
-    private $has_options = false;
     /**
      * Range of reserved numeric values. Reserved numeric values may not be used
      * by enum values in the same enum declaration. Reserved ranges may not
@@ -40,7 +37,6 @@
      * Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4;</code>
      */
     private $reserved_range;
-    private $has_reserved_range = false;
     /**
      * Reserved enum value names, which may not be reused. A given name may only
      * be reserved once.
@@ -48,7 +44,6 @@
      * Generated from protobuf field <code>repeated string reserved_name = 5;</code>
      */
     private $reserved_name;
-    private $has_reserved_name = false;
 
     /**
      * Constructor.
@@ -79,7 +74,17 @@
      */
     public function getName()
     {
-        return $this->name;
+        return isset($this->name) ? $this->name : '';
+    }
+
+    public function hasName()
+    {
+        return isset($this->name);
+    }
+
+    public function clearName()
+    {
+        unset($this->name);
     }
 
     /**
@@ -91,16 +96,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->name = $var;
-        $this->has_name = true;
 
         return $this;
     }
 
-    public function hasName()
-    {
-        return $this->has_name;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -119,23 +118,27 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class);
         $this->value = $arr;
-        $this->has_value = true;
 
         return $this;
     }
 
-    public function hasValue()
-    {
-        return $this->has_value;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.EnumOptions options = 3;</code>
      * @return \Google\Protobuf\Internal\EnumOptions
      */
     public function getOptions()
     {
-        return $this->options;
+        return isset($this->options) ? $this->options : null;
+    }
+
+    public function hasOptions()
+    {
+        return isset($this->options);
+    }
+
+    public function clearOptions()
+    {
+        unset($this->options);
     }
 
     /**
@@ -147,16 +150,10 @@
     {
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class);
         $this->options = $var;
-        $this->has_options = true;
 
         return $this;
     }
 
-    public function hasOptions()
-    {
-        return $this->has_options;
-    }
-
     /**
      * Range of reserved numeric values. Reserved numeric values may not be used
      * by enum values in the same enum declaration. Reserved ranges may not
@@ -183,16 +180,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto\EnumReservedRange::class);
         $this->reserved_range = $arr;
-        $this->has_reserved_range = true;
 
         return $this;
     }
 
-    public function hasReservedRange()
-    {
-        return $this->has_reserved_range;
-    }
-
     /**
      * Reserved enum value names, which may not be reused. A given name may only
      * be reserved once.
@@ -217,15 +208,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
         $this->reserved_name = $arr;
-        $this->has_reserved_name = true;
 
         return $this;
     }
 
-    public function hasReservedName()
-    {
-        return $this->has_reserved_name;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
index 949dd89..7282fcc 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
@@ -26,15 +26,13 @@
      *
      * Generated from protobuf field <code>optional int32 start = 1;</code>
      */
-    protected $start = 0;
-    private $has_start = false;
+    protected $start = null;
     /**
      * Inclusive.
      *
      * Generated from protobuf field <code>optional int32 end = 2;</code>
      */
-    protected $end = 0;
-    private $has_end = false;
+    protected $end = null;
 
     /**
      * Constructor.
@@ -61,7 +59,17 @@
      */
     public function getStart()
     {
-        return $this->start;
+        return isset($this->start) ? $this->start : 0;
+    }
+
+    public function hasStart()
+    {
+        return isset($this->start);
+    }
+
+    public function clearStart()
+    {
+        unset($this->start);
     }
 
     /**
@@ -75,16 +83,10 @@
     {
         GPBUtil::checkInt32($var);
         $this->start = $var;
-        $this->has_start = true;
 
         return $this;
     }
 
-    public function hasStart()
-    {
-        return $this->has_start;
-    }
-
     /**
      * Inclusive.
      *
@@ -93,7 +95,17 @@
      */
     public function getEnd()
     {
-        return $this->end;
+        return isset($this->end) ? $this->end : 0;
+    }
+
+    public function hasEnd()
+    {
+        return isset($this->end);
+    }
+
+    public function clearEnd()
+    {
+        unset($this->end);
     }
 
     /**
@@ -107,16 +119,10 @@
     {
         GPBUtil::checkInt32($var);
         $this->end = $var;
-        $this->has_end = true;
 
         return $this;
     }
 
-    public function hasEnd()
-    {
-        return $this->has_end;
-    }
-
 }
 
 // Adding a class alias for backwards compatibility with the previous class name.
diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php
index e650042..7a69676 100644
--- a/php/src/Google/Protobuf/Internal/EnumOptions.php
+++ b/php/src/Google/Protobuf/Internal/EnumOptions.php
@@ -21,8 +21,7 @@
      *
      * Generated from protobuf field <code>optional bool allow_alias = 2;</code>
      */
-    protected $allow_alias = false;
-    private $has_allow_alias = false;
+    protected $allow_alias = null;
     /**
      * Is this enum deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
@@ -31,15 +30,13 @@
      *
      * Generated from protobuf field <code>optional bool deprecated = 3 [default = false];</code>
      */
-    protected $deprecated = false;
-    private $has_deprecated = false;
+    protected $deprecated = null;
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
      * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
      */
     private $uninterpreted_option;
-    private $has_uninterpreted_option = false;
 
     /**
      * Constructor.
@@ -73,7 +70,17 @@
      */
     public function getAllowAlias()
     {
-        return $this->allow_alias;
+        return isset($this->allow_alias) ? $this->allow_alias : false;
+    }
+
+    public function hasAllowAlias()
+    {
+        return isset($this->allow_alias);
+    }
+
+    public function clearAllowAlias()
+    {
+        unset($this->allow_alias);
     }
 
     /**
@@ -88,16 +95,10 @@
     {
         GPBUtil::checkBool($var);
         $this->allow_alias = $var;
-        $this->has_allow_alias = true;
 
         return $this;
     }
 
-    public function hasAllowAlias()
-    {
-        return $this->has_allow_alias;
-    }
-
     /**
      * Is this enum deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
@@ -109,7 +110,17 @@
      */
     public function getDeprecated()
     {
-        return $this->deprecated;
+        return isset($this->deprecated) ? $this->deprecated : false;
+    }
+
+    public function hasDeprecated()
+    {
+        return isset($this->deprecated);
+    }
+
+    public function clearDeprecated()
+    {
+        unset($this->deprecated);
     }
 
     /**
@@ -126,16 +137,10 @@
     {
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
-        $this->has_deprecated = true;
 
         return $this;
     }
 
-    public function hasDeprecated()
-    {
-        return $this->has_deprecated;
-    }
-
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
@@ -158,15 +163,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
-        $this->has_uninterpreted_option = true;
 
         return $this;
     }
 
-    public function hasUninterpretedOption()
-    {
-        return $this->has_uninterpreted_option;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
index 3dd9558..01097b6 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
@@ -20,18 +20,15 @@
     /**
      * Generated from protobuf field <code>optional string name = 1;</code>
      */
-    protected $name = '';
-    private $has_name = false;
+    protected $name = null;
     /**
      * Generated from protobuf field <code>optional int32 number = 2;</code>
      */
-    protected $number = 0;
-    private $has_number = false;
+    protected $number = null;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.EnumValueOptions options = 3;</code>
      */
     protected $options = null;
-    private $has_options = false;
 
     /**
      * Constructor.
@@ -55,7 +52,17 @@
      */
     public function getName()
     {
-        return $this->name;
+        return isset($this->name) ? $this->name : '';
+    }
+
+    public function hasName()
+    {
+        return isset($this->name);
+    }
+
+    public function clearName()
+    {
+        unset($this->name);
     }
 
     /**
@@ -67,23 +74,27 @@
     {
         GPBUtil::checkString($var, True);
         $this->name = $var;
-        $this->has_name = true;
 
         return $this;
     }
 
-    public function hasName()
-    {
-        return $this->has_name;
-    }
-
     /**
      * Generated from protobuf field <code>optional int32 number = 2;</code>
      * @return int
      */
     public function getNumber()
     {
-        return $this->number;
+        return isset($this->number) ? $this->number : 0;
+    }
+
+    public function hasNumber()
+    {
+        return isset($this->number);
+    }
+
+    public function clearNumber()
+    {
+        unset($this->number);
     }
 
     /**
@@ -95,23 +106,27 @@
     {
         GPBUtil::checkInt32($var);
         $this->number = $var;
-        $this->has_number = true;
 
         return $this;
     }
 
-    public function hasNumber()
-    {
-        return $this->has_number;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.EnumValueOptions options = 3;</code>
      * @return \Google\Protobuf\Internal\EnumValueOptions
      */
     public function getOptions()
     {
-        return $this->options;
+        return isset($this->options) ? $this->options : null;
+    }
+
+    public function hasOptions()
+    {
+        return isset($this->options);
+    }
+
+    public function clearOptions()
+    {
+        unset($this->options);
     }
 
     /**
@@ -123,15 +138,9 @@
     {
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class);
         $this->options = $var;
-        $this->has_options = true;
 
         return $this;
     }
 
-    public function hasOptions()
-    {
-        return $this->has_options;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
index 9f9fb3b..84ba7bc 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
@@ -23,15 +23,13 @@
      *
      * Generated from protobuf field <code>optional bool deprecated = 1 [default = false];</code>
      */
-    protected $deprecated = false;
-    private $has_deprecated = false;
+    protected $deprecated = null;
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
      * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
      */
     private $uninterpreted_option;
-    private $has_uninterpreted_option = false;
 
     /**
      * Constructor.
@@ -64,7 +62,17 @@
      */
     public function getDeprecated()
     {
-        return $this->deprecated;
+        return isset($this->deprecated) ? $this->deprecated : false;
+    }
+
+    public function hasDeprecated()
+    {
+        return isset($this->deprecated);
+    }
+
+    public function clearDeprecated()
+    {
+        unset($this->deprecated);
     }
 
     /**
@@ -81,16 +89,10 @@
     {
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
-        $this->has_deprecated = true;
 
         return $this;
     }
 
-    public function hasDeprecated()
-    {
-        return $this->has_deprecated;
-    }
-
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
@@ -113,15 +115,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
-        $this->has_uninterpreted_option = true;
 
         return $this;
     }
 
-    public function hasUninterpretedOption()
-    {
-        return $this->has_uninterpreted_option;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
index 00fbebe..b5e27c3 100644
--- a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
+++ b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
@@ -21,7 +21,6 @@
      * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
      */
     private $uninterpreted_option;
-    private $has_uninterpreted_option = false;
 
     /**
      * Constructor.
@@ -60,15 +59,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
-        $this->has_uninterpreted_option = true;
 
         return $this;
     }
 
-    public function hasUninterpretedOption()
-    {
-        return $this->has_uninterpreted_option;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
index b43d988..5c8823f 100644
--- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
@@ -20,26 +20,22 @@
     /**
      * Generated from protobuf field <code>optional string name = 1;</code>
      */
-    protected $name = '';
-    private $has_name = false;
+    protected $name = null;
     /**
      * Generated from protobuf field <code>optional int32 number = 3;</code>
      */
-    protected $number = 0;
-    private $has_number = false;
+    protected $number = null;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code>
      */
-    protected $label = 0;
-    private $has_label = false;
+    protected $label = null;
     /**
      * If type_name is set, this need not be set.  If both this and type_name
      * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
      *
      * Generated from protobuf field <code>optional .google.protobuf.FieldDescriptorProto.Type type = 5;</code>
      */
-    protected $type = 0;
-    private $has_type = false;
+    protected $type = null;
     /**
      * For message and enum types, this is the name of the type.  If the name
      * starts with a '.', it is fully-qualified.  Otherwise, C++-like scoping
@@ -49,16 +45,14 @@
      *
      * Generated from protobuf field <code>optional string type_name = 6;</code>
      */
-    protected $type_name = '';
-    private $has_type_name = false;
+    protected $type_name = null;
     /**
      * For extensions, this is the name of the type being extended.  It is
      * resolved in the same manner as type_name.
      *
      * Generated from protobuf field <code>optional string extendee = 2;</code>
      */
-    protected $extendee = '';
-    private $has_extendee = false;
+    protected $extendee = null;
     /**
      * For numeric types, contains the original text representation of the value.
      * For booleans, "true" or "false".
@@ -68,16 +62,14 @@
      *
      * Generated from protobuf field <code>optional string default_value = 7;</code>
      */
-    protected $default_value = '';
-    private $has_default_value = false;
+    protected $default_value = null;
     /**
      * If set, gives the index of a oneof in the containing type's oneof_decl
      * list.  This field is a member of that oneof.
      *
      * Generated from protobuf field <code>optional int32 oneof_index = 9;</code>
      */
-    protected $oneof_index = 0;
-    private $has_oneof_index = false;
+    protected $oneof_index = null;
     /**
      * JSON name of this field. The value is set by protocol compiler. If the
      * user has set a "json_name" option on this field, that option's value
@@ -86,13 +78,11 @@
      *
      * Generated from protobuf field <code>optional string json_name = 10;</code>
      */
-    protected $json_name = '';
-    private $has_json_name = false;
+    protected $json_name = null;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.FieldOptions options = 8;</code>
      */
     protected $options = null;
-    private $has_options = false;
     /**
      * If true, this is a proto3 "optional". When a proto3 field is optional, it
      * tracks presence regardless of field type.
@@ -115,8 +105,7 @@
      *
      * Generated from protobuf field <code>optional bool proto3_optional = 17;</code>
      */
-    protected $proto3_optional = false;
-    private $has_proto3_optional = false;
+    protected $proto3_optional = null;
 
     /**
      * Constructor.
@@ -186,7 +175,17 @@
      */
     public function getName()
     {
-        return $this->name;
+        return isset($this->name) ? $this->name : '';
+    }
+
+    public function hasName()
+    {
+        return isset($this->name);
+    }
+
+    public function clearName()
+    {
+        unset($this->name);
     }
 
     /**
@@ -198,23 +197,27 @@
     {
         GPBUtil::checkString($var, True);
         $this->name = $var;
-        $this->has_name = true;
 
         return $this;
     }
 
-    public function hasName()
-    {
-        return $this->has_name;
-    }
-
     /**
      * Generated from protobuf field <code>optional int32 number = 3;</code>
      * @return int
      */
     public function getNumber()
     {
-        return $this->number;
+        return isset($this->number) ? $this->number : 0;
+    }
+
+    public function hasNumber()
+    {
+        return isset($this->number);
+    }
+
+    public function clearNumber()
+    {
+        unset($this->number);
     }
 
     /**
@@ -226,23 +229,27 @@
     {
         GPBUtil::checkInt32($var);
         $this->number = $var;
-        $this->has_number = true;
 
         return $this;
     }
 
-    public function hasNumber()
-    {
-        return $this->has_number;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code>
      * @return int
      */
     public function getLabel()
     {
-        return $this->label;
+        return isset($this->label) ? $this->label : 0;
+    }
+
+    public function hasLabel()
+    {
+        return isset($this->label);
+    }
+
+    public function clearLabel()
+    {
+        unset($this->label);
     }
 
     /**
@@ -252,18 +259,12 @@
      */
     public function setLabel($var)
     {
-        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Label::class);
+        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto\Label::class);
         $this->label = $var;
-        $this->has_label = true;
 
         return $this;
     }
 
-    public function hasLabel()
-    {
-        return $this->has_label;
-    }
-
     /**
      * If type_name is set, this need not be set.  If both this and type_name
      * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
@@ -273,7 +274,17 @@
      */
     public function getType()
     {
-        return $this->type;
+        return isset($this->type) ? $this->type : 0;
+    }
+
+    public function hasType()
+    {
+        return isset($this->type);
+    }
+
+    public function clearType()
+    {
+        unset($this->type);
     }
 
     /**
@@ -286,18 +297,12 @@
      */
     public function setType($var)
     {
-        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Type::class);
+        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto\Type::class);
         $this->type = $var;
-        $this->has_type = true;
 
         return $this;
     }
 
-    public function hasType()
-    {
-        return $this->has_type;
-    }
-
     /**
      * For message and enum types, this is the name of the type.  If the name
      * starts with a '.', it is fully-qualified.  Otherwise, C++-like scoping
@@ -310,7 +315,17 @@
      */
     public function getTypeName()
     {
-        return $this->type_name;
+        return isset($this->type_name) ? $this->type_name : '';
+    }
+
+    public function hasTypeName()
+    {
+        return isset($this->type_name);
+    }
+
+    public function clearTypeName()
+    {
+        unset($this->type_name);
     }
 
     /**
@@ -328,16 +343,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->type_name = $var;
-        $this->has_type_name = true;
 
         return $this;
     }
 
-    public function hasTypeName()
-    {
-        return $this->has_type_name;
-    }
-
     /**
      * For extensions, this is the name of the type being extended.  It is
      * resolved in the same manner as type_name.
@@ -347,7 +356,17 @@
      */
     public function getExtendee()
     {
-        return $this->extendee;
+        return isset($this->extendee) ? $this->extendee : '';
+    }
+
+    public function hasExtendee()
+    {
+        return isset($this->extendee);
+    }
+
+    public function clearExtendee()
+    {
+        unset($this->extendee);
     }
 
     /**
@@ -362,16 +381,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->extendee = $var;
-        $this->has_extendee = true;
 
         return $this;
     }
 
-    public function hasExtendee()
-    {
-        return $this->has_extendee;
-    }
-
     /**
      * For numeric types, contains the original text representation of the value.
      * For booleans, "true" or "false".
@@ -384,7 +397,17 @@
      */
     public function getDefaultValue()
     {
-        return $this->default_value;
+        return isset($this->default_value) ? $this->default_value : '';
+    }
+
+    public function hasDefaultValue()
+    {
+        return isset($this->default_value);
+    }
+
+    public function clearDefaultValue()
+    {
+        unset($this->default_value);
     }
 
     /**
@@ -402,16 +425,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->default_value = $var;
-        $this->has_default_value = true;
 
         return $this;
     }
 
-    public function hasDefaultValue()
-    {
-        return $this->has_default_value;
-    }
-
     /**
      * If set, gives the index of a oneof in the containing type's oneof_decl
      * list.  This field is a member of that oneof.
@@ -421,7 +438,17 @@
      */
     public function getOneofIndex()
     {
-        return $this->oneof_index;
+        return isset($this->oneof_index) ? $this->oneof_index : 0;
+    }
+
+    public function hasOneofIndex()
+    {
+        return isset($this->oneof_index);
+    }
+
+    public function clearOneofIndex()
+    {
+        unset($this->oneof_index);
     }
 
     /**
@@ -436,16 +463,10 @@
     {
         GPBUtil::checkInt32($var);
         $this->oneof_index = $var;
-        $this->has_oneof_index = true;
 
         return $this;
     }
 
-    public function hasOneofIndex()
-    {
-        return $this->has_oneof_index;
-    }
-
     /**
      * JSON name of this field. The value is set by protocol compiler. If the
      * user has set a "json_name" option on this field, that option's value
@@ -457,7 +478,17 @@
      */
     public function getJsonName()
     {
-        return $this->json_name;
+        return isset($this->json_name) ? $this->json_name : '';
+    }
+
+    public function hasJsonName()
+    {
+        return isset($this->json_name);
+    }
+
+    public function clearJsonName()
+    {
+        unset($this->json_name);
     }
 
     /**
@@ -474,23 +505,27 @@
     {
         GPBUtil::checkString($var, True);
         $this->json_name = $var;
-        $this->has_json_name = true;
 
         return $this;
     }
 
-    public function hasJsonName()
-    {
-        return $this->has_json_name;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.FieldOptions options = 8;</code>
      * @return \Google\Protobuf\Internal\FieldOptions
      */
     public function getOptions()
     {
-        return $this->options;
+        return isset($this->options) ? $this->options : null;
+    }
+
+    public function hasOptions()
+    {
+        return isset($this->options);
+    }
+
+    public function clearOptions()
+    {
+        unset($this->options);
     }
 
     /**
@@ -502,16 +537,10 @@
     {
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class);
         $this->options = $var;
-        $this->has_options = true;
 
         return $this;
     }
 
-    public function hasOptions()
-    {
-        return $this->has_options;
-    }
-
     /**
      * If true, this is a proto3 "optional". When a proto3 field is optional, it
      * tracks presence regardless of field type.
@@ -537,7 +566,17 @@
      */
     public function getProto3Optional()
     {
-        return $this->proto3_optional;
+        return isset($this->proto3_optional) ? $this->proto3_optional : false;
+    }
+
+    public function hasProto3Optional()
+    {
+        return isset($this->proto3_optional);
+    }
+
+    public function clearProto3Optional()
+    {
+        unset($this->proto3_optional);
     }
 
     /**
@@ -568,15 +607,9 @@
     {
         GPBUtil::checkBool($var);
         $this->proto3_optional = $var;
-        $this->has_proto3_optional = true;
 
         return $this;
     }
 
-    public function hasProto3Optional()
-    {
-        return $this->has_proto3_optional;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php
index 2ccc418..c6c63a9 100644
--- a/php/src/Google/Protobuf/Internal/FieldOptions.php
+++ b/php/src/Google/Protobuf/Internal/FieldOptions.php
@@ -23,8 +23,7 @@
      *
      * Generated from protobuf field <code>optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];</code>
      */
-    protected $ctype = 0;
-    private $has_ctype = false;
+    protected $ctype = null;
     /**
      * The packed option can be enabled for repeated primitive fields to enable
      * a more efficient representation on the wire. Rather than repeatedly
@@ -34,8 +33,7 @@
      *
      * Generated from protobuf field <code>optional bool packed = 2;</code>
      */
-    protected $packed = false;
-    private $has_packed = false;
+    protected $packed = null;
     /**
      * The jstype option determines the JavaScript type used for values of the
      * field.  The option is permitted only for 64 bit integral and fixed types
@@ -50,8 +48,7 @@
      *
      * Generated from protobuf field <code>optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];</code>
      */
-    protected $jstype = 0;
-    private $has_jstype = false;
+    protected $jstype = null;
     /**
      * Should this field be parsed lazily?  Lazy applies only to message-type
      * fields.  It means that when the outer message is initially parsed, the
@@ -80,8 +77,7 @@
      *
      * Generated from protobuf field <code>optional bool lazy = 5 [default = false];</code>
      */
-    protected $lazy = false;
-    private $has_lazy = false;
+    protected $lazy = null;
     /**
      * Is this field deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
@@ -90,22 +86,19 @@
      *
      * Generated from protobuf field <code>optional bool deprecated = 3 [default = false];</code>
      */
-    protected $deprecated = false;
-    private $has_deprecated = false;
+    protected $deprecated = null;
     /**
      * For Google-internal migration only. Do not use.
      *
      * Generated from protobuf field <code>optional bool weak = 10 [default = false];</code>
      */
-    protected $weak = false;
-    private $has_weak = false;
+    protected $weak = null;
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
      * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
      */
     private $uninterpreted_option;
-    private $has_uninterpreted_option = false;
 
     /**
      * Constructor.
@@ -187,7 +180,17 @@
      */
     public function getCtype()
     {
-        return $this->ctype;
+        return isset($this->ctype) ? $this->ctype : 0;
+    }
+
+    public function hasCtype()
+    {
+        return isset($this->ctype);
+    }
+
+    public function clearCtype()
+    {
+        unset($this->ctype);
     }
 
     /**
@@ -202,18 +205,12 @@
      */
     public function setCtype($var)
     {
-        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_CType::class);
+        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions\CType::class);
         $this->ctype = $var;
-        $this->has_ctype = true;
 
         return $this;
     }
 
-    public function hasCtype()
-    {
-        return $this->has_ctype;
-    }
-
     /**
      * The packed option can be enabled for repeated primitive fields to enable
      * a more efficient representation on the wire. Rather than repeatedly
@@ -226,7 +223,17 @@
      */
     public function getPacked()
     {
-        return $this->packed;
+        return isset($this->packed) ? $this->packed : false;
+    }
+
+    public function hasPacked()
+    {
+        return isset($this->packed);
+    }
+
+    public function clearPacked()
+    {
+        unset($this->packed);
     }
 
     /**
@@ -244,16 +251,10 @@
     {
         GPBUtil::checkBool($var);
         $this->packed = $var;
-        $this->has_packed = true;
 
         return $this;
     }
 
-    public function hasPacked()
-    {
-        return $this->has_packed;
-    }
-
     /**
      * The jstype option determines the JavaScript type used for values of the
      * field.  The option is permitted only for 64 bit integral and fixed types
@@ -271,7 +272,17 @@
      */
     public function getJstype()
     {
-        return $this->jstype;
+        return isset($this->jstype) ? $this->jstype : 0;
+    }
+
+    public function hasJstype()
+    {
+        return isset($this->jstype);
+    }
+
+    public function clearJstype()
+    {
+        unset($this->jstype);
     }
 
     /**
@@ -292,18 +303,12 @@
      */
     public function setJstype($var)
     {
-        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_JSType::class);
+        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions\JSType::class);
         $this->jstype = $var;
-        $this->has_jstype = true;
 
         return $this;
     }
 
-    public function hasJstype()
-    {
-        return $this->has_jstype;
-    }
-
     /**
      * Should this field be parsed lazily?  Lazy applies only to message-type
      * fields.  It means that when the outer message is initially parsed, the
@@ -335,7 +340,17 @@
      */
     public function getLazy()
     {
-        return $this->lazy;
+        return isset($this->lazy) ? $this->lazy : false;
+    }
+
+    public function hasLazy()
+    {
+        return isset($this->lazy);
+    }
+
+    public function clearLazy()
+    {
+        unset($this->lazy);
     }
 
     /**
@@ -372,16 +387,10 @@
     {
         GPBUtil::checkBool($var);
         $this->lazy = $var;
-        $this->has_lazy = true;
 
         return $this;
     }
 
-    public function hasLazy()
-    {
-        return $this->has_lazy;
-    }
-
     /**
      * Is this field deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
@@ -393,7 +402,17 @@
      */
     public function getDeprecated()
     {
-        return $this->deprecated;
+        return isset($this->deprecated) ? $this->deprecated : false;
+    }
+
+    public function hasDeprecated()
+    {
+        return isset($this->deprecated);
+    }
+
+    public function clearDeprecated()
+    {
+        unset($this->deprecated);
     }
 
     /**
@@ -410,16 +429,10 @@
     {
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
-        $this->has_deprecated = true;
 
         return $this;
     }
 
-    public function hasDeprecated()
-    {
-        return $this->has_deprecated;
-    }
-
     /**
      * For Google-internal migration only. Do not use.
      *
@@ -428,7 +441,17 @@
      */
     public function getWeak()
     {
-        return $this->weak;
+        return isset($this->weak) ? $this->weak : false;
+    }
+
+    public function hasWeak()
+    {
+        return isset($this->weak);
+    }
+
+    public function clearWeak()
+    {
+        unset($this->weak);
     }
 
     /**
@@ -442,16 +465,10 @@
     {
         GPBUtil::checkBool($var);
         $this->weak = $var;
-        $this->has_weak = true;
 
         return $this;
     }
 
-    public function hasWeak()
-    {
-        return $this->has_weak;
-    }
-
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
@@ -474,15 +491,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
-        $this->has_uninterpreted_option = true;
 
         return $this;
     }
 
-    public function hasUninterpretedOption()
-    {
-        return $this->has_uninterpreted_option;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
index c9e3648..96e2c6a 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
@@ -22,29 +22,25 @@
      *
      * Generated from protobuf field <code>optional string name = 1;</code>
      */
-    protected $name = '';
-    private $has_name = false;
+    protected $name = null;
     /**
      * e.g. "foo", "foo.bar", etc.
      *
      * Generated from protobuf field <code>optional string package = 2;</code>
      */
-    protected $package = '';
-    private $has_package = false;
+    protected $package = null;
     /**
      * Names of files imported by this file.
      *
      * Generated from protobuf field <code>repeated string dependency = 3;</code>
      */
     private $dependency;
-    private $has_dependency = false;
     /**
      * Indexes of the public imported files in the dependency list above.
      *
      * Generated from protobuf field <code>repeated int32 public_dependency = 10;</code>
      */
     private $public_dependency;
-    private $has_public_dependency = false;
     /**
      * Indexes of the weak imported files in the dependency list.
      * For Google-internal migration only. Do not use.
@@ -52,34 +48,28 @@
      * Generated from protobuf field <code>repeated int32 weak_dependency = 11;</code>
      */
     private $weak_dependency;
-    private $has_weak_dependency = false;
     /**
      * All top-level definitions in this file.
      *
      * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto message_type = 4;</code>
      */
     private $message_type;
-    private $has_message_type = false;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code>
      */
     private $enum_type;
-    private $has_enum_type = false;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code>
      */
     private $service;
-    private $has_service = false;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code>
      */
     private $extension;
-    private $has_extension = false;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.FileOptions options = 8;</code>
      */
     protected $options = null;
-    private $has_options = false;
     /**
      * This field contains optional information about the original source code.
      * You may safely remove this entire field without harming runtime
@@ -89,15 +79,13 @@
      * Generated from protobuf field <code>optional .google.protobuf.SourceCodeInfo source_code_info = 9;</code>
      */
     protected $source_code_info = null;
-    private $has_source_code_info = false;
     /**
      * The syntax of the proto file.
      * The supported values are "proto2" and "proto3".
      *
      * Generated from protobuf field <code>optional string syntax = 12;</code>
      */
-    protected $syntax = '';
-    private $has_syntax = false;
+    protected $syntax = null;
 
     /**
      * Constructor.
@@ -145,7 +133,17 @@
      */
     public function getName()
     {
-        return $this->name;
+        return isset($this->name) ? $this->name : '';
+    }
+
+    public function hasName()
+    {
+        return isset($this->name);
+    }
+
+    public function clearName()
+    {
+        unset($this->name);
     }
 
     /**
@@ -159,16 +157,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->name = $var;
-        $this->has_name = true;
 
         return $this;
     }
 
-    public function hasName()
-    {
-        return $this->has_name;
-    }
-
     /**
      * e.g. "foo", "foo.bar", etc.
      *
@@ -177,7 +169,17 @@
      */
     public function getPackage()
     {
-        return $this->package;
+        return isset($this->package) ? $this->package : '';
+    }
+
+    public function hasPackage()
+    {
+        return isset($this->package);
+    }
+
+    public function clearPackage()
+    {
+        unset($this->package);
     }
 
     /**
@@ -191,16 +193,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->package = $var;
-        $this->has_package = true;
 
         return $this;
     }
 
-    public function hasPackage()
-    {
-        return $this->has_package;
-    }
-
     /**
      * Names of files imported by this file.
      *
@@ -223,16 +219,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
         $this->dependency = $arr;
-        $this->has_dependency = true;
 
         return $this;
     }
 
-    public function hasDependency()
-    {
-        return $this->has_dependency;
-    }
-
     /**
      * Indexes of the public imported files in the dependency list above.
      *
@@ -255,16 +245,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
         $this->public_dependency = $arr;
-        $this->has_public_dependency = true;
 
         return $this;
     }
 
-    public function hasPublicDependency()
-    {
-        return $this->has_public_dependency;
-    }
-
     /**
      * Indexes of the weak imported files in the dependency list.
      * For Google-internal migration only. Do not use.
@@ -289,16 +273,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
         $this->weak_dependency = $arr;
-        $this->has_weak_dependency = true;
 
         return $this;
     }
 
-    public function hasWeakDependency()
-    {
-        return $this->has_weak_dependency;
-    }
-
     /**
      * All top-level definitions in this file.
      *
@@ -321,16 +299,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class);
         $this->message_type = $arr;
-        $this->has_message_type = true;
 
         return $this;
     }
 
-    public function hasMessageType()
-    {
-        return $this->has_message_type;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -349,16 +321,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class);
         $this->enum_type = $arr;
-        $this->has_enum_type = true;
 
         return $this;
     }
 
-    public function hasEnumType()
-    {
-        return $this->has_enum_type;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -377,16 +343,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class);
         $this->service = $arr;
-        $this->has_service = true;
 
         return $this;
     }
 
-    public function hasService()
-    {
-        return $this->has_service;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -405,23 +365,27 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
         $this->extension = $arr;
-        $this->has_extension = true;
 
         return $this;
     }
 
-    public function hasExtension()
-    {
-        return $this->has_extension;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.FileOptions options = 8;</code>
      * @return \Google\Protobuf\Internal\FileOptions
      */
     public function getOptions()
     {
-        return $this->options;
+        return isset($this->options) ? $this->options : null;
+    }
+
+    public function hasOptions()
+    {
+        return isset($this->options);
+    }
+
+    public function clearOptions()
+    {
+        unset($this->options);
     }
 
     /**
@@ -433,16 +397,10 @@
     {
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class);
         $this->options = $var;
-        $this->has_options = true;
 
         return $this;
     }
 
-    public function hasOptions()
-    {
-        return $this->has_options;
-    }
-
     /**
      * This field contains optional information about the original source code.
      * You may safely remove this entire field without harming runtime
@@ -454,7 +412,17 @@
      */
     public function getSourceCodeInfo()
     {
-        return $this->source_code_info;
+        return isset($this->source_code_info) ? $this->source_code_info : null;
+    }
+
+    public function hasSourceCodeInfo()
+    {
+        return isset($this->source_code_info);
+    }
+
+    public function clearSourceCodeInfo()
+    {
+        unset($this->source_code_info);
     }
 
     /**
@@ -471,16 +439,10 @@
     {
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class);
         $this->source_code_info = $var;
-        $this->has_source_code_info = true;
 
         return $this;
     }
 
-    public function hasSourceCodeInfo()
-    {
-        return $this->has_source_code_info;
-    }
-
     /**
      * The syntax of the proto file.
      * The supported values are "proto2" and "proto3".
@@ -490,7 +452,17 @@
      */
     public function getSyntax()
     {
-        return $this->syntax;
+        return isset($this->syntax) ? $this->syntax : '';
+    }
+
+    public function hasSyntax()
+    {
+        return isset($this->syntax);
+    }
+
+    public function clearSyntax()
+    {
+        unset($this->syntax);
     }
 
     /**
@@ -505,15 +477,9 @@
     {
         GPBUtil::checkString($var, True);
         $this->syntax = $var;
-        $this->has_syntax = true;
 
         return $this;
     }
 
-    public function hasSyntax()
-    {
-        return $this->has_syntax;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
index 9907b17..794e634 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
@@ -22,7 +22,6 @@
      * Generated from protobuf field <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code>
      */
     private $file;
-    private $has_file = false;
 
     /**
      * Constructor.
@@ -56,15 +55,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class);
         $this->file = $arr;
-        $this->has_file = true;
 
         return $this;
     }
 
-    public function hasFile()
-    {
-        return $this->has_file;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php
index 892a6a8..f415b07 100644
--- a/php/src/Google/Protobuf/Internal/FileOptions.php
+++ b/php/src/Google/Protobuf/Internal/FileOptions.php
@@ -23,8 +23,7 @@
      *
      * Generated from protobuf field <code>optional string java_package = 1;</code>
      */
-    protected $java_package = '';
-    private $has_java_package = false;
+    protected $java_package = null;
     /**
      * If set, all the classes from the .proto file are wrapped in a single
      * outer class with the given name.  This applies to both Proto1
@@ -34,8 +33,7 @@
      *
      * Generated from protobuf field <code>optional string java_outer_classname = 8;</code>
      */
-    protected $java_outer_classname = '';
-    private $has_java_outer_classname = false;
+    protected $java_outer_classname = null;
     /**
      * If set true, then the Java code generator will generate a separate .java
      * file for each top-level message, enum, and service defined in the .proto
@@ -46,15 +44,13 @@
      *
      * Generated from protobuf field <code>optional bool java_multiple_files = 10 [default = false];</code>
      */
-    protected $java_multiple_files = false;
-    private $has_java_multiple_files = false;
+    protected $java_multiple_files = null;
     /**
      * This option does nothing.
      *
      * Generated from protobuf field <code>optional bool java_generate_equals_and_hash = 20 [deprecated = true];</code>
      */
-    protected $java_generate_equals_and_hash = false;
-    private $has_java_generate_equals_and_hash = false;
+    protected $java_generate_equals_and_hash = null;
     /**
      * If set true, then the Java2 code generator will generate code that
      * throws an exception whenever an attempt is made to assign a non-UTF-8
@@ -65,13 +61,11 @@
      *
      * Generated from protobuf field <code>optional bool java_string_check_utf8 = 27 [default = false];</code>
      */
-    protected $java_string_check_utf8 = false;
-    private $has_java_string_check_utf8 = false;
+    protected $java_string_check_utf8 = null;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code>
      */
-    protected $optimize_for = 0;
-    private $has_optimize_for = false;
+    protected $optimize_for = null;
     /**
      * Sets the Go package where structs generated from this .proto will be
      * placed. If omitted, the Go package will be derived from the following:
@@ -81,8 +75,7 @@
      *
      * Generated from protobuf field <code>optional string go_package = 11;</code>
      */
-    protected $go_package = '';
-    private $has_go_package = false;
+    protected $go_package = null;
     /**
      * Should generic services be generated in each language?  "Generic" services
      * are not specific to any particular RPC system.  They are generated by the
@@ -96,23 +89,19 @@
      *
      * Generated from protobuf field <code>optional bool cc_generic_services = 16 [default = false];</code>
      */
-    protected $cc_generic_services = false;
-    private $has_cc_generic_services = false;
+    protected $cc_generic_services = null;
     /**
      * Generated from protobuf field <code>optional bool java_generic_services = 17 [default = false];</code>
      */
-    protected $java_generic_services = false;
-    private $has_java_generic_services = false;
+    protected $java_generic_services = null;
     /**
      * Generated from protobuf field <code>optional bool py_generic_services = 18 [default = false];</code>
      */
-    protected $py_generic_services = false;
-    private $has_py_generic_services = false;
+    protected $py_generic_services = null;
     /**
      * Generated from protobuf field <code>optional bool php_generic_services = 42 [default = false];</code>
      */
-    protected $php_generic_services = false;
-    private $has_php_generic_services = false;
+    protected $php_generic_services = null;
     /**
      * Is this file deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
@@ -121,31 +110,27 @@
      *
      * Generated from protobuf field <code>optional bool deprecated = 23 [default = false];</code>
      */
-    protected $deprecated = false;
-    private $has_deprecated = false;
+    protected $deprecated = null;
     /**
      * Enables the use of arenas for the proto messages in this file. This applies
      * only to generated classes for C++.
      *
      * Generated from protobuf field <code>optional bool cc_enable_arenas = 31 [default = true];</code>
      */
-    protected $cc_enable_arenas = false;
-    private $has_cc_enable_arenas = false;
+    protected $cc_enable_arenas = null;
     /**
      * Sets the objective c class prefix which is prepended to all objective c
      * generated classes from this .proto. There is no default.
      *
      * Generated from protobuf field <code>optional string objc_class_prefix = 36;</code>
      */
-    protected $objc_class_prefix = '';
-    private $has_objc_class_prefix = false;
+    protected $objc_class_prefix = null;
     /**
      * Namespace for generated classes; defaults to the package.
      *
      * Generated from protobuf field <code>optional string csharp_namespace = 37;</code>
      */
-    protected $csharp_namespace = '';
-    private $has_csharp_namespace = false;
+    protected $csharp_namespace = null;
     /**
      * By default Swift generators will take the proto package and CamelCase it
      * replacing '.' with underscore and use that to prefix the types/symbols
@@ -154,16 +139,14 @@
      *
      * Generated from protobuf field <code>optional string swift_prefix = 39;</code>
      */
-    protected $swift_prefix = '';
-    private $has_swift_prefix = false;
+    protected $swift_prefix = null;
     /**
      * Sets the php class prefix which is prepended to all php generated classes
      * from this .proto. Default is empty.
      *
      * Generated from protobuf field <code>optional string php_class_prefix = 40;</code>
      */
-    protected $php_class_prefix = '';
-    private $has_php_class_prefix = false;
+    protected $php_class_prefix = null;
     /**
      * Use this option to change the namespace of php generated classes. Default
      * is empty. When this option is empty, the package name will be used for
@@ -171,8 +154,7 @@
      *
      * Generated from protobuf field <code>optional string php_namespace = 41;</code>
      */
-    protected $php_namespace = '';
-    private $has_php_namespace = false;
+    protected $php_namespace = null;
     /**
      * Use this option to change the namespace of php generated metadata classes.
      * Default is empty. When this option is empty, the proto file name will be
@@ -180,8 +162,7 @@
      *
      * Generated from protobuf field <code>optional string php_metadata_namespace = 44;</code>
      */
-    protected $php_metadata_namespace = '';
-    private $has_php_metadata_namespace = false;
+    protected $php_metadata_namespace = null;
     /**
      * Use this option to change the package of ruby generated classes. Default
      * is empty. When this option is not set, the package name will be used for
@@ -189,8 +170,7 @@
      *
      * Generated from protobuf field <code>optional string ruby_package = 45;</code>
      */
-    protected $ruby_package = '';
-    private $has_ruby_package = false;
+    protected $ruby_package = null;
     /**
      * The parser stores options it doesn't recognize here.
      * See the documentation for the "Options" section above.
@@ -198,7 +178,6 @@
      * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
      */
     private $uninterpreted_option;
-    private $has_uninterpreted_option = false;
 
     /**
      * Constructor.
@@ -307,7 +286,17 @@
      */
     public function getJavaPackage()
     {
-        return $this->java_package;
+        return isset($this->java_package) ? $this->java_package : '';
+    }
+
+    public function hasJavaPackage()
+    {
+        return isset($this->java_package);
+    }
+
+    public function clearJavaPackage()
+    {
+        unset($this->java_package);
     }
 
     /**
@@ -324,16 +313,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->java_package = $var;
-        $this->has_java_package = true;
 
         return $this;
     }
 
-    public function hasJavaPackage()
-    {
-        return $this->has_java_package;
-    }
-
     /**
      * If set, all the classes from the .proto file are wrapped in a single
      * outer class with the given name.  This applies to both Proto1
@@ -346,7 +329,17 @@
      */
     public function getJavaOuterClassname()
     {
-        return $this->java_outer_classname;
+        return isset($this->java_outer_classname) ? $this->java_outer_classname : '';
+    }
+
+    public function hasJavaOuterClassname()
+    {
+        return isset($this->java_outer_classname);
+    }
+
+    public function clearJavaOuterClassname()
+    {
+        unset($this->java_outer_classname);
     }
 
     /**
@@ -364,16 +357,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->java_outer_classname = $var;
-        $this->has_java_outer_classname = true;
 
         return $this;
     }
 
-    public function hasJavaOuterClassname()
-    {
-        return $this->has_java_outer_classname;
-    }
-
     /**
      * If set true, then the Java code generator will generate a separate .java
      * file for each top-level message, enum, and service defined in the .proto
@@ -387,7 +374,17 @@
      */
     public function getJavaMultipleFiles()
     {
-        return $this->java_multiple_files;
+        return isset($this->java_multiple_files) ? $this->java_multiple_files : false;
+    }
+
+    public function hasJavaMultipleFiles()
+    {
+        return isset($this->java_multiple_files);
+    }
+
+    public function clearJavaMultipleFiles()
+    {
+        unset($this->java_multiple_files);
     }
 
     /**
@@ -406,16 +403,10 @@
     {
         GPBUtil::checkBool($var);
         $this->java_multiple_files = $var;
-        $this->has_java_multiple_files = true;
 
         return $this;
     }
 
-    public function hasJavaMultipleFiles()
-    {
-        return $this->has_java_multiple_files;
-    }
-
     /**
      * This option does nothing.
      *
@@ -424,7 +415,17 @@
      */
     public function getJavaGenerateEqualsAndHash()
     {
-        return $this->java_generate_equals_and_hash;
+        return isset($this->java_generate_equals_and_hash) ? $this->java_generate_equals_and_hash : false;
+    }
+
+    public function hasJavaGenerateEqualsAndHash()
+    {
+        return isset($this->java_generate_equals_and_hash);
+    }
+
+    public function clearJavaGenerateEqualsAndHash()
+    {
+        unset($this->java_generate_equals_and_hash);
     }
 
     /**
@@ -438,16 +439,10 @@
     {
         GPBUtil::checkBool($var);
         $this->java_generate_equals_and_hash = $var;
-        $this->has_java_generate_equals_and_hash = true;
 
         return $this;
     }
 
-    public function hasJavaGenerateEqualsAndHash()
-    {
-        return $this->has_java_generate_equals_and_hash;
-    }
-
     /**
      * If set true, then the Java2 code generator will generate code that
      * throws an exception whenever an attempt is made to assign a non-UTF-8
@@ -461,7 +456,17 @@
      */
     public function getJavaStringCheckUtf8()
     {
-        return $this->java_string_check_utf8;
+        return isset($this->java_string_check_utf8) ? $this->java_string_check_utf8 : false;
+    }
+
+    public function hasJavaStringCheckUtf8()
+    {
+        return isset($this->java_string_check_utf8);
+    }
+
+    public function clearJavaStringCheckUtf8()
+    {
+        unset($this->java_string_check_utf8);
     }
 
     /**
@@ -480,23 +485,27 @@
     {
         GPBUtil::checkBool($var);
         $this->java_string_check_utf8 = $var;
-        $this->has_java_string_check_utf8 = true;
 
         return $this;
     }
 
-    public function hasJavaStringCheckUtf8()
-    {
-        return $this->has_java_string_check_utf8;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code>
      * @return int
      */
     public function getOptimizeFor()
     {
-        return $this->optimize_for;
+        return isset($this->optimize_for) ? $this->optimize_for : 0;
+    }
+
+    public function hasOptimizeFor()
+    {
+        return isset($this->optimize_for);
+    }
+
+    public function clearOptimizeFor()
+    {
+        unset($this->optimize_for);
     }
 
     /**
@@ -506,18 +515,12 @@
      */
     public function setOptimizeFor($var)
     {
-        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions_OptimizeMode::class);
+        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions\OptimizeMode::class);
         $this->optimize_for = $var;
-        $this->has_optimize_for = true;
 
         return $this;
     }
 
-    public function hasOptimizeFor()
-    {
-        return $this->has_optimize_for;
-    }
-
     /**
      * Sets the Go package where structs generated from this .proto will be
      * placed. If omitted, the Go package will be derived from the following:
@@ -530,7 +533,17 @@
      */
     public function getGoPackage()
     {
-        return $this->go_package;
+        return isset($this->go_package) ? $this->go_package : '';
+    }
+
+    public function hasGoPackage()
+    {
+        return isset($this->go_package);
+    }
+
+    public function clearGoPackage()
+    {
+        unset($this->go_package);
     }
 
     /**
@@ -548,16 +561,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->go_package = $var;
-        $this->has_go_package = true;
 
         return $this;
     }
 
-    public function hasGoPackage()
-    {
-        return $this->has_go_package;
-    }
-
     /**
      * Should generic services be generated in each language?  "Generic" services
      * are not specific to any particular RPC system.  They are generated by the
@@ -574,7 +581,17 @@
      */
     public function getCcGenericServices()
     {
-        return $this->cc_generic_services;
+        return isset($this->cc_generic_services) ? $this->cc_generic_services : false;
+    }
+
+    public function hasCcGenericServices()
+    {
+        return isset($this->cc_generic_services);
+    }
+
+    public function clearCcGenericServices()
+    {
+        unset($this->cc_generic_services);
     }
 
     /**
@@ -596,23 +613,27 @@
     {
         GPBUtil::checkBool($var);
         $this->cc_generic_services = $var;
-        $this->has_cc_generic_services = true;
 
         return $this;
     }
 
-    public function hasCcGenericServices()
-    {
-        return $this->has_cc_generic_services;
-    }
-
     /**
      * Generated from protobuf field <code>optional bool java_generic_services = 17 [default = false];</code>
      * @return bool
      */
     public function getJavaGenericServices()
     {
-        return $this->java_generic_services;
+        return isset($this->java_generic_services) ? $this->java_generic_services : false;
+    }
+
+    public function hasJavaGenericServices()
+    {
+        return isset($this->java_generic_services);
+    }
+
+    public function clearJavaGenericServices()
+    {
+        unset($this->java_generic_services);
     }
 
     /**
@@ -624,23 +645,27 @@
     {
         GPBUtil::checkBool($var);
         $this->java_generic_services = $var;
-        $this->has_java_generic_services = true;
 
         return $this;
     }
 
-    public function hasJavaGenericServices()
-    {
-        return $this->has_java_generic_services;
-    }
-
     /**
      * Generated from protobuf field <code>optional bool py_generic_services = 18 [default = false];</code>
      * @return bool
      */
     public function getPyGenericServices()
     {
-        return $this->py_generic_services;
+        return isset($this->py_generic_services) ? $this->py_generic_services : false;
+    }
+
+    public function hasPyGenericServices()
+    {
+        return isset($this->py_generic_services);
+    }
+
+    public function clearPyGenericServices()
+    {
+        unset($this->py_generic_services);
     }
 
     /**
@@ -652,23 +677,27 @@
     {
         GPBUtil::checkBool($var);
         $this->py_generic_services = $var;
-        $this->has_py_generic_services = true;
 
         return $this;
     }
 
-    public function hasPyGenericServices()
-    {
-        return $this->has_py_generic_services;
-    }
-
     /**
      * Generated from protobuf field <code>optional bool php_generic_services = 42 [default = false];</code>
      * @return bool
      */
     public function getPhpGenericServices()
     {
-        return $this->php_generic_services;
+        return isset($this->php_generic_services) ? $this->php_generic_services : false;
+    }
+
+    public function hasPhpGenericServices()
+    {
+        return isset($this->php_generic_services);
+    }
+
+    public function clearPhpGenericServices()
+    {
+        unset($this->php_generic_services);
     }
 
     /**
@@ -680,16 +709,10 @@
     {
         GPBUtil::checkBool($var);
         $this->php_generic_services = $var;
-        $this->has_php_generic_services = true;
 
         return $this;
     }
 
-    public function hasPhpGenericServices()
-    {
-        return $this->has_php_generic_services;
-    }
-
     /**
      * Is this file deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
@@ -701,7 +724,17 @@
      */
     public function getDeprecated()
     {
-        return $this->deprecated;
+        return isset($this->deprecated) ? $this->deprecated : false;
+    }
+
+    public function hasDeprecated()
+    {
+        return isset($this->deprecated);
+    }
+
+    public function clearDeprecated()
+    {
+        unset($this->deprecated);
     }
 
     /**
@@ -718,16 +751,10 @@
     {
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
-        $this->has_deprecated = true;
 
         return $this;
     }
 
-    public function hasDeprecated()
-    {
-        return $this->has_deprecated;
-    }
-
     /**
      * Enables the use of arenas for the proto messages in this file. This applies
      * only to generated classes for C++.
@@ -737,7 +764,17 @@
      */
     public function getCcEnableArenas()
     {
-        return $this->cc_enable_arenas;
+        return isset($this->cc_enable_arenas) ? $this->cc_enable_arenas : false;
+    }
+
+    public function hasCcEnableArenas()
+    {
+        return isset($this->cc_enable_arenas);
+    }
+
+    public function clearCcEnableArenas()
+    {
+        unset($this->cc_enable_arenas);
     }
 
     /**
@@ -752,16 +789,10 @@
     {
         GPBUtil::checkBool($var);
         $this->cc_enable_arenas = $var;
-        $this->has_cc_enable_arenas = true;
 
         return $this;
     }
 
-    public function hasCcEnableArenas()
-    {
-        return $this->has_cc_enable_arenas;
-    }
-
     /**
      * Sets the objective c class prefix which is prepended to all objective c
      * generated classes from this .proto. There is no default.
@@ -771,7 +802,17 @@
      */
     public function getObjcClassPrefix()
     {
-        return $this->objc_class_prefix;
+        return isset($this->objc_class_prefix) ? $this->objc_class_prefix : '';
+    }
+
+    public function hasObjcClassPrefix()
+    {
+        return isset($this->objc_class_prefix);
+    }
+
+    public function clearObjcClassPrefix()
+    {
+        unset($this->objc_class_prefix);
     }
 
     /**
@@ -786,16 +827,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->objc_class_prefix = $var;
-        $this->has_objc_class_prefix = true;
 
         return $this;
     }
 
-    public function hasObjcClassPrefix()
-    {
-        return $this->has_objc_class_prefix;
-    }
-
     /**
      * Namespace for generated classes; defaults to the package.
      *
@@ -804,7 +839,17 @@
      */
     public function getCsharpNamespace()
     {
-        return $this->csharp_namespace;
+        return isset($this->csharp_namespace) ? $this->csharp_namespace : '';
+    }
+
+    public function hasCsharpNamespace()
+    {
+        return isset($this->csharp_namespace);
+    }
+
+    public function clearCsharpNamespace()
+    {
+        unset($this->csharp_namespace);
     }
 
     /**
@@ -818,16 +863,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->csharp_namespace = $var;
-        $this->has_csharp_namespace = true;
 
         return $this;
     }
 
-    public function hasCsharpNamespace()
-    {
-        return $this->has_csharp_namespace;
-    }
-
     /**
      * By default Swift generators will take the proto package and CamelCase it
      * replacing '.' with underscore and use that to prefix the types/symbols
@@ -839,7 +878,17 @@
      */
     public function getSwiftPrefix()
     {
-        return $this->swift_prefix;
+        return isset($this->swift_prefix) ? $this->swift_prefix : '';
+    }
+
+    public function hasSwiftPrefix()
+    {
+        return isset($this->swift_prefix);
+    }
+
+    public function clearSwiftPrefix()
+    {
+        unset($this->swift_prefix);
     }
 
     /**
@@ -856,16 +905,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->swift_prefix = $var;
-        $this->has_swift_prefix = true;
 
         return $this;
     }
 
-    public function hasSwiftPrefix()
-    {
-        return $this->has_swift_prefix;
-    }
-
     /**
      * Sets the php class prefix which is prepended to all php generated classes
      * from this .proto. Default is empty.
@@ -875,7 +918,17 @@
      */
     public function getPhpClassPrefix()
     {
-        return $this->php_class_prefix;
+        return isset($this->php_class_prefix) ? $this->php_class_prefix : '';
+    }
+
+    public function hasPhpClassPrefix()
+    {
+        return isset($this->php_class_prefix);
+    }
+
+    public function clearPhpClassPrefix()
+    {
+        unset($this->php_class_prefix);
     }
 
     /**
@@ -890,16 +943,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->php_class_prefix = $var;
-        $this->has_php_class_prefix = true;
 
         return $this;
     }
 
-    public function hasPhpClassPrefix()
-    {
-        return $this->has_php_class_prefix;
-    }
-
     /**
      * Use this option to change the namespace of php generated classes. Default
      * is empty. When this option is empty, the package name will be used for
@@ -910,7 +957,17 @@
      */
     public function getPhpNamespace()
     {
-        return $this->php_namespace;
+        return isset($this->php_namespace) ? $this->php_namespace : '';
+    }
+
+    public function hasPhpNamespace()
+    {
+        return isset($this->php_namespace);
+    }
+
+    public function clearPhpNamespace()
+    {
+        unset($this->php_namespace);
     }
 
     /**
@@ -926,16 +983,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->php_namespace = $var;
-        $this->has_php_namespace = true;
 
         return $this;
     }
 
-    public function hasPhpNamespace()
-    {
-        return $this->has_php_namespace;
-    }
-
     /**
      * Use this option to change the namespace of php generated metadata classes.
      * Default is empty. When this option is empty, the proto file name will be
@@ -946,7 +997,17 @@
      */
     public function getPhpMetadataNamespace()
     {
-        return $this->php_metadata_namespace;
+        return isset($this->php_metadata_namespace) ? $this->php_metadata_namespace : '';
+    }
+
+    public function hasPhpMetadataNamespace()
+    {
+        return isset($this->php_metadata_namespace);
+    }
+
+    public function clearPhpMetadataNamespace()
+    {
+        unset($this->php_metadata_namespace);
     }
 
     /**
@@ -962,16 +1023,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->php_metadata_namespace = $var;
-        $this->has_php_metadata_namespace = true;
 
         return $this;
     }
 
-    public function hasPhpMetadataNamespace()
-    {
-        return $this->has_php_metadata_namespace;
-    }
-
     /**
      * Use this option to change the package of ruby generated classes. Default
      * is empty. When this option is not set, the package name will be used for
@@ -982,7 +1037,17 @@
      */
     public function getRubyPackage()
     {
-        return $this->ruby_package;
+        return isset($this->ruby_package) ? $this->ruby_package : '';
+    }
+
+    public function hasRubyPackage()
+    {
+        return isset($this->ruby_package);
+    }
+
+    public function clearRubyPackage()
+    {
+        unset($this->ruby_package);
     }
 
     /**
@@ -998,16 +1063,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->ruby_package = $var;
-        $this->has_ruby_package = true;
 
         return $this;
     }
 
-    public function hasRubyPackage()
-    {
-        return $this->has_ruby_package;
-    }
-
     /**
      * The parser stores options it doesn't recognize here.
      * See the documentation for the "Options" section above.
@@ -1032,15 +1091,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
-        $this->has_uninterpreted_option = true;
 
         return $this;
     }
 
-    public function hasUninterpretedOption()
-    {
-        return $this->has_uninterpreted_option;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
index f5a65be..c261ed6 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
@@ -26,7 +26,6 @@
      * Generated from protobuf field <code>repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;</code>
      */
     private $annotation;
-    private $has_annotation = false;
 
     /**
      * Constructor.
@@ -68,15 +67,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo\Annotation::class);
         $this->annotation = $arr;
-        $this->has_annotation = true;
 
         return $this;
     }
 
-    public function hasAnnotation()
-    {
-        return $this->has_annotation;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
index 369fea4..0b043d0 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
@@ -22,22 +22,19 @@
      * Generated from protobuf field <code>repeated int32 path = 1 [packed = true];</code>
      */
     private $path;
-    private $has_path = false;
     /**
      * Identifies the filesystem path to the original source .proto.
      *
      * Generated from protobuf field <code>optional string source_file = 2;</code>
      */
-    protected $source_file = '';
-    private $has_source_file = false;
+    protected $source_file = null;
     /**
      * Identifies the starting offset in bytes in the generated code
      * that relates to the identified object.
      *
      * Generated from protobuf field <code>optional int32 begin = 3;</code>
      */
-    protected $begin = 0;
-    private $has_begin = false;
+    protected $begin = null;
     /**
      * Identifies the ending offset in bytes in the generated code that
      * relates to the identified offset. The end offset should be one past
@@ -45,8 +42,7 @@
      *
      * Generated from protobuf field <code>optional int32 end = 4;</code>
      */
-    protected $end = 0;
-    private $has_end = false;
+    protected $end = null;
 
     /**
      * Constructor.
@@ -97,16 +93,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
         $this->path = $arr;
-        $this->has_path = true;
 
         return $this;
     }
 
-    public function hasPath()
-    {
-        return $this->has_path;
-    }
-
     /**
      * Identifies the filesystem path to the original source .proto.
      *
@@ -115,7 +105,17 @@
      */
     public function getSourceFile()
     {
-        return $this->source_file;
+        return isset($this->source_file) ? $this->source_file : '';
+    }
+
+    public function hasSourceFile()
+    {
+        return isset($this->source_file);
+    }
+
+    public function clearSourceFile()
+    {
+        unset($this->source_file);
     }
 
     /**
@@ -129,16 +129,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->source_file = $var;
-        $this->has_source_file = true;
 
         return $this;
     }
 
-    public function hasSourceFile()
-    {
-        return $this->has_source_file;
-    }
-
     /**
      * Identifies the starting offset in bytes in the generated code
      * that relates to the identified object.
@@ -148,7 +142,17 @@
      */
     public function getBegin()
     {
-        return $this->begin;
+        return isset($this->begin) ? $this->begin : 0;
+    }
+
+    public function hasBegin()
+    {
+        return isset($this->begin);
+    }
+
+    public function clearBegin()
+    {
+        unset($this->begin);
     }
 
     /**
@@ -163,16 +167,10 @@
     {
         GPBUtil::checkInt32($var);
         $this->begin = $var;
-        $this->has_begin = true;
 
         return $this;
     }
 
-    public function hasBegin()
-    {
-        return $this->has_begin;
-    }
-
     /**
      * Identifies the ending offset in bytes in the generated code that
      * relates to the identified offset. The end offset should be one past
@@ -183,7 +181,17 @@
      */
     public function getEnd()
     {
-        return $this->end;
+        return isset($this->end) ? $this->end : 0;
+    }
+
+    public function hasEnd()
+    {
+        return isset($this->end);
+    }
+
+    public function clearEnd()
+    {
+        unset($this->end);
     }
 
     /**
@@ -199,16 +207,10 @@
     {
         GPBUtil::checkInt32($var);
         $this->end = $var;
-        $this->has_end = true;
 
         return $this;
     }
 
-    public function hasEnd()
-    {
-        return $this->has_end;
-    }
-
 }
 
 // Adding a class alias for backwards compatibility with the previous class name.
diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php
index 95bb706a..2f4e3cb 100644
--- a/php/src/Google/Protobuf/Internal/MessageOptions.php
+++ b/php/src/Google/Protobuf/Internal/MessageOptions.php
@@ -34,8 +34,7 @@
      *
      * Generated from protobuf field <code>optional bool message_set_wire_format = 1 [default = false];</code>
      */
-    protected $message_set_wire_format = false;
-    private $has_message_set_wire_format = false;
+    protected $message_set_wire_format = null;
     /**
      * Disables the generation of the standard "descriptor()" accessor, which can
      * conflict with a field of the same name.  This is meant to make migration
@@ -43,8 +42,7 @@
      *
      * Generated from protobuf field <code>optional bool no_standard_descriptor_accessor = 2 [default = false];</code>
      */
-    protected $no_standard_descriptor_accessor = false;
-    private $has_no_standard_descriptor_accessor = false;
+    protected $no_standard_descriptor_accessor = null;
     /**
      * Is this message deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
@@ -53,8 +51,7 @@
      *
      * Generated from protobuf field <code>optional bool deprecated = 3 [default = false];</code>
      */
-    protected $deprecated = false;
-    private $has_deprecated = false;
+    protected $deprecated = null;
     /**
      * Whether the message is an automatically generated map entry type for the
      * maps field.
@@ -77,15 +74,13 @@
      *
      * Generated from protobuf field <code>optional bool map_entry = 7;</code>
      */
-    protected $map_entry = false;
-    private $has_map_entry = false;
+    protected $map_entry = null;
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
      * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
      */
     private $uninterpreted_option;
-    private $has_uninterpreted_option = false;
 
     /**
      * Constructor.
@@ -168,7 +163,17 @@
      */
     public function getMessageSetWireFormat()
     {
-        return $this->message_set_wire_format;
+        return isset($this->message_set_wire_format) ? $this->message_set_wire_format : false;
+    }
+
+    public function hasMessageSetWireFormat()
+    {
+        return isset($this->message_set_wire_format);
+    }
+
+    public function clearMessageSetWireFormat()
+    {
+        unset($this->message_set_wire_format);
     }
 
     /**
@@ -196,16 +201,10 @@
     {
         GPBUtil::checkBool($var);
         $this->message_set_wire_format = $var;
-        $this->has_message_set_wire_format = true;
 
         return $this;
     }
 
-    public function hasMessageSetWireFormat()
-    {
-        return $this->has_message_set_wire_format;
-    }
-
     /**
      * Disables the generation of the standard "descriptor()" accessor, which can
      * conflict with a field of the same name.  This is meant to make migration
@@ -216,7 +215,17 @@
      */
     public function getNoStandardDescriptorAccessor()
     {
-        return $this->no_standard_descriptor_accessor;
+        return isset($this->no_standard_descriptor_accessor) ? $this->no_standard_descriptor_accessor : false;
+    }
+
+    public function hasNoStandardDescriptorAccessor()
+    {
+        return isset($this->no_standard_descriptor_accessor);
+    }
+
+    public function clearNoStandardDescriptorAccessor()
+    {
+        unset($this->no_standard_descriptor_accessor);
     }
 
     /**
@@ -232,16 +241,10 @@
     {
         GPBUtil::checkBool($var);
         $this->no_standard_descriptor_accessor = $var;
-        $this->has_no_standard_descriptor_accessor = true;
 
         return $this;
     }
 
-    public function hasNoStandardDescriptorAccessor()
-    {
-        return $this->has_no_standard_descriptor_accessor;
-    }
-
     /**
      * Is this message deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
@@ -253,7 +256,17 @@
      */
     public function getDeprecated()
     {
-        return $this->deprecated;
+        return isset($this->deprecated) ? $this->deprecated : false;
+    }
+
+    public function hasDeprecated()
+    {
+        return isset($this->deprecated);
+    }
+
+    public function clearDeprecated()
+    {
+        unset($this->deprecated);
     }
 
     /**
@@ -270,16 +283,10 @@
     {
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
-        $this->has_deprecated = true;
 
         return $this;
     }
 
-    public function hasDeprecated()
-    {
-        return $this->has_deprecated;
-    }
-
     /**
      * Whether the message is an automatically generated map entry type for the
      * maps field.
@@ -305,7 +312,17 @@
      */
     public function getMapEntry()
     {
-        return $this->map_entry;
+        return isset($this->map_entry) ? $this->map_entry : false;
+    }
+
+    public function hasMapEntry()
+    {
+        return isset($this->map_entry);
+    }
+
+    public function clearMapEntry()
+    {
+        unset($this->map_entry);
     }
 
     /**
@@ -336,16 +353,10 @@
     {
         GPBUtil::checkBool($var);
         $this->map_entry = $var;
-        $this->has_map_entry = true;
 
         return $this;
     }
 
-    public function hasMapEntry()
-    {
-        return $this->has_map_entry;
-    }
-
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
@@ -368,15 +379,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
-        $this->has_uninterpreted_option = true;
 
         return $this;
     }
 
-    public function hasUninterpretedOption()
-    {
-        return $this->has_uninterpreted_option;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
index f40f20f..e2ea8ea 100644
--- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
@@ -20,40 +20,34 @@
     /**
      * Generated from protobuf field <code>optional string name = 1;</code>
      */
-    protected $name = '';
-    private $has_name = false;
+    protected $name = null;
     /**
      * Input and output type names.  These are resolved in the same way as
      * FieldDescriptorProto.type_name, but must refer to a message type.
      *
      * Generated from protobuf field <code>optional string input_type = 2;</code>
      */
-    protected $input_type = '';
-    private $has_input_type = false;
+    protected $input_type = null;
     /**
      * Generated from protobuf field <code>optional string output_type = 3;</code>
      */
-    protected $output_type = '';
-    private $has_output_type = false;
+    protected $output_type = null;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.MethodOptions options = 4;</code>
      */
     protected $options = null;
-    private $has_options = false;
     /**
      * Identifies if client streams multiple client messages
      *
      * Generated from protobuf field <code>optional bool client_streaming = 5 [default = false];</code>
      */
-    protected $client_streaming = false;
-    private $has_client_streaming = false;
+    protected $client_streaming = null;
     /**
      * Identifies if server streams multiple server messages
      *
      * Generated from protobuf field <code>optional bool server_streaming = 6 [default = false];</code>
      */
-    protected $server_streaming = false;
-    private $has_server_streaming = false;
+    protected $server_streaming = null;
 
     /**
      * Constructor.
@@ -84,7 +78,17 @@
      */
     public function getName()
     {
-        return $this->name;
+        return isset($this->name) ? $this->name : '';
+    }
+
+    public function hasName()
+    {
+        return isset($this->name);
+    }
+
+    public function clearName()
+    {
+        unset($this->name);
     }
 
     /**
@@ -96,16 +100,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->name = $var;
-        $this->has_name = true;
 
         return $this;
     }
 
-    public function hasName()
-    {
-        return $this->has_name;
-    }
-
     /**
      * Input and output type names.  These are resolved in the same way as
      * FieldDescriptorProto.type_name, but must refer to a message type.
@@ -115,7 +113,17 @@
      */
     public function getInputType()
     {
-        return $this->input_type;
+        return isset($this->input_type) ? $this->input_type : '';
+    }
+
+    public function hasInputType()
+    {
+        return isset($this->input_type);
+    }
+
+    public function clearInputType()
+    {
+        unset($this->input_type);
     }
 
     /**
@@ -130,23 +138,27 @@
     {
         GPBUtil::checkString($var, True);
         $this->input_type = $var;
-        $this->has_input_type = true;
 
         return $this;
     }
 
-    public function hasInputType()
-    {
-        return $this->has_input_type;
-    }
-
     /**
      * Generated from protobuf field <code>optional string output_type = 3;</code>
      * @return string
      */
     public function getOutputType()
     {
-        return $this->output_type;
+        return isset($this->output_type) ? $this->output_type : '';
+    }
+
+    public function hasOutputType()
+    {
+        return isset($this->output_type);
+    }
+
+    public function clearOutputType()
+    {
+        unset($this->output_type);
     }
 
     /**
@@ -158,23 +170,27 @@
     {
         GPBUtil::checkString($var, True);
         $this->output_type = $var;
-        $this->has_output_type = true;
 
         return $this;
     }
 
-    public function hasOutputType()
-    {
-        return $this->has_output_type;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.MethodOptions options = 4;</code>
      * @return \Google\Protobuf\Internal\MethodOptions
      */
     public function getOptions()
     {
-        return $this->options;
+        return isset($this->options) ? $this->options : null;
+    }
+
+    public function hasOptions()
+    {
+        return isset($this->options);
+    }
+
+    public function clearOptions()
+    {
+        unset($this->options);
     }
 
     /**
@@ -186,16 +202,10 @@
     {
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class);
         $this->options = $var;
-        $this->has_options = true;
 
         return $this;
     }
 
-    public function hasOptions()
-    {
-        return $this->has_options;
-    }
-
     /**
      * Identifies if client streams multiple client messages
      *
@@ -204,7 +214,17 @@
      */
     public function getClientStreaming()
     {
-        return $this->client_streaming;
+        return isset($this->client_streaming) ? $this->client_streaming : false;
+    }
+
+    public function hasClientStreaming()
+    {
+        return isset($this->client_streaming);
+    }
+
+    public function clearClientStreaming()
+    {
+        unset($this->client_streaming);
     }
 
     /**
@@ -218,16 +238,10 @@
     {
         GPBUtil::checkBool($var);
         $this->client_streaming = $var;
-        $this->has_client_streaming = true;
 
         return $this;
     }
 
-    public function hasClientStreaming()
-    {
-        return $this->has_client_streaming;
-    }
-
     /**
      * Identifies if server streams multiple server messages
      *
@@ -236,7 +250,17 @@
      */
     public function getServerStreaming()
     {
-        return $this->server_streaming;
+        return isset($this->server_streaming) ? $this->server_streaming : false;
+    }
+
+    public function hasServerStreaming()
+    {
+        return isset($this->server_streaming);
+    }
+
+    public function clearServerStreaming()
+    {
+        unset($this->server_streaming);
     }
 
     /**
@@ -250,15 +274,9 @@
     {
         GPBUtil::checkBool($var);
         $this->server_streaming = $var;
-        $this->has_server_streaming = true;
 
         return $this;
     }
 
-    public function hasServerStreaming()
-    {
-        return $this->has_server_streaming;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php
index 6a4c92d..a4595b7 100644
--- a/php/src/Google/Protobuf/Internal/MethodOptions.php
+++ b/php/src/Google/Protobuf/Internal/MethodOptions.php
@@ -23,20 +23,17 @@
      *
      * Generated from protobuf field <code>optional bool deprecated = 33 [default = false];</code>
      */
-    protected $deprecated = false;
-    private $has_deprecated = false;
+    protected $deprecated = null;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];</code>
      */
-    protected $idempotency_level = 0;
-    private $has_idempotency_level = false;
+    protected $idempotency_level = null;
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
      * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
      */
     private $uninterpreted_option;
-    private $has_uninterpreted_option = false;
 
     /**
      * Constructor.
@@ -70,7 +67,17 @@
      */
     public function getDeprecated()
     {
-        return $this->deprecated;
+        return isset($this->deprecated) ? $this->deprecated : false;
+    }
+
+    public function hasDeprecated()
+    {
+        return isset($this->deprecated);
+    }
+
+    public function clearDeprecated()
+    {
+        unset($this->deprecated);
     }
 
     /**
@@ -87,23 +94,27 @@
     {
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
-        $this->has_deprecated = true;
 
         return $this;
     }
 
-    public function hasDeprecated()
-    {
-        return $this->has_deprecated;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];</code>
      * @return int
      */
     public function getIdempotencyLevel()
     {
-        return $this->idempotency_level;
+        return isset($this->idempotency_level) ? $this->idempotency_level : 0;
+    }
+
+    public function hasIdempotencyLevel()
+    {
+        return isset($this->idempotency_level);
+    }
+
+    public function clearIdempotencyLevel()
+    {
+        unset($this->idempotency_level);
     }
 
     /**
@@ -113,18 +124,12 @@
      */
     public function setIdempotencyLevel($var)
     {
-        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\MethodOptions_IdempotencyLevel::class);
+        GPBUtil::checkEnum($var, \Google\Protobuf\Internal\MethodOptions\IdempotencyLevel::class);
         $this->idempotency_level = $var;
-        $this->has_idempotency_level = true;
 
         return $this;
     }
 
-    public function hasIdempotencyLevel()
-    {
-        return $this->has_idempotency_level;
-    }
-
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
@@ -147,15 +152,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
-        $this->has_uninterpreted_option = true;
 
         return $this;
     }
 
-    public function hasUninterpretedOption()
-    {
-        return $this->has_uninterpreted_option;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
index 413b8e5..5ae36ce 100644
--- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
@@ -20,13 +20,11 @@
     /**
      * Generated from protobuf field <code>optional string name = 1;</code>
      */
-    protected $name = '';
-    private $has_name = false;
+    protected $name = null;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.OneofOptions options = 2;</code>
      */
     protected $options = null;
-    private $has_options = false;
 
     /**
      * Constructor.
@@ -49,7 +47,17 @@
      */
     public function getName()
     {
-        return $this->name;
+        return isset($this->name) ? $this->name : '';
+    }
+
+    public function hasName()
+    {
+        return isset($this->name);
+    }
+
+    public function clearName()
+    {
+        unset($this->name);
     }
 
     /**
@@ -61,23 +69,27 @@
     {
         GPBUtil::checkString($var, True);
         $this->name = $var;
-        $this->has_name = true;
 
         return $this;
     }
 
-    public function hasName()
-    {
-        return $this->has_name;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.OneofOptions options = 2;</code>
      * @return \Google\Protobuf\Internal\OneofOptions
      */
     public function getOptions()
     {
-        return $this->options;
+        return isset($this->options) ? $this->options : null;
+    }
+
+    public function hasOptions()
+    {
+        return isset($this->options);
+    }
+
+    public function clearOptions()
+    {
+        unset($this->options);
     }
 
     /**
@@ -89,15 +101,9 @@
     {
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\OneofOptions::class);
         $this->options = $var;
-        $this->has_options = true;
 
         return $this;
     }
 
-    public function hasOptions()
-    {
-        return $this->has_options;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php
index 46b516f..8dde8f3 100644
--- a/php/src/Google/Protobuf/Internal/OneofOptions.php
+++ b/php/src/Google/Protobuf/Internal/OneofOptions.php
@@ -21,7 +21,6 @@
      * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
      */
     private $uninterpreted_option;
-    private $has_uninterpreted_option = false;
 
     /**
      * Constructor.
@@ -60,15 +59,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
-        $this->has_uninterpreted_option = true;
 
         return $this;
     }
 
-    public function hasUninterpretedOption()
-    {
-        return $this->has_uninterpreted_option;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
index aaeefbc..9c2cc8f 100644
--- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
@@ -20,18 +20,15 @@
     /**
      * Generated from protobuf field <code>optional string name = 1;</code>
      */
-    protected $name = '';
-    private $has_name = false;
+    protected $name = null;
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.MethodDescriptorProto method = 2;</code>
      */
     private $method;
-    private $has_method = false;
     /**
      * Generated from protobuf field <code>optional .google.protobuf.ServiceOptions options = 3;</code>
      */
     protected $options = null;
-    private $has_options = false;
 
     /**
      * Constructor.
@@ -55,7 +52,17 @@
      */
     public function getName()
     {
-        return $this->name;
+        return isset($this->name) ? $this->name : '';
+    }
+
+    public function hasName()
+    {
+        return isset($this->name);
+    }
+
+    public function clearName()
+    {
+        unset($this->name);
     }
 
     /**
@@ -67,16 +74,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->name = $var;
-        $this->has_name = true;
 
         return $this;
     }
 
-    public function hasName()
-    {
-        return $this->has_name;
-    }
-
     /**
      * Generated from protobuf field <code>repeated .google.protobuf.MethodDescriptorProto method = 2;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -95,23 +96,27 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\MethodDescriptorProto::class);
         $this->method = $arr;
-        $this->has_method = true;
 
         return $this;
     }
 
-    public function hasMethod()
-    {
-        return $this->has_method;
-    }
-
     /**
      * Generated from protobuf field <code>optional .google.protobuf.ServiceOptions options = 3;</code>
      * @return \Google\Protobuf\Internal\ServiceOptions
      */
     public function getOptions()
     {
-        return $this->options;
+        return isset($this->options) ? $this->options : null;
+    }
+
+    public function hasOptions()
+    {
+        return isset($this->options);
+    }
+
+    public function clearOptions()
+    {
+        unset($this->options);
     }
 
     /**
@@ -123,15 +128,9 @@
     {
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ServiceOptions::class);
         $this->options = $var;
-        $this->has_options = true;
 
         return $this;
     }
 
-    public function hasOptions()
-    {
-        return $this->has_options;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php
index 0581efb..d15a36a 100644
--- a/php/src/Google/Protobuf/Internal/ServiceOptions.php
+++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php
@@ -23,15 +23,13 @@
      *
      * Generated from protobuf field <code>optional bool deprecated = 33 [default = false];</code>
      */
-    protected $deprecated = false;
-    private $has_deprecated = false;
+    protected $deprecated = null;
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
      * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
      */
     private $uninterpreted_option;
-    private $has_uninterpreted_option = false;
 
     /**
      * Constructor.
@@ -64,7 +62,17 @@
      */
     public function getDeprecated()
     {
-        return $this->deprecated;
+        return isset($this->deprecated) ? $this->deprecated : false;
+    }
+
+    public function hasDeprecated()
+    {
+        return isset($this->deprecated);
+    }
+
+    public function clearDeprecated()
+    {
+        unset($this->deprecated);
     }
 
     /**
@@ -81,16 +89,10 @@
     {
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
-        $this->has_deprecated = true;
 
         return $this;
     }
 
-    public function hasDeprecated()
-    {
-        return $this->has_deprecated;
-    }
-
     /**
      * The parser stores options it doesn't recognize here. See above.
      *
@@ -113,15 +115,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
-        $this->has_uninterpreted_option = true;
 
         return $this;
     }
 
-    public function hasUninterpretedOption()
-    {
-        return $this->has_uninterpreted_option;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
index dfeb69f..1c572e7 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
@@ -64,7 +64,6 @@
      * Generated from protobuf field <code>repeated .google.protobuf.SourceCodeInfo.Location location = 1;</code>
      */
     private $location;
-    private $has_location = false;
 
     /**
      * Constructor.
@@ -223,15 +222,9 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\SourceCodeInfo\Location::class);
         $this->location = $arr;
-        $this->has_location = true;
 
         return $this;
     }
 
-    public function hasLocation()
-    {
-        return $this->has_location;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
index 0aeea61..c4cc667 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
@@ -41,7 +41,6 @@
      * Generated from protobuf field <code>repeated int32 path = 1 [packed = true];</code>
      */
     private $path;
-    private $has_path = false;
     /**
      * Always has exactly three or four elements: start line, start column,
      * end line (optional, otherwise assumed same as start line), end column.
@@ -52,7 +51,6 @@
      * Generated from protobuf field <code>repeated int32 span = 2 [packed = true];</code>
      */
     private $span;
-    private $has_span = false;
     /**
      * If this SourceCodeInfo represents a complete declaration, these are any
      * comments appearing before and after the declaration which appear to be
@@ -93,18 +91,15 @@
      *
      * Generated from protobuf field <code>optional string leading_comments = 3;</code>
      */
-    protected $leading_comments = '';
-    private $has_leading_comments = false;
+    protected $leading_comments = null;
     /**
      * Generated from protobuf field <code>optional string trailing_comments = 4;</code>
      */
-    protected $trailing_comments = '';
-    private $has_trailing_comments = false;
+    protected $trailing_comments = null;
     /**
      * Generated from protobuf field <code>repeated string leading_detached_comments = 6;</code>
      */
     private $leading_detached_comments;
-    private $has_leading_detached_comments = false;
 
     /**
      * Constructor.
@@ -248,16 +243,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
         $this->path = $arr;
-        $this->has_path = true;
 
         return $this;
     }
 
-    public function hasPath()
-    {
-        return $this->has_path;
-    }
-
     /**
      * Always has exactly three or four elements: start line, start column,
      * end line (optional, otherwise assumed same as start line), end column.
@@ -288,16 +277,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
         $this->span = $arr;
-        $this->has_span = true;
 
         return $this;
     }
 
-    public function hasSpan()
-    {
-        return $this->has_span;
-    }
-
     /**
      * If this SourceCodeInfo represents a complete declaration, these are any
      * comments appearing before and after the declaration which appear to be
@@ -341,7 +324,17 @@
      */
     public function getLeadingComments()
     {
-        return $this->leading_comments;
+        return isset($this->leading_comments) ? $this->leading_comments : '';
+    }
+
+    public function hasLeadingComments()
+    {
+        return isset($this->leading_comments);
+    }
+
+    public function clearLeadingComments()
+    {
+        unset($this->leading_comments);
     }
 
     /**
@@ -390,23 +383,27 @@
     {
         GPBUtil::checkString($var, True);
         $this->leading_comments = $var;
-        $this->has_leading_comments = true;
 
         return $this;
     }
 
-    public function hasLeadingComments()
-    {
-        return $this->has_leading_comments;
-    }
-
     /**
      * Generated from protobuf field <code>optional string trailing_comments = 4;</code>
      * @return string
      */
     public function getTrailingComments()
     {
-        return $this->trailing_comments;
+        return isset($this->trailing_comments) ? $this->trailing_comments : '';
+    }
+
+    public function hasTrailingComments()
+    {
+        return isset($this->trailing_comments);
+    }
+
+    public function clearTrailingComments()
+    {
+        unset($this->trailing_comments);
     }
 
     /**
@@ -418,16 +415,10 @@
     {
         GPBUtil::checkString($var, True);
         $this->trailing_comments = $var;
-        $this->has_trailing_comments = true;
 
         return $this;
     }
 
-    public function hasTrailingComments()
-    {
-        return $this->has_trailing_comments;
-    }
-
     /**
      * Generated from protobuf field <code>repeated string leading_detached_comments = 6;</code>
      * @return \Google\Protobuf\Internal\RepeatedField
@@ -446,16 +437,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
         $this->leading_detached_comments = $arr;
-        $this->has_leading_detached_comments = true;
 
         return $this;
     }
 
-    public function hasLeadingDetachedComments()
-    {
-        return $this->has_leading_detached_comments;
-    }
-
 }
 
 // Adding a class alias for backwards compatibility with the previous class name.
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
index 6c871cc..a2aae3e 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
@@ -26,40 +26,33 @@
      * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption.NamePart name = 2;</code>
      */
     private $name;
-    private $has_name = false;
     /**
      * The value of the uninterpreted option, in whatever type the tokenizer
      * identified it as during parsing. Exactly one of these should be set.
      *
      * Generated from protobuf field <code>optional string identifier_value = 3;</code>
      */
-    protected $identifier_value = '';
-    private $has_identifier_value = false;
+    protected $identifier_value = null;
     /**
      * Generated from protobuf field <code>optional uint64 positive_int_value = 4;</code>
      */
-    protected $positive_int_value = 0;
-    private $has_positive_int_value = false;
+    protected $positive_int_value = null;
     /**
      * Generated from protobuf field <code>optional int64 negative_int_value = 5;</code>
      */
-    protected $negative_int_value = 0;
-    private $has_negative_int_value = false;
+    protected $negative_int_value = null;
     /**
      * Generated from protobuf field <code>optional double double_value = 6;</code>
      */
-    protected $double_value = 0.0;
-    private $has_double_value = false;
+    protected $double_value = null;
     /**
      * Generated from protobuf field <code>optional bytes string_value = 7;</code>
      */
-    protected $string_value = '';
-    private $has_string_value = false;
+    protected $string_value = null;
     /**
      * Generated from protobuf field <code>optional string aggregate_value = 8;</code>
      */
-    protected $aggregate_value = '';
-    private $has_aggregate_value = false;
+    protected $aggregate_value = null;
 
     /**
      * Constructor.
@@ -101,16 +94,10 @@
     {
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption\NamePart::class);
         $this->name = $arr;
-        $this->has_name = true;
 
         return $this;
     }
 
-    public function hasName()
-    {
-        return $this->has_name;
-    }
-
     /**
      * The value of the uninterpreted option, in whatever type the tokenizer
      * identified it as during parsing. Exactly one of these should be set.
@@ -120,7 +107,17 @@
      */
     public function getIdentifierValue()
     {
-        return $this->identifier_value;
+        return isset($this->identifier_value) ? $this->identifier_value : '';
+    }
+
+    public function hasIdentifierValue()
+    {
+        return isset($this->identifier_value);
+    }
+
+    public function clearIdentifierValue()
+    {
+        unset($this->identifier_value);
     }
 
     /**
@@ -135,23 +132,27 @@
     {
         GPBUtil::checkString($var, True);
         $this->identifier_value = $var;
-        $this->has_identifier_value = true;
 
         return $this;
     }
 
-    public function hasIdentifierValue()
-    {
-        return $this->has_identifier_value;
-    }
-
     /**
      * Generated from protobuf field <code>optional uint64 positive_int_value = 4;</code>
      * @return int|string
      */
     public function getPositiveIntValue()
     {
-        return $this->positive_int_value;
+        return isset($this->positive_int_value) ? $this->positive_int_value : 0;
+    }
+
+    public function hasPositiveIntValue()
+    {
+        return isset($this->positive_int_value);
+    }
+
+    public function clearPositiveIntValue()
+    {
+        unset($this->positive_int_value);
     }
 
     /**
@@ -163,23 +164,27 @@
     {
         GPBUtil::checkUint64($var);
         $this->positive_int_value = $var;
-        $this->has_positive_int_value = true;
 
         return $this;
     }
 
-    public function hasPositiveIntValue()
-    {
-        return $this->has_positive_int_value;
-    }
-
     /**
      * Generated from protobuf field <code>optional int64 negative_int_value = 5;</code>
      * @return int|string
      */
     public function getNegativeIntValue()
     {
-        return $this->negative_int_value;
+        return isset($this->negative_int_value) ? $this->negative_int_value : 0;
+    }
+
+    public function hasNegativeIntValue()
+    {
+        return isset($this->negative_int_value);
+    }
+
+    public function clearNegativeIntValue()
+    {
+        unset($this->negative_int_value);
     }
 
     /**
@@ -191,23 +196,27 @@
     {
         GPBUtil::checkInt64($var);
         $this->negative_int_value = $var;
-        $this->has_negative_int_value = true;
 
         return $this;
     }
 
-    public function hasNegativeIntValue()
-    {
-        return $this->has_negative_int_value;
-    }
-
     /**
      * Generated from protobuf field <code>optional double double_value = 6;</code>
      * @return float
      */
     public function getDoubleValue()
     {
-        return $this->double_value;
+        return isset($this->double_value) ? $this->double_value : 0.0;
+    }
+
+    public function hasDoubleValue()
+    {
+        return isset($this->double_value);
+    }
+
+    public function clearDoubleValue()
+    {
+        unset($this->double_value);
     }
 
     /**
@@ -219,23 +228,27 @@
     {
         GPBUtil::checkDouble($var);
         $this->double_value = $var;
-        $this->has_double_value = true;
 
         return $this;
     }
 
-    public function hasDoubleValue()
-    {
-        return $this->has_double_value;
-    }
-
     /**
      * Generated from protobuf field <code>optional bytes string_value = 7;</code>
      * @return string
      */
     public function getStringValue()
     {
-        return $this->string_value;
+        return isset($this->string_value) ? $this->string_value : '';
+    }
+
+    public function hasStringValue()
+    {
+        return isset($this->string_value);
+    }
+
+    public function clearStringValue()
+    {
+        unset($this->string_value);
     }
 
     /**
@@ -247,23 +260,27 @@
     {
         GPBUtil::checkString($var, False);
         $this->string_value = $var;
-        $this->has_string_value = true;
 
         return $this;
     }
 
-    public function hasStringValue()
-    {
-        return $this->has_string_value;
-    }
-
     /**
      * Generated from protobuf field <code>optional string aggregate_value = 8;</code>
      * @return string
      */
     public function getAggregateValue()
     {
-        return $this->aggregate_value;
+        return isset($this->aggregate_value) ? $this->aggregate_value : '';
+    }
+
+    public function hasAggregateValue()
+    {
+        return isset($this->aggregate_value);
+    }
+
+    public function clearAggregateValue()
+    {
+        unset($this->aggregate_value);
     }
 
     /**
@@ -275,15 +292,9 @@
     {
         GPBUtil::checkString($var, True);
         $this->aggregate_value = $var;
-        $this->has_aggregate_value = true;
 
         return $this;
     }
 
-    public function hasAggregateValue()
-    {
-        return $this->has_aggregate_value;
-    }
-
 }
 
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
index 1956ba7..6212d1e 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
@@ -24,13 +24,11 @@
     /**
      * Generated from protobuf field <code>required string name_part = 1;</code>
      */
-    protected $name_part = '';
-    private $has_name_part = false;
+    protected $name_part = null;
     /**
      * Generated from protobuf field <code>required bool is_extension = 2;</code>
      */
-    protected $is_extension = false;
-    private $has_is_extension = false;
+    protected $is_extension = null;
 
     /**
      * Constructor.
@@ -53,7 +51,17 @@
      */
     public function getNamePart()
     {
-        return $this->name_part;
+        return isset($this->name_part) ? $this->name_part : '';
+    }
+
+    public function hasNamePart()
+    {
+        return isset($this->name_part);
+    }
+
+    public function clearNamePart()
+    {
+        unset($this->name_part);
     }
 
     /**
@@ -65,23 +73,27 @@
     {
         GPBUtil::checkString($var, True);
         $this->name_part = $var;
-        $this->has_name_part = true;
 
         return $this;
     }
 
-    public function hasNamePart()
-    {
-        return $this->has_name_part;
-    }
-
     /**
      * Generated from protobuf field <code>required bool is_extension = 2;</code>
      * @return bool
      */
     public function getIsExtension()
     {
-        return $this->is_extension;
+        return isset($this->is_extension) ? $this->is_extension : false;
+    }
+
+    public function hasIsExtension()
+    {
+        return isset($this->is_extension);
+    }
+
+    public function clearIsExtension()
+    {
+        unset($this->is_extension);
     }
 
     /**
@@ -93,16 +105,10 @@
     {
         GPBUtil::checkBool($var);
         $this->is_extension = $var;
-        $this->has_is_extension = true;
 
         return $this;
     }
 
-    public function hasIsExtension()
-    {
-        return $this->has_is_extension;
-    }
-
 }
 
 // Adding a class alias for backwards compatibility with the previous class name.
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc
index a4b7139..365cb64 100644
--- a/src/google/protobuf/compiler/php/php_generator.cc
+++ b/src/google/protobuf/compiler/php/php_generator.cc
@@ -636,12 +636,6 @@
         "name", field->name(),
         "initial_value", initial_value);
   }
-
-  if (is_descriptor) {
-    printer->Print(
-        "private $has_^name^ = false;\n",
-        "name", field->name());
-  }
 }
 
 void GenerateOneofField(const OneofDescriptor* oneof, io::Printer* printer) {
@@ -797,13 +791,6 @@
         "name", field->name());
   }
 
-  // Set has bit for proto2 only.
-  if (is_descriptor) {
-    printer->Print(
-        "$this->has_^field_name^ = true;\n",
-        "field_name", field->name());
-  }
-
   printer->Print("\nreturn $this;\n");
 
   Outdent(printer);
@@ -826,17 +813,6 @@
         "camel_name", UnderscoresToCamelCase(field->name(), true),
         "field_name", field->name());
   }
-
-  // Generate has method for proto2 only.
-  if (is_descriptor) {
-    printer->Print(
-        "public function has^camel_name^()\n"
-        "{\n"
-        "    return $this->has_^field_name^;\n"
-        "}\n\n",
-        "camel_name", UnderscoresToCamelCase(field->name(), true),
-        "field_name", field->name());
-  }
 }
 
 void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) {