private function writeCombinedImports(array $imports, AbstractToken $startToken) { $this->newContent .= $startToken->getContent() . $startToken->getWhitespaceAfter(); // For following imports, we use an indentation to reach the // column of the first import, so that they are neatly aligned. // // ``` // use A, // B, // C; // ``` $indentation = $startToken->findNextToken('NO_WHITESPACE')->get()->getIndentation(); $first = true; foreach ($imports as $namespace => $alias) { if (!$first) { $this->newContent .= ",\n" . $indentation; } $first = false; $this->newContent .= $namespace; if (null !== $alias) { $this->newContent .= ' as ' . $alias; } } $this->newContent .= ';'; }
private function checkLeftCurlyPlacement(AbstractToken $startToken, AbstractToken $endToken, AbstractToken $curlyToken, $config) { if ('new line on wrap' === $config) { $config = $startToken->getLine() === $endToken->getLine() ? 'same line' : 'new line'; } switch ($config) { case 'same line': if ($endToken->getLine() !== $curlyToken->getLine()) { $this->phpFile->addComment($curlyToken->getLine(), Comment::warning('coding_style.token_should_be_on_same_line', '``%token%`` should probably be on the same line like ``%end_token%``.', array('token' => $curlyToken->getContent(), 'end_token' => $endToken->getContent()))->varyIn(array())); } break; case 'new line': if ($endToken->getLine() + 1 !== $curlyToken->getLine()) { $this->phpFile->addComment($curlyToken->getLine(), Comment::warning('coding_style.token_should_be_on_new_line', '``%token`` should probably be on a new line after ``%end_token%``.', array('token' => $curlyToken->getContent(), 'end_token' => $endToken->getContent()))->varyIn(array())); } break; default: throw new \InvalidArgumentException(sprintf('Unknown left curly setting "%s".', $config)); } }