title: Extending ArrayObject in PHP properly?
body: <p><strong>Problem:</strong> I am trying to extend PHP's <code>ArrayObject</code> as shown below. Unfortunately I can't get it to work properly when setting multi-dimensional objects and instead an error thrown as I have the strict settings enabled in PHP. (<code>Error: Strict standards: Creating default object from empty value</code>)</p>
  
  <p><strong>Question:</strong> How can I modify my class to automatically create non-existing levels for me?</p>
  
  <p><strong>The code:</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>$config = new Config;
  $config-&gt;lvl1_0 = true; // Works
  $config-&gt;lvl1_1-&gt;lvl2 = true; // Throws error as "lvl1" isn't set already
  
  class Config extends ArrayObject
  {
      function __construct() {
          parent::__construct(array(), self::ARRAY_AS_PROPS);
      }
  
      public function offsetSet($k, $v) {
          $v = is_array($v) ? new self($v) : $v;
          return parent::offsetSet($k, $v);
      }
  }
  </code></pre>