1 | <?php |
||
11 | class Command extends BaseCommand |
||
12 | { |
||
13 | /** |
||
14 | * The name and signature of the console command. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $signature = 'eloquentjs:generate |
||
19 | {--models= : Models to include in the generated javascript} |
||
20 | {--namespace=App : Namespace prefix to use with the --models option} |
||
21 | {--output=public/eloquent.js : Where to save the generated javascript file}'; |
||
22 | |||
23 | /** |
||
24 | * The console command description. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $description = 'Generate a javascript file for an Eloquent-ish API in the browser'; |
||
29 | |||
30 | /** |
||
31 | * @var InputParser |
||
32 | */ |
||
33 | protected $inputParser; |
||
34 | |||
35 | /** |
||
36 | * @var Generator |
||
37 | */ |
||
38 | protected $generator; |
||
39 | |||
40 | /** |
||
41 | * @var ClassFinder |
||
42 | */ |
||
43 | protected $classFinder; |
||
44 | |||
45 | /** |
||
46 | * @var Inspector |
||
47 | */ |
||
48 | protected $inspector; |
||
49 | |||
50 | /** |
||
51 | * Create a new command instance. |
||
52 | * |
||
53 | * @param InputParser $inputParser |
||
54 | * @param ClassFinder $classFinder |
||
55 | * @param Inspector $inspector |
||
56 | * @param Generator $generator |
||
57 | */ |
||
58 | public function __construct(InputParser $inputParser, ClassFinder $classFinder, Inspector $inspector, Generator $generator) |
||
67 | |||
68 | /** |
||
69 | * Execute the console command. |
||
70 | * |
||
71 | * @return mixed |
||
72 | */ |
||
73 | public function handle() |
||
85 | |||
86 | /** |
||
87 | * Get models to include in the eloquentjs build. |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | protected function inspectRequestedModels() |
||
95 | |||
96 | /** |
||
97 | * Get the model classes requested by the user. |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | protected function getRequestedClassNames() |
||
113 | |||
114 | /** |
||
115 | * Search the app path for any models that implement EloquentJs. |
||
116 | * |
||
117 | * @return array |
||
118 | */ |
||
119 | protected function searchAppForModels() |
||
128 | |||
129 | /** |
||
130 | * Test if the named model supports EloquentJs. |
||
131 | * |
||
132 | * @param string $className |
||
133 | * @return bool |
||
134 | */ |
||
135 | protected function isEloquentJsModel($className) |
||
139 | |||
140 | /** |
||
141 | * Get the metadata for the given model name. |
||
142 | * |
||
143 | * @param string $className |
||
144 | * @return Metadata |
||
145 | */ |
||
146 | protected function inspectModel($className) |
||
156 | |||
157 | /** |
||
158 | * Find endpoint for the named model, either from router or from user prompt. |
||
159 | * |
||
160 | * @param string $className |
||
161 | * @return string |
||
162 | */ |
||
163 | protected function findMissingEndpoint($className) |
||
175 | |||
176 | /** |
||
177 | * Print the model-endpoint mapping. |
||
178 | * |
||
179 | * @param array $models |
||
180 | * @return void |
||
181 | */ |
||
182 | protected function printMapping(array $models) |
||
191 | |||
192 | /** |
||
193 | * Prompt user to confirm. |
||
194 | * |
||
195 | * @return string |
||
196 | */ |
||
197 | protected function isConfirmed() |
||
201 | |||
202 | /** |
||
203 | * Save the generated javascript to the filesystem. |
||
204 | * |
||
205 | * @param array $models |
||
206 | * @return bool |
||
207 | */ |
||
208 | protected function writeJavascript($models) |
||
212 | } |
||
213 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.