Add "kind" attribute to Stmt\Exit_

Attribute specifies whether this is a "die" or an "exit" and the
pretty printer behaves accordingly.
This commit is contained in:
Nikita Popov 2016-03-09 20:20:36 +01:00
parent 7eac2cfd8b
commit 47c342a3e4
3 changed files with 9 additions and 4 deletions

View File

@ -201,6 +201,10 @@ class Lexer
$endAttributes['endFilePos'] = $this->filePos - 1;
}
if ($token[0] === T_EXIT) {
$startAttributes['kind'] = strtolower($token[1]);
}
return $this->tokenMap[$token[0]];
}
}

View File

@ -493,7 +493,8 @@ class Standard extends PrettyPrinterAbstract
}
public function pExpr_Exit(Expr\Exit_ $node) {
return 'die' . (null !== $node->expr ? '(' . $this->p($node->expr) . ')' : '');
return $node->getAttribute('kind', 'die')
. (null !== $node->expr ? '(' . $this->p($node->expr) . ')' : '');
}
public function pExpr_Yield(Expr\Yield_ $node) {

View File

@ -19,9 +19,9 @@ isset($a, $a[$b]);
empty($a);
empty('foo');
unset($a, $a[$b]);
die;
die;
die(1);
exit;
exit;
exit(1);
die;
die;
die('foo');