Mercurial > hg > cmmr2012-drupal-site
comparison vendor/psy/psysh/src/Command/ThrowUpCommand.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 |
---|---|
123 if (!$code) { | 123 if (!$code) { |
124 // Default to last exception if nothing else was supplied | 124 // Default to last exception if nothing else was supplied |
125 return [new Arg(new Variable('_e'))]; | 125 return [new Arg(new Variable('_e'))]; |
126 } | 126 } |
127 | 127 |
128 if (strpos('<?', $code) === false) { | 128 if (\strpos('<?', $code) === false) { |
129 $code = '<?php ' . $code; | 129 $code = '<?php ' . $code; |
130 } | 130 } |
131 | 131 |
132 $nodes = $this->parse($code); | 132 $nodes = $this->parse($code); |
133 if (count($nodes) !== 1) { | 133 if (\count($nodes) !== 1) { |
134 throw new \InvalidArgumentException('No idea how to throw this'); | 134 throw new \InvalidArgumentException('No idea how to throw this'); |
135 } | 135 } |
136 | 136 |
137 $node = $nodes[0]; | 137 $node = $nodes[0]; |
138 | 138 |
159 private function parse($code) | 159 private function parse($code) |
160 { | 160 { |
161 try { | 161 try { |
162 return $this->parser->parse($code); | 162 return $this->parser->parse($code); |
163 } catch (\PhpParser\Error $e) { | 163 } catch (\PhpParser\Error $e) { |
164 if (strpos($e->getMessage(), 'unexpected EOF') === false) { | 164 if (\strpos($e->getMessage(), 'unexpected EOF') === false) { |
165 throw $e; | 165 throw $e; |
166 } | 166 } |
167 | 167 |
168 // If we got an unexpected EOF, let's try it again with a semicolon. | 168 // If we got an unexpected EOF, let's try it again with a semicolon. |
169 return $this->parser->parse($code . ';'); | 169 return $this->parser->parse($code . ';'); |