title: How to handle __clone for child class object properties
body: <p>When cloning an object that is a child of another object, is it "required" to indicate all the parent properties that are objects in the child class <code>__clone()</code> method or does the child class <code>__clone()</code> method can only include its own object properties that does not belong to the parent object?</p>
  
  <p>Here is an example</p>
  
  <p>The object <code>Child_A</code> extends the object <code>Parent_A</code>.</p>
  
  <p>The object <code>Parent_A</code> uses the object <code>A_1</code> in its constructor and has a <code>__clone()</code> method.</p>
  
  <pre><code>class Parent_A{
  
     function __construct(A_1 $a_1){
        $this-&gt;A_1 = $a_1;
     }
  
     function __clone(){
        $this-&gt;A_1 = clone $this-&gt;A_1;
     }
  }
  </code></pre>
  
  <p>The object <code>Child_A</code> requires <code>A_2</code> to construct.</p>
  
  <pre><code>class Child_A{
  
     function __construct(A_2 $a_2){
        parent::__construct(new A_1());
  
     }
  
     function __clone(){
  
        $this-&gt;A_2 = clone $this-&gt;A_2;
     }
  }
  </code></pre>
  
  <p>If I want to make a deep copy of <code>Child_A</code> that would include a deep_copy <code>A_1</code>, should I use in <code>Child_A</code>:</p>
  
  <pre><code>   function __clone(){
  
        $this-&gt;A_1 = clone $this-&gt;A_1;
        $this-&gt;A_2 = clone $this-&gt;A_2;
     }
  </code></pre>
  
  <p>Or is the following enough as the parent object's clone method already includes <code>A_1</code>:</p>
  
  <pre><code>   function __clone(){
  
        $this-&gt;A_2 = clone $this-&gt;A_2;
     }
  </code></pre>
  
  <p>Thank you.</p>