HtmlOutput::disableOb()   B
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 24
rs 8.6845
cc 4
eloc 11
nc 6
nop 0
1
<?php
2
namespace tonisormisson\browsercomposer;
3
4
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
0 ignored issues
show
Bug introduced by
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
Bug introduced by
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
Bug introduced by
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
Bug introduced by
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
        }
37
        // Disable apache output buffering/compression
38
        if (function_exists('apache_setenv')) {
39
            apache_setenv('no-gzip', '1');
40
            apache_setenv('dont-vary', '1');
41
        }
42
    }
43
44
    protected function h($text)
45
    {
46
        return htmlspecialchars($text);
47
    }
48
49
    public function writeln($messages, $options = 0)
50
    {
51
        $this->write($messages, true, $options);
52
    }
53
54
    public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
55
    {
56
        $this->doWrite($messages, $newline);
57
    }
58
59
    protected function doWrite($message, $newline)
60
    {
61
62
        //echo $this->h($message);
63
        echo $message;
64
65
        if ($newline) {
66
            echo "\n";
67
        }
68
        if (ob_get_length()) {
69
            ob_flush();
70
            flush();
71
        }
72
    }
73
74
}