- var_dump: documentation ( source)
<?php
class Foo
{
private $resource;
private $state = 'stable';
public function runBar()
{
try {
$this->bar();
} catch (\Exception $e)
{
// Instead of trying to make this object stable again, just..
yield;
}
}
private function bar()
{
$this->state = 'unstable';
$this->resource = 'Some external service';
throw new \Exception('Something went wrong with our resource, we\'re now in an unstable state');
}
}
$foo = new Foo();
$foo->runBar();
var_dump($foo);