You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tejas Manohar edited this page Feb 28, 2015
·
1 revision
After each expression you enter, Boris passes it through an Inspector to get a
representation that is useful for debugging. The default is does some nice
highlighting of the data types in the value, to make it easier to read at a
glance, but you can change this behaviour.
Any object that has an inspect($variable) method may be used for this purpose.
$boris->setInspector(new BlinkInspector());
Boris comes with three alternatives out of the box:
\Boris\ColoredInspector, which does data-type highlighting and is the default
\Boris\DumpInspector, which uses a simple, but effective var_dump()
\Boris\ExportInspector, which uses var_export()
Note that you can change this from inside the REPL too:
To further customize object output within \Boris\ColoredInspector, you may
subclass and override the objectVars($value) method:
class MyInspector extends \Boris\ColoredInspector {
public function objectVars($value) {
if ($value instanceof User) {
return array('user_id' => $value->getUserId());
}
return parent::objectVars($value);
}
}
This overrides the default behavior of simply calling get_object_vars()
on the object, allowing you to display properties that may be otherwise obfuscated
behind magic methods or property visibility.