Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Push — poc-upload-non-breaking ( b1fecd...2ebadc )
by Pedro
13:26
created

Version::getPackageVersionsFromComposer2()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 3
eloc 4
c 1
b 1
f 0
nc 3
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Backpack\CRUD\app\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Symfony\Component\Process\Exception\ProcessFailedException;
7
use Symfony\Component\Process\Process;
8
9
class Version extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'backpack:version';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Show the version of PHP and Backpack packages.';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return mixed
29
     */
30
    public function handle()
31
    {
32
        $this->comment('### PHP VERSION:');
33
        $this->runConsoleCommand(['php', '-v']);
0 ignored issues
show
Bug introduced by
array('php', '-v') of type array<integer,string> is incompatible with the type string expected by parameter $command of Backpack\CRUD\app\Consol...on::runConsoleCommand(). ( Ignorable by Annotation )

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

33
        $this->runConsoleCommand(/** @scrutinizer ignore-type */ ['php', '-v']);
Loading history...
34
35
        $this->comment('### LARAVEL VERSION:');
36
        $this->line(\PackageVersions\Versions::getVersion('laravel/framework'));
37
        $this->line('');
38
39
        $this->comment('### BACKPACK PACKAGE VERSIONS:');
40
        foreach (\PackageVersions\Versions::VERSIONS as $package => $version) {
41
            if (substr($package, 0, 9) == 'backpack/') {
42
                $this->line($package.': '.strtok($version, '@'));
43
            }
44
        }
45
    }
46
47
    /**
48
     * Run a shell command in a separate process.
49
     *
50
     * @param  string  $command  Text to be executed.
51
     * @return void
52
     */
53
    private function runConsoleCommand($command)
54
    {
55
        $process = new Process($command, null, null, null, 60, null);
0 ignored issues
show
Unused Code introduced by
The call to Symfony\Component\Process\Process::__construct() has too many arguments starting with null. ( Ignorable by Annotation )

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

55
        $process = /** @scrutinizer ignore-call */ new Process($command, null, null, null, 60, null);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
$command of type string is incompatible with the type array expected by parameter $command of Symfony\Component\Process\Process::__construct(). ( Ignorable by Annotation )

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

55
        $process = new Process(/** @scrutinizer ignore-type */ $command, null, null, null, 60, null);
Loading history...
56
        $process->run(function ($type, $buffer) {
57
            if (Process::ERR === $type) {
58
                $this->line($buffer);
59
            } else {
60
                $this->line($buffer);
61
            }
62
        });
63
64
        // executes after the command finishes
65
        if (! $process->isSuccessful()) {
66
            throw new ProcessFailedException($process);
67
        }
68
    }
69
}
70