Skip to content

Commit 50bc2eb

Browse files
committed
formatting
1 parent ac11036 commit 50bc2eb

File tree

1 file changed

+84
-26
lines changed

1 file changed

+84
-26
lines changed

src/Illuminate/Console/GeneratorCommand.php

Lines changed: 84 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,74 @@ abstract class GeneratorCommand extends Command
2828
* @var array
2929
*/
3030
protected $reservedNames = [
31-
'__halt_compiler', 'break', 'clone', 'die', 'empty', 'endswitch', 'final',
32-
'function', 'include', 'isset', 'print', 'require_once', 'trait', 'while',
33-
'abstract', 'callable', 'const', 'do', 'enddeclare', 'endwhile', 'finally',
34-
'global', 'include_once', 'list', 'private', 'return', 'try', 'xor', 'and',
35-
'case', 'continue', 'echo', 'endfor', 'eval', 'fn', 'goto', 'instanceof',
36-
'namespace', 'protected', 'static', 'unset', 'yield', 'array', 'catch',
37-
'declare', 'else', 'endforeach', 'exit', 'for', 'if', 'insteadof', 'new',
38-
'public', 'switch', 'use', 'as', 'class', 'default', 'elseif', 'endif',
39-
'extends', 'foreach', 'implements', 'interface', 'or', 'require', 'throw',
31+
'__halt_compiler',
32+
'abstract',
33+
'and',
34+
'array',
35+
'as',
36+
'break',
37+
'callable',
38+
'case',
39+
'catch',
40+
'class',
41+
'clone',
42+
'const',
43+
'continue',
44+
'declare',
45+
'default',
46+
'die',
47+
'do',
48+
'echo',
49+
'else',
50+
'elseif',
51+
'empty',
52+
'enddeclare',
53+
'endfor',
54+
'endforeach',
55+
'endif',
56+
'endswitch',
57+
'endwhile',
58+
'eval',
59+
'exit',
60+
'extends',
61+
'final',
62+
'finally',
63+
'fn',
64+
'for',
65+
'foreach',
66+
'function',
67+
'global',
68+
'goto',
69+
'if',
70+
'implements',
71+
'include',
72+
'include_once',
73+
'instanceof',
74+
'insteadof',
75+
'interface',
76+
'isset',
77+
'list',
78+
'namespace',
79+
'new',
80+
'or',
81+
'print',
82+
'private',
83+
'protected',
84+
'public',
85+
'require',
86+
'require_once',
87+
'return',
88+
'static',
89+
'switch',
90+
'throw',
91+
'trait',
92+
'try',
93+
'unset',
94+
'use',
4095
'var',
96+
'while',
97+
'xor',
98+
'yield',
4199
];
42100

43101
/**
@@ -69,11 +127,11 @@ abstract protected function getStub();
69127
*/
70128
public function handle()
71129
{
72-
// First we will check whether the name can be found in the reserved names.
73-
// We have so called "reserved names" to ensure that no files are generated
74-
// using PHP keywords for example, because that would cause errors.
130+
// First we need to ensure that the given name is not a reserved word within the PHP
131+
// language and that the class name will actually be valid. If it is not valid we
132+
// can error now and prevent from polluting the filesystem using invalid files.
75133
if ($this->isReservedName($this->getNameInput())) {
76-
$this->error('The name "'.$this->getNameInput().'" is reserved. Please pick something else.');
134+
$this->error('The name "'.$this->getNameInput().'" is reserved by PHP.');
77135

78136
return false;
79137
}
@@ -82,7 +140,7 @@ public function handle()
82140

83141
$path = $this->getPath($name);
84142

85-
// We will check to see if the class already exists. If it does, we don't want
143+
// Next, We will check to see if the class already exists. If it does, we don't want
86144
// to create the class and overwrite the user's code. So, we will bail out so the
87145
// code is untouched. Otherwise, we will continue generating this class' files.
88146
if ((! $this->hasOption('force') ||
@@ -295,18 +353,6 @@ protected function userProviderModel()
295353
return $config->get("auth.providers.{$provider}.model");
296354
}
297355

298-
/**
299-
* Get the console command arguments.
300-
*
301-
* @return array
302-
*/
303-
protected function getArguments()
304-
{
305-
return [
306-
['name', InputArgument::REQUIRED, 'The name of the class'],
307-
];
308-
}
309-
310356
/**
311357
* Checks whether the given name is reserved.
312358
*
@@ -319,4 +365,16 @@ protected function isReservedName($name)
319365

320366
return in_array($name, $this->reservedNames);
321367
}
368+
369+
/**
370+
* Get the console command arguments.
371+
*
372+
* @return array
373+
*/
374+
protected function getArguments()
375+
{
376+
return [
377+
['name', InputArgument::REQUIRED, 'The name of the class'],
378+
];
379+
}
322380
}

0 commit comments

Comments
 (0)