functions.php
Table of Contents
- sh() : string
- Command to return the eval-able code to startup PsySH.
- debug() : array<string|int, mixed>
- Invoke a Psy Shell from the current context.
- info() : array<string|int, mixed>|null
- Get a bunch of debugging info about the current PsySH environment and configuration.
- bin() : Closure
- `psysh` command line executable.
Functions
sh()
Command to return the eval-able code to startup PsySH.
sh() : string
eval(\Psy\sh());
Return values
string —debug()
Invoke a Psy Shell from the current context.
debug([array<string|int, mixed> $vars = [] ][, object|string $bindTo = null ]) : array<string|int, mixed>
For example:
foreach ($items as $item) {
\Psy\debug(get_defined_vars());
}
If you would like your shell interaction to affect the state of the current context, you can extract() the values returned from this call:
foreach ($items as $item) {
extract(\Psy\debug(get_defined_vars()));
var_dump($item); // will be whatever you set $item to in Psy Shell
}
Optionally, supply an object as the $bindTo parameter. This determines
the value $this will have in the shell, and sets up class scope so that
private and protected members are accessible:
class Foo {
function bar() {
\Psy\debug(get_defined_vars(), $this);
}
}
For the static equivalent, pass a class name as the $bindTo parameter.
This makes self work in the shell, and sets up static scope so that
private and protected static members are accessible:
class Foo {
static function bar() {
\Psy\debug(get_defined_vars(), get_called_class());
}
}
Parameters
- $vars : array<string|int, mixed> = []
-
Scope variables from the calling context (default: array())
- $bindTo : object|string = null
-
Bound object ($this) or class (self) value for the shell
Return values
array<string|int, mixed> —Scope variables from the debugger session
info()
Get a bunch of debugging info about the current PsySH environment and configuration.
info([Configuration|null $config = null ]) : array<string|int, mixed>|null
If a Configuration param is passed, that configuration is stored and used for the current shell session, and no debugging info is returned.
Parameters
- $config : Configuration|null = null
Return values
array<string|int, mixed>|null —bin()
`psysh` command line executable.
bin() : Closure