Mercurial > hg > cmmr2012-drupal-site
comparison vendor/psy/psysh/src/Command/ParseCommand.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 |
---|---|
95 new InputOption('depth', '', InputOption::VALUE_REQUIRED, 'Depth to parse.', 10), | 95 new InputOption('depth', '', InputOption::VALUE_REQUIRED, 'Depth to parse.', 10), |
96 ]; | 96 ]; |
97 | 97 |
98 if ($this->parserFactory->hasKindsSupport()) { | 98 if ($this->parserFactory->hasKindsSupport()) { |
99 $msg = 'One of PhpParser\\ParserFactory constants: ' | 99 $msg = 'One of PhpParser\\ParserFactory constants: ' |
100 . implode(', ', ParserFactory::getPossibleKinds()) | 100 . \implode(', ', ParserFactory::getPossibleKinds()) |
101 . " (default is based on current interpreter's version)."; | 101 . " (default is based on current interpreter's version)."; |
102 $defaultKind = $this->parserFactory->getDefaultKind(); | 102 $defaultKind = $this->parserFactory->getDefaultKind(); |
103 | 103 |
104 $definition[] = new InputOption('kind', '', InputOption::VALUE_REQUIRED, $msg, $defaultKind); | 104 $definition[] = new InputOption('kind', '', InputOption::VALUE_REQUIRED, $msg, $defaultKind); |
105 } | 105 } |
126 * {@inheritdoc} | 126 * {@inheritdoc} |
127 */ | 127 */ |
128 protected function execute(InputInterface $input, OutputInterface $output) | 128 protected function execute(InputInterface $input, OutputInterface $output) |
129 { | 129 { |
130 $code = $input->getArgument('code'); | 130 $code = $input->getArgument('code'); |
131 if (strpos('<?', $code) === false) { | 131 if (\strpos('<?', $code) === false) { |
132 $code = '<?php ' . $code; | 132 $code = '<?php ' . $code; |
133 } | 133 } |
134 | 134 |
135 $parserKind = $this->parserFactory->hasKindsSupport() ? $input->getOption('kind') : null; | 135 $parserKind = $this->parserFactory->hasKindsSupport() ? $input->getOption('kind') : null; |
136 $depth = $input->getOption('depth'); | 136 $depth = $input->getOption('depth'); |
151 private function parse(Parser $parser, $code) | 151 private function parse(Parser $parser, $code) |
152 { | 152 { |
153 try { | 153 try { |
154 return $parser->parse($code); | 154 return $parser->parse($code); |
155 } catch (\PhpParser\Error $e) { | 155 } catch (\PhpParser\Error $e) { |
156 if (strpos($e->getMessage(), 'unexpected EOF') === false) { | 156 if (\strpos($e->getMessage(), 'unexpected EOF') === false) { |
157 throw $e; | 157 throw $e; |
158 } | 158 } |
159 | 159 |
160 // If we got an unexpected EOF, let's try it again with a semicolon. | 160 // If we got an unexpected EOF, let's try it again with a semicolon. |
161 return $parser->parse($code . ';'); | 161 return $parser->parse($code . ';'); |
169 * | 169 * |
170 * @return Parser | 170 * @return Parser |
171 */ | 171 */ |
172 private function getParser($kind = null) | 172 private function getParser($kind = null) |
173 { | 173 { |
174 if (!array_key_exists($kind, $this->parsers)) { | 174 if (!\array_key_exists($kind, $this->parsers)) { |
175 $this->parsers[$kind] = $this->parserFactory->createParser($kind); | 175 $this->parsers[$kind] = $this->parserFactory->createParser($kind); |
176 } | 176 } |
177 | 177 |
178 return $this->parsers[$kind]; | 178 return $this->parsers[$kind]; |
179 } | 179 } |