[Console] OutputFormatter: move strtolower to createStyleFromString

While playing with the href feature that'll be available in 4.3,
I spotted href value is lowercased. Which I guess could be an issue
on case-sensitive filesystems.
This changes nothing for the current branch, but will allow when merging
to upper branches to fix the behavior described above, hence keep original case.
This commit is contained in:
Maxime Steinhausser 2018-12-15 11:33:10 +01:00
parent d1bf595bdf
commit 8e2bd35dca

View File

@ -157,7 +157,7 @@ class OutputFormatter implements OutputFormatterInterface
if (!$open && !$tag) {
// </>
$this->styleStack->pop();
} elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
} elseif (false === $style = $this->createStyleFromString($tag)) {
$output .= $this->applyCurrentStyle($text);
} elseif ($open) {
$this->styleStack->push($style);
@ -203,13 +203,14 @@ class OutputFormatter implements OutputFormatterInterface
$style = new OutputFormatterStyle();
foreach ($matches as $match) {
array_shift($match);
$match[0] = strtolower($match[0]);
if ('fg' == $match[0]) {
$style->setForeground($match[1]);
$style->setForeground(strtolower($match[1]));
} elseif ('bg' == $match[0]) {
$style->setBackground($match[1]);
$style->setBackground(strtolower($match[1]));
} elseif ('options' === $match[0]) {
preg_match_all('([^,;]+)', $match[1], $options);
preg_match_all('([^,;]+)', strtolower($match[1]), $options);
$options = array_shift($options);
foreach ($options as $option) {
try {