8000 wrap up · symfony/symfony@243d6fc · GitHub
[go: up one dir, main page]

Skip to content

Commit 243d6fc

Browse files
committed
wrap up
1 parent 3232043 commit 243d6fc

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

src/Symfony/Component/Console/Formatter/OutputFormatter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ private function createStyleFromString($string)
210210
foreach ($matches as $match) {
211211
array_shift($match);
212212

213-
if ('fg' === $match[0]) {
213+
if ('fg' == $match[0]) {
214214
$style->setForeground($match[1]);
215-
} elseif ('bg' === $match[0]) {
215+
} elseif ('bg' == $match[0]) {
216216
$style->setBackground($match[1]);
217217
} elseif ('options' === $match[0]) {
218218
preg_match_all('([^,;]+)', $match[1], $options);
@@ -221,7 +221,7 @@ private function createStyleFromString($string)
221221
try {
222222
$style->setOption($option);
223223
} catch (\InvalidArgumentException $e) {
224-
@trigger_error(sprintf('Unknown style options are deprecated since version 3.2 and will be removed in 4.0. Exception "%s".', $e->getMessage()), E_USER_DEPRECATED);
224+
trigger_error(sprintf('Unknown style options are deprecated since version 3.2 and will be removed in 4.0. Exception "%s".', $e->getMessage()), E_USER_DEPRECATED);
225225

226226
return false;
227227
}

src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Console\Tests\Formatter;
1313

14+
use Symfony\Bridge\PhpUnit\ErrorAssert;
1415
use Symfony\Component\Console\Formatter\OutputFormatter;
1516
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
1617

@@ -168,6 +169,8 @@ public function testInlineStyleOptions($tag, $expected = null, $input = null)
168169
$result = $method->invoke($formatter, $styleString);
169170
if (null === $expected) {
170171
$this->assertFalse($result);
172+
$expected = $tag.$input.'</'.$styleString.'>';
173+
$this->assertSame($expected, $formatter->format($expected));
171174
} else {
172175
/* @var OutputFormatterStyle $result */
173176
$this->assertInstanceOf(OutputFormatterStyle::class, $result);
@@ -179,9 +182,8 @@ public function testInlineStyleOptions($tag, $expected = null, $input = null)
179182
public function provideInlineStyleOptionsCases()
180183
{
181184
return array(
182-
array('<options=abc;>'),
183-
array('<options=abc,def;>'),
184185
array('<unknown=_unknown_>'),
186+
array('<unknown=_unknown_;a=1;b>'),
185187
array('<fg=green;>', "\033[32m[test]\033[39m", '[test]'),
186188
array('<fg=green;bg=blue;>', "\033[32;44ma\033[39;49m", 'a'),
187189
array('<fg=green;options=bold>', "\033[32;1mb\033[39;22m", 'b'),
@@ -191,6 +193,31 @@ public function provideInlineStyleOptionsCases()
191193
);
192194
}
193195

196+
/**
197+
* @group legacy
198+
* @dataProvider provideInlineStyleTagsWithUnknownOptions
199+
*/
200+
public function testInlineStyleOptionsUnknownAreDeprecated($tag, $option)
201+
{
202+
ErrorAssert::assertDeprecationsAreTriggered(
203+
array(sprintf('Unknown style options are deprecated since version 3.2 and will be removed in 4.0. Exception "Invalid option specified: "%s". Expected one of (bold, underscore, blink, reverse, conceal)".', $option)),
204+
function () use ($tag) {
205+
$formatter = new OutputFormatter(true);
206+
$formatter->format($tag);
207+
}
208+
);
209+
}
210+
211+
public function provideInlineStyleTagsWithUnknownOptions()
212+
{
213+
return array(
214+
array('<options=abc;>', 'abc'),
215+
array('<options=abc,def;>', 'abc'),
216+
array('<fg=green;options=xyz;>', 'xyz'),
217+
array('<fg=green;options=efg,abc>', 'efg'),
218+
);
219+
}
220+
194221
public function testNonStyleTag()
195222
{
196223
$formatter = new OutputFormatter(true);

0 commit comments

Comments
 (0)
0