Issues (67)

src/components/Composer.php (3 issues)

1
<?php
2
3
namespace hidev\components;
4
5
use hidev\helpers\Sys;
6
7
class Composer
8
{
9
    public function __construct(string $dir)
10
    {
11
        $this->dir = ($dir === getcwd() ? '' : $dir);
0 ignored issues
show
Bug Best Practice introduced by
The property dir does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
12
    }
13
14
    public function autoload()
15
    {
16
        $path =  $this->getPath('vendor/autoload.php');
17
        if (!file_exists($path)) {
18
            $this->run('update');
19
        }
20
        require $path;
21
    }
22
23
    public function dump()
24
    {
25
        $this->run('dump-autoload');
26
    }
27
28
    public function run(string $command, array $args = [])
0 ignored issues
show
The parameter $args 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

28
    public function run(string $command, /** @scrutinizer ignore-unused */ array $args = [])

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...
29
    {
30
        Sys::passthru("{$this->getCmd()} $command");
31
    }
32
33
    public function getCmd(): string
34
    {
35
        return 'composer' . ($this->dir ? " -d $dir" : '');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $dir seems to be never defined.
Loading history...
36
    }
37
38
    public function getPath(string $file): string
39
    {
40
        if (strncmp($file, '/', 1) === 0) {
41
            return $file;
42
        }
43
44
        return $this->dir ? $this->dir . DIRECTORY_SEPARATOR . $file : $file;
45
    }
46
}
47