title: access private variable in subclass
body: <p>I have a class.</p>
  
  <pre><code>&lt;?php
  
  class WC_Swatch_Picker {
  
  private $size;
  private $attributes;
  private $selected_attributes;
  private $swatch_type_options;
  
  public function __construct( $product_id, $attributes, $selected_attributes ) {
      $this-&gt;swatch_type_options = maybe_unserialize( get_post_meta( $product_id, '_swatch_type_options', true ) );
  
      if ( !$this-&gt;swatch_type_options ) {
          $this-&gt;swatch_type_options = array();
      }
  
      $product_configured_size = get_post_meta( $product_id, '_swatch_size', true );
      if ( !$product_configured_size ) {
          $this-&gt;size = 'swatches_image_size';
      } else {
          $this-&gt;size = $product_configured_size;
      }
  
      $this-&gt;attributes = $attributes;
      $this-&gt;selected_attributes = $selected_attributes;
  }
  
  public function picker() {
      ?&gt;
  
      &lt;table class="variations-table" cellspacing="0"&gt;
          &lt;tbody&gt;
              &lt;?php
              $loop = 0;
              foreach ( $this-&gt;attributes as $name =&gt; $options ) : $loop++;
                  $st_name = sanitize_title( $name );
                  $hashed_name = md5( $st_name );
                  $lookup_name = '';
                  if ( isset( $this-&gt;swatch_type_options[$hashed_name] ) ) {
                      $lookup_name = $hashed_name;
                  } elseif ( isset( $this-&gt;swatch_type_options[$st_name] ) ) {
                      $lookup_name = $st_name;
                  }
                  ?&gt;
                  &lt;tr&gt;
                      &lt;td class="label"&gt;&lt;label for="&lt;?php echo $st_name; ?&gt;"&gt;&lt;?php echo WC_Swatches_Compatibility::wc_attribute_label( $name ); ?&gt;&lt;/label&gt;&lt;/td&gt;
                      &lt;td&gt;
                          &lt;?php
                          if ( isset( $this-&gt;swatch_type_options[$lookup_name] ) ) {
                              $picker_type = $this-&gt;swatch_type_options[$lookup_name]['type'];
                              if ( $picker_type == 'default' ) {
                                  $this-&gt;render_default( $st_name, $options );
                              } else {
                                  $this-&gt;render_picker( $st_name, $options, $name );
                              }
                          } else {
                              $this-&gt;render_default( $st_name, $options );
                          }
                          ?&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;?php endforeach; ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
      &lt;?php
  }
  </code></pre>
  
  <p>I am trying to extend that class so that I can output the <code>picker()</code> method that displays <code>&lt;table&gt;</code> as a <code>&lt;div&gt;</code> instead. </p>
  
  <p>Here is my attempt to extend that class.</p>
  
  <pre><code>class SSi_WC_Swatch_Picker extends WC_Swatch_Picker {
  
  public function picker() {
      ?&gt;
  
      &lt;div class="variations-table"&gt;
  
              &lt;?php
  
              $loop = 0;
              foreach ( $this-&gt;attributes as $name =&gt; $options ) : $loop++;
                  $st_name = sanitize_title( $name );
                  $hashed_name = md5( $st_name );
                  $lookup_name = '';
                  if ( isset( $this-&gt;swatch_type_options[$hashed_name] ) ) {
                      $lookup_name = $hashed_name;
                  } elseif ( isset( $this-&gt;swatch_type_options[$st_name] ) ) {
                      $lookup_name = $st_name;
                  }
                  ?&gt;
                  &lt;div&gt;
                      &lt;div class="label"&gt;&lt;label for="&lt;?php echo $st_name; ?&gt;"&gt;&lt;?php echo WC_Swatches_Compatibility::wc_attribute_label( $name ); ?&gt;&lt;/label&gt;&lt;/div&gt;
                      &lt;div&gt;
                          &lt;?php
                          if ( isset( $this-&gt;swatch_type_options[$lookup_name] ) ) {
                              $picker_type = $this-&gt;swatch_type_options[$lookup_name]['type'];
                              if ( $picker_type == 'default' ) {
                                  $this-&gt;render_default( $st_name, $options );
                              } else {
                                  $this-&gt;render_picker( $st_name, $options, $name );
                              }
                          } else {
                              $this-&gt;render_default( $st_name, $options );
                          }
                          ?&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;?php endforeach; 
  
              ?&gt;
  
      &lt;/div&gt;
  
      &lt;?php
  }
  
  }
  </code></pre>
  
  <p>My output on screen shows the <code>&lt;div&gt;</code> like I want but I get:
   <code>Notice: Undefined property: SSi_WC_Swatch_Picker::$attributes</code> and <code>Warning: Invalid argument supplied for foreach()</code> </p>
  
  <p>I believe that it is because the parent class defines <code>$attributes</code> as <code>private</code>.</p>
  
  <p>Unfortunately I cannot change the parent class. </p>
  
  <p>So my noob questions is can the <code>$attributes</code> be accessed from the subclass somehow? I do not see a __get or __set method in the parent class so I'm guessing there isn't.</p>
  
  <p>The developer is changing the <code>private</code> attributes to <code>protected</code>. So that will solve my issue of accessing the properties. </p>