title: Casting object to array - any magic method being called?
body: <p>I have an object of class Foo:</p>
  
  <pre><code>class Foo extends Bar {
      protected $a;
      protected $b;
  }
  
  $obj = new Foo();
  </code></pre>
  
  <p>What I want (and have) to do is cast this object to an array, like this:</p>
  
  <pre><code>$arr = (array)$obj;
  </code></pre>
  
  <p>Is there any magic (or not magic :)) method that is being called at this moment? Or is there any other way to intercept it? I know I can write a simple method, eg. <code>asArray()</code> in Foo, but I'm looking for some more "native" PHP ways.</p>