private function fixSpaceAroundToken(Tokens $tokens)
{
$controlTokens = $this->getControlTokens();
for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
$token = $tokens[$index];
// Declare tokens don't follow the same rules are other control statements
if ($token->isGivenKind(T_DECLARE)) {
$this->fixDeclareStatement($tokens, $index);
} elseif ($token->isGivenKind($controlTokens) || $token->isGivenKind(CT::T_USE_LAMBDA)) {
$nextNonWhitespaceIndex = $tokens->getNextNonWhitespace($index);
if (!$tokens[$nextNonWhitespaceIndex]->equals(':')) {
$tokens->ensureWhitespaceAtIndex($index + 1, 0, ' ');
}
$prevToken = $tokens[$index - 1];
if (!$prevToken->isWhitespace() && !$prevToken->isComment() && !$prevToken->isGivenKind(T_OPEN_TAG)) {
$tokens->ensureWhitespaceAtIndex($index - 1, 1, ' ');
}
}
}
}