Skip to content

Instantly share code, notes, and snippets.

@spolischook
Created January 9, 2014 14:24
Show Gist options
  • Select an option

  • Save spolischook/8334864 to your computer and use it in GitHub Desktop.

Select an option

Save spolischook/8334864 to your computer and use it in GitHub Desktop.
<?php
class Dto
{
public $foo;
public $bar;
public $baz;
}
class Obj
{
protected $foo = 'foo';
protected $bar = 'bar';
public function getFoo() {return $this->foo;}
public function getBar() {return $this->bar;}
}
$obj = new Obj();
$getter = function () {
return get_object_vars($this);
};
$getVars = $getter->bindTo($obj, $obj);
var_dump( get_object_vars($obj));
var_dump($getVars());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment