Issues (1482)

src/command/Install.php (1 issue)

Labels
Severity
1
<?php
2
3
// +----------------------------------------------------------------------
4
// | ThinkLibrary 6.0 for ThinkPhP 6.0
5
// +----------------------------------------------------------------------
6
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
7
// +----------------------------------------------------------------------
8
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
9
// +----------------------------------------------------------------------
10
// | 开源协议 ( https://mit-license.org )
11
// +----------------------------------------------------------------------
12
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
13
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
14
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
15
// +----------------------------------------------------------------------
16
17
namespace DtApp\ThinkLibrary\command;
18
19
use think\console\Command;
20
use think\console\Input;
21
use think\console\input\Argument;
22
use think\console\Output;
23
24
class Install extends Command
25
{
26
    /**
27
     * 名称
28
     * @var string
29
     */
30
    protected $name;
31
32
    protected function configure()
33
    {
34
        $this->setName('dta:install');
35
        $this->setDescription("Install or update dtapp");
36
        $this->addArgument('name', Argument::OPTIONAL, 'Name', '');
37
    }
38
39
    protected function execute(Input $input, Output $output)
40
    {
41
        $this->name = trim($input->getArgument('name'));
0 ignored issues
show
It seems like $input->getArgument('name') can also be of type think\console\input\Argument; however, parameter $string of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

41
        $this->name = trim(/** @scrutinizer ignore-type */ $input->getArgument('name'));
Loading history...
42
        if (empty($this->name)) {
43
            $this->output->writeln('name of online installation cannot be empty');
44
        } else {
45
            $this->output->writeln("The specified module {$this->name} is not configured with installation rules");
46
        }
47
    }
48
}
49