title: php, static method overloading
body: <p>I have an object with method that sometimes I need to call as static, sometimes not.</p>
  
  <pre><code>class MYOBJECT
  {
    private $group_id;
  
    public function SetGroupId($_id) { $this-&gt;group_id = $_id; }
  
    public static function GetGroupName($_id=NULL)
    {
      // is there any way to implement condition like this?
      if( _called_as_static ) $id = $_id;
      else $id = $this-&gt;group_id;
  
      $query mysql_query("SELECT name FROM group WHERE id = $id");
      list($name) = mysql_fetch_array($query);
  
      return $name;
    }
  }
  
  $obj = new MYOBJECT;
  $obj-&gt;SetGroupId(4);
  
  // should work both ways
  $name = $obj-&gt;GetGroupName();
  $name = MYOBJECT::GetGroupName(4);
  </code></pre>
  
  <p>I solved it this way:</p>
  
  <pre><code>public static function MYOBJECT::GetGroupName($_id=NULL)
  {
    if( is_object($_id) ) $_id = $_id-&gt;GetGroupId();
  
    ...
  }
  
  $name = MYOBJECT:GetGroupName(4);
  $name = $obj-&gt;GetGroupName($obj);
  </code></pre>
  
  <p>but still, is there something more elegant?</p>