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

Issues (869)

Branch: translatable-with-fallbacks

src/app/Console/Commands/PublishView.php (4 issues)

1
<?php
2
3
namespace Backpack\CRUD\app\Console\Commands;
4
5
use Illuminate\Console\Command;
6
7
class PublishView extends Command
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'backpack:publish';
15
16
    /**
17
     * The name and signature of the console command.
18
     *
19
     * @var string
20
     */
21
    protected $signature = 'backpack:publish
22
                            {subpath : short path to the view file (ex: fields/text)}';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'Publishes a Backpack view so you can make changes to it, for your project.';
30
31
    /**
32
     * The directory where the views will be published FROM.
33
     *
34
     * @var string
35
     */
36
    public $sourcePath = 'vendor/backpack/crud/src/resources/views/';
37
38
    /**
39
     * The directory where the views will pe published TO.
40
     *
41
     * @var string
42
     */
43
    public $destinationPath = 'resources/views/vendor/backpack/';
44
45
    /**
46
     * Create a new command instance.
47
     *
48
     * @return void
49
     */
50
    public function __construct()
51
    {
52
        parent::__construct();
53
    }
54
55
    /**
56
     * Execute the console command.
57
     *
58
     * @return mixed
59
     */
60
    public function handle()
61
    {
62
        $this->file = strtolower($this->argument('subpath'));
0 ignored issues
show
Bug Best Practice introduced by
The property file does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
63
64
        return $this->publishFile($this->file);
0 ignored issues
show
Are you sure the usage of $this->publishFile($this->file) targeting Backpack\CRUD\app\Consol...lishView::publishFile() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
65
    }
66
67
    /**
68
     * Take a blade file from the vendor folder and publish it to the resources folder.
69
     *
70
     * @param  string  $file  The filename without extension
71
     * @return void
72
     */
73
    protected function publishFile($file)
74
    {
75
        $sourceFile = $this->sourcePath.$file.'.blade.php';
76
        $copiedFile = $this->destinationPath.$file.'.blade.php';
77
78
        if (! file_exists($sourceFile)) {
79
            return $this->error(
0 ignored issues
show
Are you sure the usage of $this->error('Cannot fin...an existing view file') targeting Illuminate\Console\Command::error() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
80
                'Cannot find source view file at '
81
                .$sourceFile.
82
                ' - make sure you\'ve picked an existing view file'
83
            );
84
        } else {
85
            $canCopy = true;
86
87
            if (file_exists($copiedFile)) {
88
                $canCopy = $this->confirm(
89
                    'File already exists at '
90
                    .$copiedFile.
91
                    ' - do you want to overwrite it?'
92
                );
93
            }
94
95
            if ($canCopy) {
96
                $path = pathinfo($copiedFile);
97
98
                if (! file_exists($path['dirname'])) {
99
                    mkdir($path['dirname'], 0755, true);
100
                }
101
102
                if (copy($sourceFile, $copiedFile)) {
103
                    $this->info('Copied to '.$copiedFile);
104
                } else {
105
                    return $this->error(
0 ignored issues
show
Are you sure the usage of $this->error('Failed to ... ' for unknown reason') targeting Illuminate\Console\Command::error() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
106
                        'Failed to copy '
107
                        .$sourceFile.
108
                        ' to '
109
                        .$copiedFile.
110
                        ' for unknown reason'
111
                    );
112
                }
113
            }
114
        }
115
    }
116
}
117