title: Efficiently dump certain class properties in PHP
body: <p>I'm writing a class and I want to make a method that dumps some, but not all, of the class properties. </p>
  
  <p>I'm lazy and I don't feel like writing out an array with the keys being the names of the properties, like so: </p>
  
  <pre><code>private $prop1;
  private $dontdumpthis;
  private $prop2;
  public method dump() {
    return array(
      'prop1' =&gt; $this-&gt;prop1,
      'prop2' =&gt; $this-&gt;prop2,
      ...
  </code></pre>
  
  <p>I looked at <code>compact()</code>:</p>
  
  <pre><code>public method dump() {
    return compact(
      $this-&gt;prop1,
      ...
  </code></pre>
  
  <p>But that just returns an empty array. </p>
  
  <p>Is there a simple way to specify the properties' names and values?</p>