comparison vendor/psy/psysh/src/Command/SudoCommand.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
101 $code = $input->getArgument('code'); 101 $code = $input->getArgument('code');
102 102
103 // special case for !! 103 // special case for !!
104 if ($code === '!!') { 104 if ($code === '!!') {
105 $history = $this->readline->listHistory(); 105 $history = $this->readline->listHistory();
106 if (count($history) < 2) { 106 if (\count($history) < 2) {
107 throw new \InvalidArgumentException('No previous command to replay'); 107 throw new \InvalidArgumentException('No previous command to replay');
108 } 108 }
109 $code = $history[count($history) - 2]; 109 $code = $history[\count($history) - 2];
110 } 110 }
111 111
112 if (strpos('<?', $code) === false) { 112 if (\strpos('<?', $code) === false) {
113 $code = '<?php ' . $code; 113 $code = '<?php ' . $code;
114 } 114 }
115 115
116 $nodes = $this->traverser->traverse($this->parse($code)); 116 $nodes = $this->traverser->traverse($this->parse($code));
117 117
130 private function parse($code) 130 private function parse($code)
131 { 131 {
132 try { 132 try {
133 return $this->parser->parse($code); 133 return $this->parser->parse($code);
134 } catch (\PhpParser\Error $e) { 134 } catch (\PhpParser\Error $e) {
135 if (strpos($e->getMessage(), 'unexpected EOF') === false) { 135 if (\strpos($e->getMessage(), 'unexpected EOF') === false) {
136 throw $e; 136 throw $e;
137 } 137 }
138 138
139 // If we got an unexpected EOF, let's try it again with a semicolon. 139 // If we got an unexpected EOF, let's try it again with a semicolon.
140 return $this->parser->parse($code . ';'); 140 return $this->parser->parse($code . ';');