1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Consigliere\Components\Commands; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Command as ComponentCommand; |
6
|
|
|
use Consigliere\Components\Generators\ComponentGenerator; |
7
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
|
10
|
|
|
class MakeCommand extends ComponentCommand |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* The console command name. |
14
|
|
|
* |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
protected $name = 'component:make'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* The console command description. |
21
|
|
|
* |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $description = 'Generate new component.'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Execute the console command. |
28
|
|
|
* |
29
|
|
|
* @return mixed |
30
|
|
|
*/ |
31
|
|
|
public function fire() |
32
|
|
|
{ |
33
|
|
|
$names = $this->argument('name'); |
34
|
|
|
|
35
|
|
|
foreach ($names as $name) { |
|
|
|
|
36
|
|
|
with(new ComponentGenerator($name)) |
37
|
|
|
->setFilesystem($this->laravel['files']) |
38
|
|
|
->setComponent($this->laravel['components']) |
39
|
|
|
->setConfig($this->laravel['config']) |
40
|
|
|
->setConsole($this) |
41
|
|
|
->setForce($this->option('force')) |
42
|
|
|
->setPlain($this->option('plain')) |
43
|
|
|
->generate(); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Get the console command arguments. |
49
|
|
|
* |
50
|
|
|
* @return array |
51
|
|
|
*/ |
52
|
|
|
protected function getArguments() |
53
|
|
|
{ |
54
|
|
|
return [ |
55
|
|
|
['name', InputArgument::IS_ARRAY, 'The names of components will be created.'], |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
protected function getOptions() |
60
|
|
|
{ |
61
|
|
|
return [ |
62
|
|
|
['plain', 'p', InputOption::VALUE_NONE, 'Generate a plain component (without some resources).'], |
63
|
|
|
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when component already exist.'], |
64
|
|
|
]; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.