public function afterTraverse(array $nodes)
{
// Parse code as PHP 5
try {
$stmts = $this->parser5->parse($this->visitor->getCode());
} catch (PhpParserError $e) {
$this->addSpot('WARNING', true, 'Parse failed as PHP 5 "' . $e->getMessage() . '"', $e->getStartLine());
return;
}
// Compare
$this->ast2plain($stmts, $this->plain5);
$this->normalizeNodeList($this->plain5);
$this->normalizeNodeList($this->plain7);
$diff = array_diff_assoc($this->plain5, $this->plain7);
$lset = [];
foreach ($diff as $i => $name) {
// TODO we do like double-? in PHP 7 such as `$line = $this->lines[$i] ?? 0;`
$line = isset($this->lines[$i]) ? $this->lines[$i] : 0;
if (isset($lset[$line])) {
continue;
}
$lset[$line] = true;
$this->addSpot('WARNING', true, 'Different behavior between PHP 5/7', $line);
}
}