1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Caffeinated\Modules\Console\Generators; |
4
|
|
|
|
5
|
|
|
class MakeControllerCommand extends MakeCommand |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* The name and signature of the console command. |
9
|
|
|
* |
10
|
|
|
* @var string |
11
|
|
|
*/ |
12
|
|
|
protected $signature = 'make:module:controller |
13
|
|
|
{slug : The slug of the module} |
14
|
|
|
{name : The name of the controller class} |
15
|
|
|
{--resource : Generate a module resource controller class}'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The console command description. |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $description = 'Create a new module controller class'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* String to store the command type. |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $type = 'Controller'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Module folders to be created. |
33
|
|
|
* |
34
|
|
|
* @var array |
35
|
|
|
*/ |
36
|
|
|
protected $listFolders = [ |
37
|
|
|
'Http/Controllers/' |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Module files to be created. |
42
|
|
|
* |
43
|
|
|
* @var array |
44
|
|
|
*/ |
45
|
|
|
protected $listFiles = [ |
46
|
|
|
'{{filename}}.php' |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Module signature option. |
51
|
|
|
* |
52
|
|
|
* @var array |
53
|
|
|
*/ |
54
|
|
|
protected $signOption = [ |
55
|
|
|
'resource' |
56
|
|
|
]; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Module stubs used to populate defined files. |
60
|
|
|
* |
61
|
|
|
* @var array |
62
|
|
|
*/ |
63
|
|
|
protected $listStubs = [ |
64
|
|
|
'default' => [ |
65
|
|
|
'controller.stub' |
66
|
|
|
], |
67
|
|
|
|
68
|
|
|
'resource' => [ |
69
|
|
|
'controller_resource.stub' |
70
|
|
|
] |
71
|
|
|
]; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Resolve Container after getting file path |
75
|
|
|
* |
76
|
|
|
* @param string $FilePath |
|
|
|
|
77
|
|
|
* @return Array |
78
|
|
|
*/ |
79
|
|
|
protected function resolveByPath($filePath) |
80
|
|
|
{ |
81
|
|
|
$this->container['filename'] = $this->makeFileName($filePath); |
82
|
|
|
$this->container['namespace'] = $this->getNamespace($filePath); |
83
|
|
|
$this->container['classname'] = basename($filePath); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Replace placeholder text with correct values. |
88
|
|
|
* |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
|
protected function formatContent($content) |
92
|
|
|
{ |
93
|
|
|
return str_replace( |
94
|
|
|
[ |
95
|
|
|
'{{filename}}', |
96
|
|
|
'{{namespace}}', |
97
|
|
|
'{{classname}}' |
98
|
|
|
], |
99
|
|
|
[ |
100
|
|
|
$this->container['filename'], |
101
|
|
|
$this->container['namespace'], |
102
|
|
|
$this->container['classname'] |
103
|
|
|
], |
104
|
|
|
$content |
105
|
|
|
); |
106
|
|
|
} |
107
|
|
|
} |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.