Passed
Push — master ( d064f7...8220d6 )
by Tõnis
02:21
created

HtmlOutput.php (4 issues)

1
<?php
2
namespace tonisormisson\browsercomposer;
3
4
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
0 ignored issues
show
The type Symfony\Component\Consol...utputFormatterInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
6
class HtmlOutput extends \Symfony\Component\Console\Output\Output
0 ignored issues
show
The type Symfony\Component\Console\Output\Output was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
{
8
9
    public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
10
    {
11
        parent::__construct($verbosity, $decorated, $formatter);
12
13
        // tell php to automatically flush after every output
14
        //$this->disableOb();
15
    }
16
17
    protected function disableOb()
18
    {
19
        // Turn off output buffering
20
        ini_set('output_buffering', 'off');
21
        // Turn off PHP output compression
22
        //ini_set('zlib.output_compression', false);
23
        // Implicitly flush the buffer(s)
24
        ini_set('implicit_flush', true);
0 ignored issues
show
true of type true is incompatible with the type string expected by parameter $newvalue of ini_set(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

24
        ini_set('implicit_flush', /** @scrutinizer ignore-type */ true);
Loading history...
25
        ob_implicit_flush(true);
0 ignored issues
show
true of type true is incompatible with the type integer expected by parameter $flag of ob_implicit_flush(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
        ob_implicit_flush(/** @scrutinizer ignore-type */ true);
Loading history...
26
        // Clear, and turn off output buffering
27
        while (ob_get_level() > 0) {
28
            // Get the curent level
29
            $level = ob_get_level();
30
            // End the buffering
31
            ob_end_clean();
32
            // If the current level has not changed, abort
33
            if (ob_get_level() == $level)
34
                break;
35
        }
36
        // Disable apache output buffering/compression
37
        if (function_exists('apache_setenv')) {
38
            apache_setenv('no-gzip', '1');
39
            apache_setenv('dont-vary', '1');
40
        }
41
    }
42
43
    protected function h($text)
44
    {
45
        return htmlspecialchars($text);
46
    }
47
48
    public function writeln($messages, $options = 0)
49
    {
50
        $this->write($messages, true, $options);
51
    }
52
53
    public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
54
    {
55
        $this->doWrite($messages, $newline);
56
    }
57
58
    protected function doWrite($message, $newline)
59
    {
60
61
        //echo $this->h($message);
62
        echo $message;
63
64
        if ($newline) {
65
            echo "\n";
66
        }
67
        if (ob_get_length()) {
68
            ob_flush();
69
            flush();
70
        }
71
    }
72
73
}