1 | <?php |
||
17 | class BufferedConsoleOutput implements ConsoleOutputInterface |
||
18 | { |
||
19 | /** @var string[] */ |
||
20 | private $buffer = []; |
||
21 | /** @var ConsoleDiff */ |
||
22 | private $diff; |
||
23 | /** @var TerminalInterface */ |
||
24 | private $terminal; |
||
25 | /** @var ConsoleOutputInterface */ |
||
26 | private $output; |
||
27 | /** @var Wrapper */ |
||
28 | private $wrapper; |
||
29 | /** @var bool */ |
||
30 | private $trim = false; |
||
31 | |||
32 | /** |
||
33 | * Constructor. |
||
34 | * |
||
35 | * @param ConsoleOutputInterface $output |
||
36 | * @param TerminalInterface $terminal |
||
37 | * @param Wrapper $wrapper |
||
38 | */ |
||
39 | public function __construct( |
||
49 | |||
50 | /** |
||
51 | * Sets information about the terminal |
||
52 | * |
||
53 | * @param TerminalInterface $terminal |
||
54 | */ |
||
55 | public function setTerminal(TerminalInterface $terminal) |
||
60 | |||
61 | /** |
||
62 | * @return TerminalInterface |
||
63 | */ |
||
64 | public function getTerminal() |
||
68 | |||
69 | /** |
||
70 | * @param string|array $messages The message as an array of lines or a single string |
||
71 | * @param bool $newline Whether to add a newline |
||
72 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
73 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
74 | */ |
||
75 | public function write($messages, $newline = false, $options = 0) |
||
80 | |||
81 | /** |
||
82 | * @param string|array $messages The message as an array of lines or a single string |
||
83 | * @param bool $newline Whether to add a newline |
||
84 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
85 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
86 | */ |
||
87 | public function reWrite($messages, $newline = false, $options = 0) |
||
109 | |||
110 | /** |
||
111 | * @param array $diff |
||
112 | * @param bool $newline |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | private function buildOutput(array $diff, $newline = false) |
||
144 | |||
145 | /** |
||
146 | * Gets the OutputInterface for errors. |
||
147 | * |
||
148 | * @return OutputInterface |
||
149 | */ |
||
150 | public function getErrorOutput() |
||
154 | |||
155 | /** |
||
156 | * Sets the OutputInterface used for errors. |
||
157 | * |
||
158 | * @param OutputInterface $error |
||
159 | */ |
||
160 | public function setErrorOutput(OutputInterface $error) |
||
164 | |||
165 | /** |
||
166 | * Writes a message to the output and adds a newline at the end. |
||
167 | * |
||
168 | * @param string|array $messages The message as an array of lines of a single string |
||
169 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
170 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
171 | */ |
||
172 | public function writeln($messages, $options = 0) |
||
176 | |||
177 | /** |
||
178 | * Sets the verbosity of the output. |
||
179 | * |
||
180 | * @param int $level The level of verbosity (one of the VERBOSITY constants) |
||
181 | */ |
||
182 | public function setVerbosity($level) |
||
186 | |||
187 | /** |
||
188 | * Gets the current verbosity of the output. |
||
189 | * |
||
190 | * @return int The current level of verbosity (one of the VERBOSITY constants) |
||
191 | */ |
||
192 | public function getVerbosity() |
||
196 | |||
197 | /** |
||
198 | * Returns whether verbosity is quiet (-q). |
||
199 | * |
||
200 | * @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise |
||
201 | */ |
||
202 | public function isQuiet() |
||
206 | |||
207 | /** |
||
208 | * Returns whether verbosity is verbose (-v). |
||
209 | * |
||
210 | * @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise |
||
211 | */ |
||
212 | public function isVerbose() |
||
216 | |||
217 | /** |
||
218 | * Returns whether verbosity is very verbose (-vv). |
||
219 | * |
||
220 | * @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise |
||
221 | */ |
||
222 | public function isVeryVerbose() |
||
226 | |||
227 | /** |
||
228 | * Returns whether verbosity is debug (-vvv). |
||
229 | * |
||
230 | * @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise |
||
231 | */ |
||
232 | public function isDebug() |
||
236 | |||
237 | /** |
||
238 | * Sets the decorated flag. |
||
239 | * |
||
240 | * @param bool $decorated Whether to decorate the messages |
||
241 | */ |
||
242 | public function setDecorated($decorated) |
||
246 | |||
247 | /** |
||
248 | * Gets the decorated flag. |
||
249 | * |
||
250 | * @return bool true if the output will decorate messages, false otherwise |
||
251 | */ |
||
252 | public function isDecorated() |
||
256 | |||
257 | /** |
||
258 | * Sets output formatter. |
||
259 | * |
||
260 | * @param OutputFormatterInterface $formatter |
||
261 | */ |
||
262 | public function setFormatter(OutputFormatterInterface $formatter) |
||
266 | |||
267 | /** |
||
268 | * Returns current output formatter instance. |
||
269 | * |
||
270 | * @return OutputFormatterInterface |
||
271 | */ |
||
272 | public function getFormatter() |
||
276 | |||
277 | /** |
||
278 | * @return bool |
||
279 | */ |
||
280 | public function isTrim() |
||
284 | |||
285 | /** |
||
286 | * Should we wrap the input or not, if this is set to false, it will trim each line |
||
287 | * |
||
288 | * @param bool $trim |
||
289 | * |
||
290 | * @return $this |
||
291 | */ |
||
292 | public function setTrim($trim) |
||
297 | } |
||
298 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.