Merge branch '2.8' into 3.0
* 2.8: [Console] SymfonyStyle: Fix alignment/prefixing of multi-line comments [Routing] Finish annotation loader taking a class constant as a beginning of a class name [Routing] Fix the annotation loader taking a class constant as a beginning of a class name
This commit is contained in:
commit
7b7c9b86a1
@ -322,7 +322,7 @@ class TextDescriptor extends Descriptor
|
|||||||
*/
|
*/
|
||||||
protected function describeContainerAlias(Alias $alias, array $options = array())
|
protected function describeContainerAlias(Alias $alias, array $options = array())
|
||||||
{
|
{
|
||||||
$options['output']->comment(sprintf("This service is an alias for the service <info>%s</info>\n", (string) $alias));
|
$options['output']->comment(sprintf('This service is an alias for the service <info>%s</info>', (string) $alias));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,16 +170,18 @@ class SymfonyStyle extends OutputStyle
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Formats a command comment.
|
||||||
|
*
|
||||||
|
* @param string|array $message
|
||||||
*/
|
*/
|
||||||
public function comment($message)
|
public function comment($message)
|
||||||
{
|
{
|
||||||
$this->autoPrependText();
|
|
||||||
|
|
||||||
$messages = is_array($message) ? array_values($message) : array($message);
|
$messages = is_array($message) ? array_values($message) : array($message);
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as &$message) {
|
||||||
$this->writeln(sprintf(' // %s', $message));
|
$message = $this->getFormatter()->format($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->block($messages, null, null, ' // ');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
|
||||||
|
|
||||||
|
//Ensure that all lines are aligned to the begin of the first one and start with '//' in a very long line comment
|
||||||
|
return function (InputInterface $input, OutputInterface $output) {
|
||||||
|
$output = new SymfonyStyleWithForcedLineLength($input, $output);
|
||||||
|
$output->comment(
|
||||||
|
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum'
|
||||||
|
);
|
||||||
|
};
|
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
// Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||||
|
// aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
|
// Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
|
||||||
|
// sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
|
||||||
|
|
@ -11,5 +11,8 @@ Lorem ipsum dolor sit amet
|
|||||||
consectetur adipiscing elit
|
consectetur adipiscing elit
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet
|
Lorem ipsum dolor sit amet
|
||||||
// Lorem ipsum dolor sit amet
|
|
||||||
// consectetur adipiscing elit
|
// Lorem ipsum dolor sit amet
|
||||||
|
//
|
||||||
|
// consectetur adipiscing elit
|
||||||
|
|
||||||
|
@ -112,7 +112,24 @@ class AnnotationFileLoader extends FileLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (T_CLASS === $token[0]) {
|
if (T_CLASS === $token[0]) {
|
||||||
$class = true;
|
// Skip usage of ::class constant
|
||||||
|
$isClassConstant = false;
|
||||||
|
for ($j = $i - 1; $j > 0; --$j) {
|
||||||
|
if (!isset($tokens[$j][1])) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (T_DOUBLE_COLON === $tokens[$j][0]) {
|
||||||
|
$isClassConstant = true;
|
||||||
|
break;
|
||||||
|
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$isClassConstant) {
|
||||||
|
$class = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (T_NAMESPACE === $token[0]) {
|
if (T_NAMESPACE === $token[0]) {
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
|
||||||
|
|
||||||
|
trait FooTrait
|
||||||
|
{
|
||||||
|
public function doBar()
|
||||||
|
{
|
||||||
|
$baz = self::class;
|
||||||
|
if (true) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -35,6 +35,16 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
|
|||||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
|
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @requires PHP 5.4
|
||||||
|
*/
|
||||||
|
public function testLoadTraitWithClassConstant()
|
||||||
|
{
|
||||||
|
$this->reader->expects($this->never())->method('getClassAnnotation');
|
||||||
|
|
||||||
|
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooTrait.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires PHP 5.6
|
* @requires PHP 5.6
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user