Completed
Pull Request — master (#597)
by Mateusz
03:12
created

SymfonyProcessFixer::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
/**
3
 * SymfonyProcessFixer implements a workaround to make Symfony Process not kill itself when we
4
 * trap a Unix signal.
5
 *
6
 * Process is relying on error_get_last to learn if the stream reading was interrupted by a signal
7
 * (see UnixSignal's readAndWrite, the hasSystemCallBeenInterrupted call). Unfortunately this doesn't
8
 * work if we trapp the signal, which wipes out the error, which makes Process think it's some
9
 * other kind of error which makes it commit suicide for no good reason.
10
 *
11
 * Workaround is to avoid blocking stream_select as ->run nor ->wait do. Fortunately we can call
12
 * ->isRunning instead, which uses a non-blocking readPipes via updateStatus. This means our callback
13
 * will still get called if we loop over ->isRunning.
14
 */
15
class SymfonyProcessFixer extends \Symfony\Component\Process\Process {
16
	public function run($callback = null) {
17
		parent::start($callback);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (start() instead of run()). Are you sure this is correct? If so, you might want to change this to $this->start().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
18
		while(parent::isRunning()) {
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (isRunning() instead of run()). Are you sure this is correct? If so, you might want to change this to $this->isRunning().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
19
			parent::checkTimeout();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (checkTimeout() instead of run()). Are you sure this is correct? If so, you might want to change this to $this->checkTimeout().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
20
			sleep(1);
21
		}
22
	}
23
}
24