title: PHP how to use magic method with static class?
body: <p>I'm trying to convert array to object. I want to use magic methods - __get and __set with static properties.</p>
  
  <p>My code:</p>
  
  <pre><code>class UserData {
      private static  $id, $name, $login;
  
      public function __get($var)
      {
          return self::$var;
      }
      public function __set($var, $val)
      {
          self::{$var} = $val;
      }
  }
  </code></pre>
  
  <p>And setting:</p>
  
  <pre><code>foreach($userArray as $key =&gt; $val) 
      {
          DaneBilingowe::${$key} = $val;
      }
  </code></pre>
  
  <p>Error:
  Fatal error: Cannot access private property UserData::$id</p>
  
  <p>Is it possible to use magic method with static property?</p>