@@ -16,8 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * @author Kevin Bond <[email protected]> |
18 | 18 | */ |
19 | -interface StyleInterface |
|
20 | -{ |
|
19 | +interface StyleInterface { |
|
21 | 20 | /** |
22 | 21 | * Formats a command title. |
23 | 22 | */ |
@@ -25,125 +25,109 @@ |
||
25 | 25 | { |
26 | 26 | private $output; |
27 | 27 | |
28 | - public function __construct(OutputInterface $output) |
|
29 | - { |
|
28 | + public function __construct(OutputInterface $output) { |
|
30 | 29 | $this->output = $output; |
31 | 30 | } |
32 | 31 | |
33 | 32 | /** |
34 | 33 | * {@inheritdoc} |
35 | 34 | */ |
36 | - public function newLine(int $count = 1) |
|
37 | - { |
|
35 | + public function newLine(int $count = 1) { |
|
38 | 36 | $this->output->write(str_repeat(\PHP_EOL, $count)); |
39 | 37 | } |
40 | 38 | |
41 | 39 | /** |
42 | 40 | * @return ProgressBar |
43 | 41 | */ |
44 | - public function createProgressBar(int $max = 0) |
|
45 | - { |
|
42 | + public function createProgressBar(int $max = 0) { |
|
46 | 43 | return new ProgressBar($this->output, $max); |
47 | 44 | } |
48 | 45 | |
49 | 46 | /** |
50 | 47 | * {@inheritdoc} |
51 | 48 | */ |
52 | - public function write($messages, bool $newline = false, int $type = self::OUTPUT_NORMAL) |
|
53 | - { |
|
49 | + public function write($messages, bool $newline = false, int $type = self::OUTPUT_NORMAL) { |
|
54 | 50 | $this->output->write($messages, $newline, $type); |
55 | 51 | } |
56 | 52 | |
57 | 53 | /** |
58 | 54 | * {@inheritdoc} |
59 | 55 | */ |
60 | - public function writeln($messages, int $type = self::OUTPUT_NORMAL) |
|
61 | - { |
|
56 | + public function writeln($messages, int $type = self::OUTPUT_NORMAL) { |
|
62 | 57 | $this->output->writeln($messages, $type); |
63 | 58 | } |
64 | 59 | |
65 | 60 | /** |
66 | 61 | * {@inheritdoc} |
67 | 62 | */ |
68 | - public function setVerbosity(int $level) |
|
69 | - { |
|
63 | + public function setVerbosity(int $level) { |
|
70 | 64 | $this->output->setVerbosity($level); |
71 | 65 | } |
72 | 66 | |
73 | 67 | /** |
74 | 68 | * {@inheritdoc} |
75 | 69 | */ |
76 | - public function getVerbosity() |
|
77 | - { |
|
70 | + public function getVerbosity() { |
|
78 | 71 | return $this->output->getVerbosity(); |
79 | 72 | } |
80 | 73 | |
81 | 74 | /** |
82 | 75 | * {@inheritdoc} |
83 | 76 | */ |
84 | - public function setDecorated(bool $decorated) |
|
85 | - { |
|
77 | + public function setDecorated(bool $decorated) { |
|
86 | 78 | $this->output->setDecorated($decorated); |
87 | 79 | } |
88 | 80 | |
89 | 81 | /** |
90 | 82 | * {@inheritdoc} |
91 | 83 | */ |
92 | - public function isDecorated() |
|
93 | - { |
|
84 | + public function isDecorated() { |
|
94 | 85 | return $this->output->isDecorated(); |
95 | 86 | } |
96 | 87 | |
97 | 88 | /** |
98 | 89 | * {@inheritdoc} |
99 | 90 | */ |
100 | - public function setFormatter(OutputFormatterInterface $formatter) |
|
101 | - { |
|
91 | + public function setFormatter(OutputFormatterInterface $formatter) { |
|
102 | 92 | $this->output->setFormatter($formatter); |
103 | 93 | } |
104 | 94 | |
105 | 95 | /** |
106 | 96 | * {@inheritdoc} |
107 | 97 | */ |
108 | - public function getFormatter() |
|
109 | - { |
|
98 | + public function getFormatter() { |
|
110 | 99 | return $this->output->getFormatter(); |
111 | 100 | } |
112 | 101 | |
113 | 102 | /** |
114 | 103 | * {@inheritdoc} |
115 | 104 | */ |
116 | - public function isQuiet() |
|
117 | - { |
|
105 | + public function isQuiet() { |
|
118 | 106 | return $this->output->isQuiet(); |
119 | 107 | } |
120 | 108 | |
121 | 109 | /** |
122 | 110 | * {@inheritdoc} |
123 | 111 | */ |
124 | - public function isVerbose() |
|
125 | - { |
|
112 | + public function isVerbose() { |
|
126 | 113 | return $this->output->isVerbose(); |
127 | 114 | } |
128 | 115 | |
129 | 116 | /** |
130 | 117 | * {@inheritdoc} |
131 | 118 | */ |
132 | - public function isVeryVerbose() |
|
133 | - { |
|
119 | + public function isVeryVerbose() { |
|
134 | 120 | return $this->output->isVeryVerbose(); |
135 | 121 | } |
136 | 122 | |
137 | 123 | /** |
138 | 124 | * {@inheritdoc} |
139 | 125 | */ |
140 | - public function isDebug() |
|
141 | - { |
|
126 | + public function isDebug() { |
|
142 | 127 | return $this->output->isDebug(); |
143 | 128 | } |
144 | 129 | |
145 | - protected function getErrorOutput() |
|
146 | - { |
|
130 | + protected function getErrorOutput() { |
|
147 | 131 | if (!$this->output instanceof ConsoleOutputInterface) { |
148 | 132 | return $this->output; |
149 | 133 | } |
@@ -16,8 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * @author Konstantin Kudryashov <[email protected]> |
18 | 18 | */ |
19 | -interface OutputFormatterInterface |
|
20 | -{ |
|
19 | +interface OutputFormatterInterface { |
|
21 | 20 | /** |
22 | 21 | * Sets the decorated flag. |
23 | 22 | */ |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @author Jean-François Simon <[email protected]> |
19 | 19 | */ |
20 | -class OutputFormatterStyleStack implements ResetInterface |
|
21 | -{ |
|
20 | +class OutputFormatterStyleStack implements ResetInterface { |
|
22 | 21 | /** |
23 | 22 | * @var OutputFormatterStyleInterface[] |
24 | 23 | */ |
@@ -26,8 +25,7 @@ discard block |
||
26 | 25 | |
27 | 26 | private $emptyStyle; |
28 | 27 | |
29 | - public function __construct(OutputFormatterStyleInterface $emptyStyle = null) |
|
30 | - { |
|
28 | + public function __construct(OutputFormatterStyleInterface $emptyStyle = null) { |
|
31 | 29 | $this->emptyStyle = $emptyStyle ?? new OutputFormatterStyle(); |
32 | 30 | $this->reset(); |
33 | 31 | } |
@@ -35,16 +33,14 @@ discard block |
||
35 | 33 | /** |
36 | 34 | * Resets stack (ie. empty internal arrays). |
37 | 35 | */ |
38 | - public function reset() |
|
39 | - { |
|
36 | + public function reset() { |
|
40 | 37 | $this->styles = []; |
41 | 38 | } |
42 | 39 | |
43 | 40 | /** |
44 | 41 | * Pushes a style in the stack. |
45 | 42 | */ |
46 | - public function push(OutputFormatterStyleInterface $style) |
|
47 | - { |
|
43 | + public function push(OutputFormatterStyleInterface $style) { |
|
48 | 44 | $this->styles[] = $style; |
49 | 45 | } |
50 | 46 | |
@@ -55,8 +51,7 @@ discard block |
||
55 | 51 | * |
56 | 52 | * @throws InvalidArgumentException When style tags incorrectly nested |
57 | 53 | */ |
58 | - public function pop(OutputFormatterStyleInterface $style = null) |
|
59 | - { |
|
54 | + public function pop(OutputFormatterStyleInterface $style = null) { |
|
60 | 55 | if (empty($this->styles)) { |
61 | 56 | return $this->emptyStyle; |
62 | 57 | } |
@@ -81,8 +76,7 @@ discard block |
||
81 | 76 | * |
82 | 77 | * @return OutputFormatterStyle |
83 | 78 | */ |
84 | - public function getCurrent() |
|
85 | - { |
|
79 | + public function getCurrent() { |
|
86 | 80 | if (empty($this->styles)) { |
87 | 81 | return $this->emptyStyle; |
88 | 82 | } |
@@ -93,8 +87,7 @@ discard block |
||
93 | 87 | /** |
94 | 88 | * @return $this |
95 | 89 | */ |
96 | - public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle) |
|
97 | - { |
|
90 | + public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle) { |
|
98 | 91 | $this->emptyStyle = $emptyStyle; |
99 | 92 | |
100 | 93 | return $this; |
@@ -103,8 +96,7 @@ discard block |
||
103 | 96 | /** |
104 | 97 | * @return OutputFormatterStyleInterface |
105 | 98 | */ |
106 | - public function getEmptyStyle() |
|
107 | - { |
|
99 | + public function getEmptyStyle() { |
|
108 | 100 | return $this->emptyStyle; |
109 | 101 | } |
110 | 102 | } |
@@ -13,8 +13,7 @@ |
||
13 | 13 | /** |
14 | 14 | * @author Tien Xuan Vo <[email protected]> |
15 | 15 | */ |
16 | -final class NullOutputFormatterStyle implements OutputFormatterStyleInterface |
|
17 | -{ |
|
16 | +final class NullOutputFormatterStyle implements OutputFormatterStyleInterface { |
|
18 | 17 | /** |
19 | 18 | * {@inheritdoc} |
20 | 19 | */ |
@@ -19,14 +19,12 @@ discard block |
||
19 | 19 | * @author Konstantin Kudryashov <[email protected]> |
20 | 20 | * @author Roland Franssen <[email protected]> |
21 | 21 | */ |
22 | -class OutputFormatter implements WrappableOutputFormatterInterface |
|
23 | -{ |
|
22 | +class OutputFormatter implements WrappableOutputFormatterInterface { |
|
24 | 23 | private $decorated; |
25 | 24 | private $styles = []; |
26 | 25 | private $styleStack; |
27 | 26 | |
28 | - public function __clone() |
|
29 | - { |
|
27 | + public function __clone() { |
|
30 | 28 | $this->styleStack = clone $this->styleStack; |
31 | 29 | foreach ($this->styles as $key => $value) { |
32 | 30 | $this->styles[$key] = clone $value; |
@@ -38,8 +36,7 @@ discard block |
||
38 | 36 | * |
39 | 37 | * @return string Escaped text |
40 | 38 | */ |
41 | - public static function escape(string $text) |
|
42 | - { |
|
39 | + public static function escape(string $text) { |
|
43 | 40 | $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text); |
44 | 41 | |
45 | 42 | return self::escapeTrailingBackslash($text); |
@@ -67,8 +64,7 @@ discard block |
||
67 | 64 | * |
68 | 65 | * @param OutputFormatterStyleInterface[] $styles Array of "name => FormatterStyle" instances |
69 | 66 | */ |
70 | - public function __construct(bool $decorated = false, array $styles = []) |
|
71 | - { |
|
67 | + public function __construct(bool $decorated = false, array $styles = []) { |
|
72 | 68 | $this->decorated = $decorated; |
73 | 69 | |
74 | 70 | $this->setStyle('error', new OutputFormatterStyle('white', 'red')); |
@@ -86,40 +82,35 @@ discard block |
||
86 | 82 | /** |
87 | 83 | * {@inheritdoc} |
88 | 84 | */ |
89 | - public function setDecorated(bool $decorated) |
|
90 | - { |
|
85 | + public function setDecorated(bool $decorated) { |
|
91 | 86 | $this->decorated = $decorated; |
92 | 87 | } |
93 | 88 | |
94 | 89 | /** |
95 | 90 | * {@inheritdoc} |
96 | 91 | */ |
97 | - public function isDecorated() |
|
98 | - { |
|
92 | + public function isDecorated() { |
|
99 | 93 | return $this->decorated; |
100 | 94 | } |
101 | 95 | |
102 | 96 | /** |
103 | 97 | * {@inheritdoc} |
104 | 98 | */ |
105 | - public function setStyle(string $name, OutputFormatterStyleInterface $style) |
|
106 | - { |
|
99 | + public function setStyle(string $name, OutputFormatterStyleInterface $style) { |
|
107 | 100 | $this->styles[strtolower($name)] = $style; |
108 | 101 | } |
109 | 102 | |
110 | 103 | /** |
111 | 104 | * {@inheritdoc} |
112 | 105 | */ |
113 | - public function hasStyle(string $name) |
|
114 | - { |
|
106 | + public function hasStyle(string $name) { |
|
115 | 107 | return isset($this->styles[strtolower($name)]); |
116 | 108 | } |
117 | 109 | |
118 | 110 | /** |
119 | 111 | * {@inheritdoc} |
120 | 112 | */ |
121 | - public function getStyle(string $name) |
|
122 | - { |
|
113 | + public function getStyle(string $name) { |
|
123 | 114 | if (!$this->hasStyle($name)) { |
124 | 115 | throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name)); |
125 | 116 | } |
@@ -130,16 +121,14 @@ discard block |
||
130 | 121 | /** |
131 | 122 | * {@inheritdoc} |
132 | 123 | */ |
133 | - public function format(?string $message) |
|
134 | - { |
|
124 | + public function format(?string $message) { |
|
135 | 125 | return $this->formatAndWrap($message, 0); |
136 | 126 | } |
137 | 127 | |
138 | 128 | /** |
139 | 129 | * {@inheritdoc} |
140 | 130 | */ |
141 | - public function formatAndWrap(?string $message, int $width) |
|
142 | - { |
|
131 | + public function formatAndWrap(?string $message, int $width) { |
|
143 | 132 | $offset = 0; |
144 | 133 | $output = ''; |
145 | 134 | $tagRegex = '[a-z][^<>]*+'; |
@@ -188,8 +177,7 @@ discard block |
||
188 | 177 | /** |
189 | 178 | * @return OutputFormatterStyleStack |
190 | 179 | */ |
191 | - public function getStyleStack() |
|
192 | - { |
|
180 | + public function getStyleStack() { |
|
193 | 181 | return $this->styleStack; |
194 | 182 | } |
195 | 183 |
@@ -18,8 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @author Konstantin Kudryashov <[email protected]> |
20 | 20 | */ |
21 | -class OutputFormatterStyle implements OutputFormatterStyleInterface |
|
22 | -{ |
|
21 | +class OutputFormatterStyle implements OutputFormatterStyleInterface { |
|
23 | 22 | private $color; |
24 | 23 | private $foreground; |
25 | 24 | private $background; |
@@ -33,24 +32,21 @@ discard block |
||
33 | 32 | * @param string|null $foreground The style foreground color name |
34 | 33 | * @param string|null $background The style background color name |
35 | 34 | */ |
36 | - public function __construct(string $foreground = null, string $background = null, array $options = []) |
|
37 | - { |
|
35 | + public function __construct(string $foreground = null, string $background = null, array $options = []) { |
|
38 | 36 | $this->color = new Color($this->foreground = $foreground ?: '', $this->background = $background ?: '', $this->options = $options); |
39 | 37 | } |
40 | 38 | |
41 | 39 | /** |
42 | 40 | * {@inheritdoc} |
43 | 41 | */ |
44 | - public function setForeground(string $color = null) |
|
45 | - { |
|
42 | + public function setForeground(string $color = null) { |
|
46 | 43 | $this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options); |
47 | 44 | } |
48 | 45 | |
49 | 46 | /** |
50 | 47 | * {@inheritdoc} |
51 | 48 | */ |
52 | - public function setBackground(string $color = null) |
|
53 | - { |
|
49 | + public function setBackground(string $color = null) { |
|
54 | 50 | $this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options); |
55 | 51 | } |
56 | 52 | |
@@ -62,8 +58,7 @@ discard block |
||
62 | 58 | /** |
63 | 59 | * {@inheritdoc} |
64 | 60 | */ |
65 | - public function setOption(string $option) |
|
66 | - { |
|
61 | + public function setOption(string $option) { |
|
67 | 62 | $this->options[] = $option; |
68 | 63 | $this->color = new Color($this->foreground, $this->background, $this->options); |
69 | 64 | } |
@@ -71,8 +66,7 @@ discard block |
||
71 | 66 | /** |
72 | 67 | * {@inheritdoc} |
73 | 68 | */ |
74 | - public function unsetOption(string $option) |
|
75 | - { |
|
69 | + public function unsetOption(string $option) { |
|
76 | 70 | $pos = array_search($option, $this->options); |
77 | 71 | if (false !== $pos) { |
78 | 72 | unset($this->options[$pos]); |
@@ -84,16 +78,14 @@ discard block |
||
84 | 78 | /** |
85 | 79 | * {@inheritdoc} |
86 | 80 | */ |
87 | - public function setOptions(array $options) |
|
88 | - { |
|
81 | + public function setOptions(array $options) { |
|
89 | 82 | $this->color = new Color($this->foreground, $this->background, $this->options = $options); |
90 | 83 | } |
91 | 84 | |
92 | 85 | /** |
93 | 86 | * {@inheritdoc} |
94 | 87 | */ |
95 | - public function apply(string $text) |
|
96 | - { |
|
88 | + public function apply(string $text) { |
|
97 | 89 | if (null === $this->handlesHrefGracefully) { |
98 | 90 | $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR') |
99 | 91 | && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100); |
@@ -14,8 +14,7 @@ |
||
14 | 14 | /** |
15 | 15 | * @author Tien Xuan Vo <[email protected]> |
16 | 16 | */ |
17 | -final class NullOutputFormatter implements OutputFormatterInterface |
|
18 | -{ |
|
17 | +final class NullOutputFormatter implements OutputFormatterInterface { |
|
19 | 18 | private $style; |
20 | 19 | |
21 | 20 | /** |
@@ -16,8 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * @author Konstantin Kudryashov <[email protected]> |
18 | 18 | */ |
19 | -interface OutputFormatterStyleInterface |
|
20 | -{ |
|
19 | +interface OutputFormatterStyleInterface { |
|
21 | 20 | /** |
22 | 21 | * Sets style foreground color. |
23 | 22 | */ |