extract() for class members
<p>There's the extract function for generating local variables from an array:</p>

<pre><code>extract(['a' =&gt; 10, 'b' =&gt; 20]) // $a = 10, $b = 20
</code></pre>

<p>What would be a clean solution like the <code>extract()</code> function, but for class members? Obviously I can do something along the lines of:</p>

<pre><code>class User {
  private $user_id;
  private $password;
  private $email;

  public function __construct($params) {
    $this-&gt;user_id = isset($params['user_id']) ? $params['user_id'] : null;
    $this-&gt;password = isset($params['password']) ? $params['password'] : null;
    $this-&gt;email = isset($params['email']) ? $params['email'] : null;
  }
}
</code></pre>

<p>Is there a cleaner way to do this?</p>