private function fixEchoToPrint(Tokens $tokens, $index)
{
/*
* HHVM parses '<?=' as T_ECHO instead of T_OPEN_TAG_WITH_ECHO
*
* @see https://github.com/facebook/hhvm/issues/4809
* @see https://github.com/facebook/hhvm/issues/7161
*/
if (defined('HHVM_VERSION') && 0 === strpos($tokens[$index]->getContent(), '<?=')) {
return;
}
$nextTokenIndex = $tokens->getNextMeaningfulToken($index);
$endTokenIndex = $tokens->getNextTokenOfKind($index, array(';', array(T_CLOSE_TAG)));
$canBeConverted = true;
for ($i = $nextTokenIndex; $i < $endTokenIndex; ++$i) {
if ($tokens[$i]->equalsAny(array('(', array(CT::T_ARRAY_SQUARE_BRACE_OPEN)))) {
$blockType = Tokens::detectBlockType($tokens[$i]);
$i = $tokens->findBlockEnd($blockType['type'], $i);
}
if ($tokens[$i]->equals(',')) {
$canBeConverted = false;
break;
}
}
if (false === $canBeConverted) {
return;
}
$tokens->overrideAt($index, array(T_PRINT, 'print'));
}