<?
class _ArrayObject implements ArrayAccess {

  function offsetExists ($key){ return isset($this->$key); }
  function offsetGet($key){ return $this->$key;}
  function offsetSet($key, $value){$this->$key = $value;}
  function offsetUnset($key){unset($this->$key); }


  public static function expose($obj){
    if(is_scalar($obj) || is_null($obj)) 
      return $obj;

    if(is_array($obj)) {
      $out = new self();
      foreach($obj as $k=>$v)  
        $out->$k = call_user_func(__METHOD__, $v);
      return $out;
    }

    if(is_object($obj)) {
      $out = new self();
      $fx = new ReflectionObject($obj);
      foreach($fx->getProperties() as $property) {
          $property_name = $property->getName();
          $property->setAccessible(true);
          $out->$property_name = call_user_func(__METHOD__, $property->getValue($obj));
      }
      return $out ;
    }

    return null;

  }
}
<?
class _ArrayObject implements ArrayAccess {

  function offsetExists ($key){ return isset($this->$key); }
  function offsetGet($key){ return $this->$key;}
  function offsetSet($key, $value){$this->$key = $value;}
  function offsetUnset($key){unset($this->$key); }



  protected function __get($key){
    if(method_exists($this, $getter = "get_$key"))
        return $this->$getter();
  }

  public static function expose($obj){
    if(is_scalar($obj) || is_null($obj)) 
      return $obj;

    if(is_array($obj)) {
      $out = new self();
      foreach($obj as $k=>$v)  
        $out->$k = call_user_func(__METHOD__, $v);
      return $out;
    }

    if(is_object($obj)) {
      $out = new self();
      $fx = new ReflectionObject($obj);
      foreach($fx->getProperties() as $property) {
          $property_name = $property->getName();
          $property->setAccessible(true);
          $out->$property_name = call_user_func(__METHOD__, $property->getValue($obj));
      }
      return $out ;
    }

    return null;

  }
}
Allow _get access in ArrayObject
Allow _get access in ArrayObject

git-svn-id: 4cd2d1688610a87757c9f4de95975a674329c79f@1807 b8ca103b-dd03-488c-9448-c80b36131af2
