- var_dump: documentation ( source)
<?php
class Foo
{
private $bar;
public function __construct($bar)
{
$this->bar = $bar;
}
public function getBar()
{
return $this->bar;
}
}
class Baz extends Foo
{
private $wrapped;
public function __construct($bar)
{
$this->wrapped = $this->wrapped ?: (new \ReflectionClass('Foo'))->newInstanceWithoutConstructor();
$this->wrapped->__construct($bar);
}
public function getBar()
{
return $this->wrapped->getBar();
}
}
var_dump((new Baz('tab'))->getBar());