title: Error serializing an object tree with SplObjectStorage
body: <p>I have implemented a simple Composite pattern using SplObjectStorage, like the example above:</p>
  
  <pre><code>class Node
  {
      private $parent = null;
  
      public function setParent(Composite $parent)
      {
          $this-&gt;parent = $parent;
      }
  }
  
  class Composite extends Node
  {
      private $children;
  
      public function __construct()
      {
          $this-&gt;children = new SplObjectStorage;
      }
  
      public function add(Node $node)
      {
          $this-&gt;children-&gt;attach($node);
          $node-&gt;setParent($this);
      }
  }
  </code></pre>
  
  <p>Whenever I try to serialize a Composite object, PHP 5.3.2 throws me a <code>Segmentation Fault</code>.
  This only happens when I add any number of nodes of any type to the object.</p>
  
  <p>This is the offending code:</p>
  
  <pre><code>$node = new Node;
  $composite = new Composite;
  $composite-&gt;add($node);
  echo serialize($composite);
  </code></pre>
  
  <p>Although this one works:</p>
  
  <pre><code>$node = new Node;
  $composite = new Composite;
  echo serialize($composite);
  </code></pre>
  
  <p>Also, if I implement the Composite pattern with array() instead of SplObjectStorage, all runs ok too.</p>
  
  <p>What I'm making wrong?</p>