public function shortTernaryPass(MacroTokens $tokens)
{
$res = new MacroTokens();
$inTernary = [];
while ($tokens->nextToken()) {
if ($tokens->isCurrent('?')) {
$inTernary[] = $tokens->depth;
} elseif ($tokens->isCurrent(':')) {
array_pop($inTernary);
} elseif ($tokens->isCurrent(',', ')', ']', '|') && end($inTernary) === $tokens->depth + $tokens->isCurrent(')', ']')) {
$res->append(' : NULL');
array_pop($inTernary);
}
$res->append($tokens->currentToken());
}
if ($inTernary) {
$res->append(' : NULL');
}
return $res;
}