- var_dump: documentation ( source)
<?php
class Foo
{
public function sing()
{
var_dump('Do re mi!');
}
public function dance()
{
var_dump('Cha cha cha!');
}
}
function gimmeFoo(Foo $foo)
{
$foo->sing();
$foo->dance();
}
$gimmeWhat = new ReflectionFunction('gimmeFoo');
$class = $gimmeWhat->getParameters()[0]->getClass();
$methods = $class->getMethods();
$evil = "
class Fake extends $class->name
{
public function idoeverything() {
var_dump('Just kidding!');
}
";
foreach ($methods as $method) {
$evil .= "public function $method->name() {\$this->idoeverything();}";
}
$evil .= "}";
eval($evil);
$fake = new Fake;
gimmeFoo($fake);