Completed
Push — master ( ea15e4...6b748c )
by Michał
04:07
created

ProcessManager::removeWorker()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Phppm;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
7
class ProcessManager implements ProcessManagerInterface
8
{
9
    protected $workers;
10
11
    public function addWorker(string $process, OutputInterface $output, int $time)
12
    {
13
        $descriptorspec = [
14
            0 => ["pipe", "r"],  // stdin is a pipe that the child will read from
15
            1 => ["pipe", "w"],  // stdout is a pipe that the child will write to
16
            2 => ["file", "/tmp/error-output.txt", "a"] // stderr is a file to write to
17
        ];
18
19
        $process = proc_open('php', $descriptorspec, $this->pipes);
0 ignored issues
show
Bug introduced by
The property pipes does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
21
        dump(proc_get_status($process));
22
23
        stream_set_blocking($this->pipes[1], 0);
24
        stream_set_blocking($this->pipes[2], 0);
25
        dump($this->pipes);
26
        
27
//        fclose($this->pipes[0]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
28
//        fclose($this->pipes[1]);
29
        
30
        proc_close($process);
31
        
32
        
33
//        $this->workers[] = $worker;
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
    }
35
36
    public function removeWorker()
37
    {
38
        // TODO: Implement removeWorker() method.
39
    }
40
}
41