Skip to content

Commit

Permalink
add breakpoint() convenience function
Browse files Browse the repository at this point in the history
Works the same way that eval(Psy\sh()) and allow interactive debugging in CLI
  • Loading branch information
antograssiot committed Jul 17, 2015
1 parent c647c0f commit fb9ddc2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/basics.php
Expand Up @@ -143,3 +143,20 @@ function json_last_error_msg()
}

}

if (!function_exists('breakpoint')) {
/**
* Command to return the eval-able code to startup PsySH in interactive debugger
* Works the same way as eval(\Psy\sh());
* ```
* eval(breakpoint());
* ```
* @return string
*/
function breakpoint()
{
if (PHP_SAPI === 'cli' && class_exists('\Psy\Shell')) {
return 'extract(\Psy\Shell::debug(get_defined_vars(), isset($this) ? $this : null));';
}
}
}

0 comments on commit fb9ddc2

Please sign in to comment.