X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fpsy%2Fpsysh%2Fsrc%2FShell.php;h=2a82facdd9dbaacedf60110731e2b46eace315aa;hp=47a32ae7f888f13829959b6bd0c13487de907c47;hb=419f97be044f1aebd0713921ee604841127e9e84;hpb=052617e40b525f8b817d84c29b1c04951f427069 diff --git a/vendor/psy/psysh/src/Shell.php b/vendor/psy/psysh/src/Shell.php index 47a32ae7f..2a82facdd 100644 --- a/vendor/psy/psysh/src/Shell.php +++ b/vendor/psy/psysh/src/Shell.php @@ -47,7 +47,7 @@ use Symfony\Component\Console\Output\OutputInterface; */ class Shell extends Application { - const VERSION = 'v0.9.3'; + const VERSION = 'v0.9.4'; const PROMPT = '>>> '; const BUFF_PROMPT = '... '; @@ -118,14 +118,14 @@ class Shell extends Application * @see Psy\debug * @deprecated will be removed in 1.0. Use \Psy\debug instead * - * @param array $vars Scope variables from the calling context (default: array()) - * @param object $boundObject Bound object ($this) value for the shell + * @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 */ - public static function debug(array $vars = [], $boundObject = null) + public static function debug(array $vars = [], $bindTo = null) { - return \Psy\debug($vars, $boundObject); + return \Psy\debug($vars, $bindTo); } /** @@ -392,13 +392,14 @@ class Shell extends Application } // handle empty input - if (trim($input) === '') { + if (trim($input) === '' && !$this->codeBufferOpen) { continue; } $input = $this->onInput($input); - if ($this->hasCommand($input)) { + // If the input isn't in an open string or comment, check for commands to run. + if ($this->hasCommand($input) && !$this->inputInOpenStringOrComment($input)) { $this->addHistory($input); $this->runCommand($input); @@ -409,6 +410,28 @@ class Shell extends Application } while (!$this->hasValidCode()); } + /** + * Check whether the code buffer (plus current input) is in an open string or comment. + * + * @param string $input current line of input + * + * @return bool true if the input is in an open string or comment + */ + private function inputInOpenStringOrComment($input) + { + if (!$this->hasCode()) { + return; + } + + $code = $this->codeBuffer; + array_push($code, $input); + $tokens = @token_get_all('context->getBoundObject(); } + /** + * Set the bound class (self) for the interactive shell. + * + * @param string|null $boundClass + */ + public function setBoundClass($boundClass) + { + $this->context->setBoundClass($boundClass); + } + + /** + * Get the bound class (self) for the interactive shell. + * + * @return string|null + */ + public function getBoundClass() + { + return $this->context->getBoundClass(); + } + /** * Add includes, to be parsed and executed before running the interactive shell. * @@ -945,7 +988,7 @@ class Shell extends Application } $message = preg_replace( - "#(\\w:)?(/\\w+)*/src/ExecutionClosure.php\(\d+\) : eval\(\)'d code#", + "#(\\w:)?(/\\w+)*/src/Execution(?:Loop)?Closure.php\(\d+\) : eval\(\)'d code#", "eval()'d code", str_replace('\\', '/', $message) ); @@ -1089,9 +1132,8 @@ class Shell extends Application */ protected function hasCommand($input) { - $input = new StringInput($input); - if ($name = $input->getFirstArgument()) { - return $this->has($name); + if (preg_match('/([^\s]+?)(?:\s|$)/A', ltrim($input), $match)) { + return $this->has($match[1]); } return false;