Beispiel #1
0
 public function testExecute()
 {
     $instance = new ShowVars('');
     $session = new \Pry\Session(__FILE__);
     $session->setDefinedVariables(['foo' => new \stdClass(), 'bar' => []]);
     ob_start();
     $instance->execute($session);
     $actual = ob_get_contents();
     ob_end_clean();
     $expected = '$bar, $foo' . PHP_EOL;
     $this->assertEquals($expected, $actual);
 }
Beispiel #2
0
}
# Enable colors for var_dump()
ini_set('xdebug.cli_color', 1);
# Create new session
Pry\Session::create(__FILE__);
# Hack make $this a defined variable -- get_defined_vars()
isset($this);
# Publicize local variables
Pry\Session::getCurrent()->setDefinedVariables(get_defined_vars());
# Show current location
Pry\Session::getCurrent()->printCurrentLocation();
# Show current scope
Pry\Session::getCurrent()->executeShellCommand(new Pry\Command\WhereAmI('whereami'));
# Show 'help' hint
Pry\Session::getCurrent()->printGreeting();
# Read shell commands until the user exits (Ctrl-D)
while (Pry\Session::getCurrent()->readShellCommand()) {
    # Try to execute command (internal commands)
    if (Pry\Session::getCurrent()->executeLastShellCommand()) {
        continue;
    }
    # Unable to execute command (no internal command) -> eval user input
    Pry\Session::getCurrent()->getOutputBuffer()->begin();
    eval(Pry\Session::getCurrent()->getLastShellCommand()->getUserInput());
    Pry\Session::getCurrent()->getOutputBuffer()->end();
    # Publicize local variables
    Pry\Session::getCurrent()->setDefinedVariables(get_defined_vars());
}
# Destroy current session
Pry\Session::destroy();