These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace DoctrineModule\Component\Console\Output; |
||
6 | |||
7 | use Symfony\Component\Console\Formatter\OutputFormatterInterface; |
||
8 | use Symfony\Component\Console\Output\Output; |
||
9 | use function function_exists; |
||
10 | use function getenv; |
||
11 | use function posix_isatty; |
||
12 | use const DIRECTORY_SEPARATOR; |
||
13 | use const PHP_EOL; |
||
14 | use const STDOUT; |
||
15 | |||
16 | /** |
||
17 | * Output writing in class member variable |
||
18 | */ |
||
19 | class PropertyOutput extends Output |
||
20 | { |
||
21 | /** @var string */ |
||
22 | private $message = ''; |
||
23 | |||
24 | /** |
||
25 | * @param null $decorated |
||
26 | */ |
||
27 | 2 | public function __construct( |
|
28 | int $verbosity = self::VERBOSITY_NORMAL, |
||
29 | $decorated = null, |
||
30 | ?OutputFormatterInterface $formatter = null |
||
31 | ) { |
||
32 | 2 | if ($decorated === null) { |
|
33 | 2 | $decorated = $this->hasColorSupport(); |
|
34 | } |
||
35 | |||
36 | 2 | parent::__construct($verbosity, $decorated, $formatter); |
|
0 ignored issues
–
show
|
|||
37 | 2 | } |
|
38 | |||
39 | // phpcs:disable SlevomatCodingStandard.TypeHints.ReturnTypeHint |
||
40 | 2 | protected function doWrite(string $message, bool $newline) |
|
41 | { |
||
42 | // phpcs:enable SlevomatCodingStandard.TypeHints.ReturnTypeHint |
||
43 | 2 | $this->message .= $message . ($newline === false ? '' : PHP_EOL); |
|
44 | 2 | } |
|
45 | |||
46 | /** |
||
47 | * @return mixed |
||
48 | */ |
||
49 | 2 | public function getMessage() |
|
50 | { |
||
51 | 2 | return $this->message; |
|
52 | } |
||
53 | |||
54 | 2 | protected function hasColorSupport() : bool |
|
55 | { |
||
56 | 2 | if (DIRECTORY_SEPARATOR === '\\') { |
|
57 | return getenv('ANSICON') !== false || getenv('ConEmuANSI') === 'ON'; |
||
58 | } |
||
59 | |||
60 | 2 | return function_exists('posix_isatty') && @posix_isatty(STDOUT); |
|
61 | } |
||
62 | } |
||
63 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.