Skip to content

Commit

Permalink
[Console] OutputFormatter: move strtolower to createStyleFromString
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ogizanagi committed Dec 15, 2018
1 parent d1bf595 commit 8e2bd35
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Symfony/Component/Console/Formatter/OutputFormatter.php
Expand Up @@ -157,7 +157,7 @@ public function format($message)
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);
Expand Down Expand Up @@ -203,13 +203,14 @@ private function createStyleFromString($string)
$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 {
Expand Down

0 comments on commit 8e2bd35

Please sign in to comment.