[console] Removed hardcoded empty style from styles stack.
This commit is contained in:
parent
f9aa6f7d1e
commit
0ae5a45282
@ -17,15 +17,23 @@ namespace Symfony\Component\Console\Formatter;
|
||||
class OutputFormatterStyleStack
|
||||
{
|
||||
/**
|
||||
* @var OutputFormatterStyle[]
|
||||
* @var OutputFormatterStyleInterface[]
|
||||
*/
|
||||
private $styles;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @var OutputFormatterStyleInterface
|
||||
*/
|
||||
public function __construct()
|
||||
private $emptyStyle;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $emptyStyle
|
||||
*/
|
||||
public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
|
||||
{
|
||||
$this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
@ -59,7 +67,7 @@ class OutputFormatterStyleStack
|
||||
public function pop(OutputFormatterStyleInterface $style = null)
|
||||
{
|
||||
if (empty($this->styles)) {
|
||||
return new OutputFormatterStyle();
|
||||
return $this->emptyStyle;
|
||||
}
|
||||
|
||||
if (null === $style) {
|
||||
@ -85,9 +93,29 @@ class OutputFormatterStyleStack
|
||||
public function getCurrent()
|
||||
{
|
||||
if (empty($this->styles)) {
|
||||
return new OutputFormatterStyle();
|
||||
return $this->emptyStyle;
|
||||
}
|
||||
|
||||
return $this->styles[count($this->styles)-1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $emptyStyle
|
||||
*
|
||||
* @return \Symfony\Component\Console\Formatter\OutputFormatterStyleStack
|
||||
*/
|
||||
public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
|
||||
{
|
||||
$this->emptyStyle = $emptyStyle;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\Console\Formatter\OutputFormatterStyleInterface
|
||||
*/
|
||||
public function getEmptyStyle()
|
||||
{
|
||||
return $this->emptyStyle;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user