Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0021ef

Browse files
committed
Merge branch '2.2'
# Conflicts: # tests/Console/Command/DescribeCommandTest.php
2 parents b22b513 + 801e787 commit e0021ef

5 files changed

Lines changed: 23 additions & 10 deletions

File tree

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ Choose from the list of available rules:
513513

514514
Configuration options:
515515

516-
- ``syntax`` (``'long'``, ``'short'``): whether to use the ``long`` or ``short``
517-
``list`` syntax; defaults to ``'long'``
516+
- ``syntax`` (``'long'``, ``'short'``): whether to use the ``long`` or ``short`` ``list``
517+
syntax; defaults to ``'long'``
518518

519519
* **lowercase_cast** [@Symfony]
520520

src/Console/Command/CommandHelp.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,10 @@ function (FixerInterface $a, FixerInterface $b) {
354354
$description = '[n/a]';
355355
}
356356

357-
$description = wordwrap($description, 72, "\n | ");
358-
$description = str_replace('`', '``', $description);
357+
$description = implode("\n | ", self::wordwrap(
358+
preg_replace('/(`.+?`)/', '<info>$1</info>', $description),
359+
72
360+
));
359361

360362
if (!empty($sets)) {
361363
$help .= sprintf(" * <comment>%s</comment> [%s]\n | %s\n", $fixer->getName(), implode(', ', $sets), $description);
@@ -366,7 +368,11 @@ function (FixerInterface $a, FixerInterface $b) {
366368
if ($fixer->isRisky()) {
367369
$help .= sprintf(
368370
" | *Risky rule: %s.*\n",
369-
str_replace('`', '``', lcfirst(preg_replace('/\.$/', '', $fixer->getDefinition()->getRiskyDescription())))
371+
preg_replace(
372+
'/(`.+?`)/',
373+
'<info>$1</info>',
374+
lcfirst(preg_replace('/\.$/', '', $fixer->getDefinition()->getRiskyDescription()))
375+
)
370376
);
371377
}
372378

@@ -399,7 +405,11 @@ function (FixerOptionInterface $optionA, FixerOptionInterface $optionB) {
399405
$line .= ' (<comment>'.implode('</comment>, <comment>', $allowed).'</comment>)';
400406
}
401407

402-
$line .= ': '.str_replace('`', '``', lcfirst(preg_replace('/\.$/', '', $option->getDescription()))).'; ';
408+
$line .= ': '.preg_replace(
409+
'/(`.+?`)/',
410+
'<info>$1</info>',
411+
lcfirst(preg_replace('/\.$/', '', $option->getDescription()))
412+
).'; ';
403413
if ($option->hasDefault()) {
404414
$line .= 'defaults to <comment>'.self::toString($option->getDefault()).'</comment>';
405415
} else {
@@ -420,7 +430,8 @@ function (FixerOptionInterface $optionA, FixerOptionInterface $optionB) {
420430
}
421431
}
422432

423-
return $help;
433+
// prevent "\</foo>" from being rendered as an escaped literal style tag
434+
return preg_replace('#\\\\(</.*?>)#', '<<$1', $help);
424435
}
425436

426437
/**

src/Console/Command/DescribeCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ private function describeRule(OutputInterface $output, $name)
169169
$line .= ' (<comment>'.implode('</comment>, <comment>', $allowed).'</comment>)';
170170
}
171171

172-
$line .= ': '.lcfirst(preg_replace('/\.$/', '', $option->getDescription())).'; ';
172+
$description = preg_replace('/(`.+?`)/', '<info>$1</info>', $option->getDescription());
173+
$line .= ': '.lcfirst(preg_replace('/\.$/', '', $description)).'; ';
173174
if ($option->hasDefault()) {
174175
$line .= sprintf(
175176
'defaults to <comment>%s</comment>',

src/Console/Command/ReadmeCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
214214
$help = str_replace('%command.full_name%', 'php-cs-fixer.phar '.$command->getName(), $help);
215215
$help = str_replace('%command.name%', $command->getName(), $help);
216216
$help = preg_replace('#</?(comment|info)>#', '``', $help);
217+
$help = preg_replace('#`(``.+?``)`#', '$1', $help);
217218
$help = preg_replace('#^(\s+)``(.+)``$#m', '$1$2', $help);
218219
$help = preg_replace('#^ \* ``(.+)``(.*?\n)#m', "* **$1**$2\n", $help);
219220
$help = preg_replace('#^ \\| #m', ' ', $help);

tests/Console/Command/DescribeCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testExecuteOutput()
3838
Replaces bad stuff with good stuff.
3939
4040
Fixer is configurable using following options:
41-
* things (bool): enables fixing things as well; defaults to false
41+
* things (bool): enables fixing `things` as well; defaults to false
4242
4343
Fixing examples:
4444
* Example #1.
@@ -119,7 +119,7 @@ private function execute()
119119
$fixer->getPriority()->willReturn(0);
120120
$fixer->isRisky()->willReturn(false);
121121
$fixer->getConfigurationDefinition()->willReturn(new FixerConfigurationResolver([
122-
new FixerOption('things', 'Enables fixing things as well.', false, false, ['bool']),
122+
new FixerOption('things', 'Enables fixing `things` as well.', false, false, ['bool']),
123123
]));
124124
$fixer->getDefinition()->willReturn(new FixerDefinition(
125125
'Fixes stuff.',

0 commit comments

Comments
 (0)