- var_dump: documentation ( source)
<?php
class PrivacyViolator
{
private $caller;
function __construct() {
$this->caller = function ($method, $args) {
return call_user_func_array([$this, $method], $args);
};
}
function callPrivateMethod($object, $method, $args) {
$this->caller->bindTo($object, $object);
return $this->caller($method, $args);
}
}
class MyClass
{
private function hello($args) {
var_dump($args);
}
}
$myObject = new MyClass();
$privacyViolator = new PrivacyViolator();
$privacyViolator->callPrivateMethod($myObject, 'hello', ['world']);