private function fixWhiteSpaceAroundOperator(Tokens $tokens, $index)
{
if ($tokens[$index]->isGivenKind(T_DOUBLE_ARROW)) {
if (true === $this->configuration['align_double_arrow']) {
if (!isset($this->alignFixerHelpers['align_double_arrow'])) {
$this->alignFixerHelpers['align_double_arrow'] = new AlignDoubleArrowFixerHelper();
}
return;
} elseif (null === $this->configuration['align_double_arrow']) {
return;
// configured not to touch the whitespace around the operator
}
} elseif ($tokens[$index]->equals('=')) {
if (true === $this->configuration['align_equals']) {
if (!isset($this->alignFixerHelpers['align_equals'])) {
$this->alignFixerHelpers['align_equals'] = new AlignEqualsFixerHelper();
}
return;
} elseif (null === $this->configuration['align_equals']) {
return;
// configured not to touch the whitespace around the operator
}
}
// fix white space after operator
if ($tokens[$index + 1]->isWhitespace()) {
$content = $tokens[$index + 1]->getContent();
if (' ' !== $content && false === strpos($content, "\n") && !$tokens[$tokens->getNextNonWhitespace($index + 1)]->isComment()) {
$tokens[$index + 1]->setContent(' ');
}
} else {
$tokens->insertAt($index + 1, new Token(array(T_WHITESPACE, ' ')));
}
// fix white space before operator
if ($tokens[$index - 1]->isWhitespace()) {
$content = $tokens[$index - 1]->getContent();
if (' ' !== $content && false === strpos($content, "\n") && !$tokens[$tokens->getPrevNonWhitespace($index - 1)]->isComment()) {
$tokens[$index - 1]->setContent(' ');
}
} else {
$tokens->insertAt($index, new Token(array(T_WHITESPACE, ' ')));
}
}