Issues (11)

src/Console/Command/Publish.php (3 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ReliqArts\Docweaver\Console\Command;
6
7
use Carbon\Carbon;
8
use ReliqArts\Docweaver\Exception\InvalidDirectory;
9
10
class Publish extends SingleProductCommand
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'docweaver:publish
18
                            {product? : Product name}
19
                            {source? : Product repository}
20
                            {--y|y : Whether to skip confirmation}
21
                            ';
22
23
    /**
24
     * The console command description.
25
     *
26
     * @var string
27
     */
28
    protected $description = 'Publish documentation for product';
29
30
    /**
31
     * Execute the console command.
32
     *
33
     * @throws InvalidDirectory
34
     */
35
    public function handle(): void
36
    {
37
        $productName = $this->argument('product');
38
        $productSource = $this->argument('source');
39
        $skipConfirmation = $this->option('y');
40
        $confirmationMessage = sprintf(
41
            "This command will attempt to pull documentation for product (%s) from %s}. \n"
42
            . 'Please ensure your internet connection is stable. Ready?',
43
            $productName,
0 ignored issues
show
It seems like $productName can also be of type string[]; however, parameter $args of sprintf() 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

43
            /** @scrutinizer ignore-type */ $productName,
Loading history...
44
            $productSource
45
        );
46
47
        $this->comment(PHP_EOL
48
            . "<info>♣♣♣</info> Docweaver DocumentationPublisher \n"
49
            . 'Help is here, try: php artisan docweaver:publish --help');
50
51
        if ($skipConfirmation || $this->confirm($confirmationMessage)) {
52
            $this->info("Publishing {$productName}.\nT: " . Carbon::now()->toCookieString() . '----------');
53
54
            $result = $this->publisher->publish($productName, $productSource, $this);
0 ignored issues
show
It seems like $productSource can also be of type null and string[]; however, parameter $source of ReliqArts\Docweaver\Cont...on\Publisher::publish() 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

54
            $result = $this->publisher->publish($productName, /** @scrutinizer ignore-type */ $productSource, $this);
Loading history...
It seems like $productName can also be of type null and string[]; however, parameter $productName of ReliqArts\Docweaver\Cont...on\Publisher::publish() 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

54
            $result = $this->publisher->publish(/** @scrutinizer ignore-type */ $productName, $productSource, $this);
Loading history...
55
56
            $this->displayResult($result);
57
        }
58
    }
59
}
60