X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fpsy%2Fpsysh%2Fsrc%2Ffunctions.php;fp=vendor%2Fpsy%2Fpsysh%2Fsrc%2Ffunctions.php;h=b07c492071b31571c4b6b554ae5d2560d0a39d0f;hb=419f97be044f1aebd0713921ee604841127e9e84;hp=edbef1fcde81c0dc1ab29cab48e680a69465fb63;hpb=052617e40b525f8b817d84c29b1c04951f427069;p=yaffs-website diff --git a/vendor/psy/psysh/src/functions.php b/vendor/psy/psysh/src/functions.php index edbef1fcd..b07c49207 100644 --- a/vendor/psy/psysh/src/functions.php +++ b/vendor/psy/psysh/src/functions.php @@ -28,7 +28,7 @@ if (!function_exists('Psy\sh')) { */ function sh() { - return 'extract(\Psy\debug(get_defined_vars(), isset($this) ? $this : null));'; + return 'extract(\Psy\debug(get_defined_vars(), isset($this) ? $this : @get_called_class()));'; } } @@ -50,9 +50,9 @@ if (!function_exists('Psy\debug')) { * var_dump($item); // will be whatever you set $item to in Psy Shell * } * - * Optionally, supply an object as the `$boundObject` parameter. This - * determines the value `$this` will have in the shell, and sets up class - * scope so that private and protected members are accessible: + * 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() { @@ -60,12 +60,22 @@ if (!function_exists('Psy\debug')) { * } * } * - * @param array $vars Scope variables from the calling context (default: array()) - * @param object $boundObject Bound object ($this) value for the shell + * 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()); + * } + * } + * + * @param array $vars Scope variables from the calling context (default: array()) + * @param object|string $bindTo Bound object ($this) or class (self) value for the shell * * @return array Scope variables from the debugger session */ - function debug(array $vars = [], $boundObject = null) + function debug(array $vars = [], $bindTo = null) { echo PHP_EOL; @@ -79,8 +89,10 @@ if (!function_exists('Psy\debug')) { $sh->addInput('whereami -n2', true); } - if ($boundObject !== null) { - $sh->setBoundObject($boundObject); + if (is_string($bindTo)) { + $sh->setBoundClass($bindTo); + } elseif ($bindTo !== null) { + $sh->setBoundObject($bindTo); } $sh->run();