本文整理汇总了PHP中PhpParser\Parser::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Parser::getErrors方法的具体用法?PHP Parser::getErrors怎么用?PHP Parser::getErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpParser\Parser
的用法示例。
在下文中一共展示了Parser::getErrors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tryParse
private function tryParse(Parser $parser, $code)
{
$stmts = null;
$error = null;
try {
$stmts = $parser->parse($code);
} catch (Error $error) {
}
$errors = $parser->getErrors();
return [$stmts, $errors, $error];
}
示例2: getParseOutput
private function getParseOutput(Parser $parser, $code)
{
$stmts = $parser->parse($code);
$errors = $parser->getErrors();
$output = '';
foreach ($errors as $error) {
$output .= $this->formatErrorMessage($error, $code) . "\n";
}
if (null !== $stmts) {
$dumper = new NodeDumper();
$output .= $dumper->dump($stmts);
}
return canonicalize($output);
}
示例3: testParse
/**
* @dataProvider provideTestParse
*/
public function testParse($name, $code, $expected)
{
$lexer = new Lexer\Emulative(array('usedAttributes' => array('startLine', 'endLine', 'startFilePos', 'endFilePos')));
$parser = new Parser($lexer, array('throwOnError' => false));
$stmts = $parser->parse($code);
$errors = $parser->getErrors();
$output = '';
foreach ($errors as $error) {
$output .= $this->formatErrorMessage($error, $code) . "\n";
}
if (null !== $stmts) {
$dumper = new NodeDumper();
$output .= $dumper->dump($stmts);
}
$this->assertSame($this->canonicalize($expected), $this->canonicalize($output), $name);
}