Completed
Push — master ( 8a3baa...fa7e80 )
by Vuong
01:55
created

ParentRuntime   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 29
ccs 11
cts 13
cp 0.8462
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createProcess() 0 22 3
1
<?php
2
/**
3
 * @link https://github.com/vuongxuongminh/yii2-async
4
 * @copyright Copyright (c) 2019 Vuong Xuong Minh
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace vxm\async\runtime;
9
10
use Spatie\Async\Pool;
11
use Spatie\Async\Process\ParallelProcess;
12
use Spatie\Async\Process\Runnable;
13
use Spatie\Async\Process\SynchronousProcess;
14
use Spatie\Async\Runtime\ParentRuntime as BaseParentRuntime;
15
use Symfony\Component\Process\Process;
16
17
/**
18
 * ParentRuntime support invoke yii app in child runtime mode.
19
 *
20
 * @author Vuong Minh <[email protected]>
21
 * @since 1.0.0
22
 */
23
class ParentRuntime extends BaseParentRuntime
24
{
25
26
    /**
27
     * @inheritDoc
28
     */
29 8
    public static function createProcess($task): Runnable
30
    {
31 8
        if (!self::$isInitialised) {
32
            self::init();
33
        }
34
35 8
        list($task, $appConfigFile) = $task;
36
37 8
        if (!Pool::isSupported()) {
38
            return SynchronousProcess::create($task, self::getId());
39
        }
40
41 8
        $process = new Process(implode(' ', [
0 ignored issues
show
Documentation introduced by
implode(' ', array('exec...task), $appConfigFile)) is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42 8
            'exec php',
43 8
            self::$childProcessScript,
44 8
            self::$autoloader,
45 8
            self::encodeTask($task),
46 8
            $appConfigFile
47
        ]));
48
49 8
        return ParallelProcess::create($process, self::getId());
50
    }
51
}
52