Issues (1019)

src/Components/Apollo/Process.php (15 issues)

1
<?php
2
0 ignored issues
show
Missing file doc comment
Loading history...
3
namespace Hhxsv5\LaravelS\Components\Apollo;
4
5
use Hhxsv5\LaravelS\Console\Portal;
6
use Hhxsv5\LaravelS\Swoole\Coroutine\Context;
7
use Hhxsv5\LaravelS\Swoole\Process\CustomProcessInterface;
8
use Swoole\Coroutine;
9
use Swoole\Http\Server;
10
use Swoole\Process as SwooleProcess;
11
12
class Process implements CustomProcessInterface
0 ignored issues
show
Missing doc comment for class Process
Loading history...
13
{
14
    /**@var Client $apollo */
0 ignored issues
show
The open comment tag must be the only content on the line
Loading history...
Missing short description in doc comment
Loading history...
The close comment tag must be the only content on the line
Loading history...
15
    protected static $apollo;
16
17
    public static function getDefinition()
0 ignored issues
show
Missing doc comment for function getDefinition()
Loading history...
18
    {
19
        return [
20
            'apollo' => [
21
                'class'    => static::class,
22
                'redirect' => false,
23
                'pipe'     => 0,
24
                'enable'   => (bool)getenv('ENABLE_APOLLO'),
25
            ],
26
        ];
27
    }
28
29
    public static function callback(Server $swoole, SwooleProcess $process)
0 ignored issues
show
Missing doc comment for function callback()
Loading history...
30
    {
31
        $filename = base_path('.env');
0 ignored issues
show
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

31
        $filename = /** @scrutinizer ignore-call */ base_path('.env');
Loading history...
32
        if (isset($_ENV['_ENV'])) {
33
            $filename .= '.' . $_ENV['_ENV'];
34
        }
35
36
        self::$apollo = Client::createFromEnv();
37
        self::$apollo->startWatchNotification(function (array $notifications) use ($process, $filename) {
0 ignored issues
show
The parameter $notifications is not used and could be removed. ( Ignorable by Annotation )

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

37
        self::$apollo->startWatchNotification(function (/** @scrutinizer ignore-unused */ array $notifications) use ($process, $filename) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
The import $process is not used and could be removed.

This check looks for imports that have been defined, but are not used in the scope.

Loading history...
38
            $configs = self::$apollo->pullAllAndSave($filename);
39
            app('log')->info('[ApolloProcess] Pull all configurations', $configs);
0 ignored issues
show
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

39
            /** @scrutinizer ignore-call */ 
40
            app('log')->info('[ApolloProcess] Pull all configurations', $configs);
Loading history...
40
            Portal::runLaravelSCommand(base_path(), 'reload');
0 ignored issues
show
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

40
            Portal::runLaravelSCommand(/** @scrutinizer ignore-call */ base_path(), 'reload');
Loading history...
41
            if (Context::inCoroutine()) {
42
                Coroutine::sleep(5);
43
            } else {
44
                sleep(5);
45
            }
46
        });
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
47
    }
48
49
    public static function onReload(Server $swoole, SwooleProcess $process)
0 ignored issues
show
Missing doc comment for function onReload()
Loading history...
50
    {
51
        // Stop the process...
52
        self::$apollo->stopWatchNotification();
53
    }
54
}