private function expandElement(Tokens $tokens, $startIndex, $endIndex)
{
$divisionContent = null;
if ($tokens[$startIndex - 1]->isWhitespace()) {
$divisionContent = $tokens[$startIndex - 1]->getContent();
if (preg_match('#(\\n|\\r\\n)#', $divisionContent, $matches)) {
$divisionContent = $matches[0] . trim($divisionContent, "\r\n");
}
}
// iterate variables to split up
for ($i = $endIndex - 1; $i > $startIndex; --$i) {
$token = $tokens[$i];
if ($token->equals(')')) {
$i = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $i, false);
continue;
}
if ($token->isGivenKind(CT::T_ARRAY_SQUARE_BRACE_CLOSE)) {
$i = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, $i, false);
continue;
}
if (!$tokens[$i]->equals(',')) {
continue;
}
$token->setContent(';');
if ($tokens[$i + 1]->isWhitespace()) {
$tokens[$i + 1]->clear();
}
if ($divisionContent) {
$tokens->insertAt($i + 1, new Token(array(T_WHITESPACE, $divisionContent)));
}
// collect modifiers
$sequence = $this->getModifiersSequences($tokens, $startIndex, $endIndex);
$tokens->insertAt($i + 2, $sequence);
}
}