Skip to content

Commit d44c435

Browse files
jrl05ktaylorotwell
authored andcommitted
Fix class name in generated class file. (#20961)
* Fix class name in generated class file. If a class name used in a make commands starts with a slash the generated file will have the slash in the class name creating syntax error in class file. For example, artisan make modeld command (i.e. php artisan make:model \Foo) will generate file with the class name \Foo (i.e. class \Foo { ..... } ). Removing the beginning slash in the GeneratorCommand::qualifyClass() method will generate file will a valid class name. * Update GeneratorCommand.php
1 parent 3cd20ad commit d44c435

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Illuminate/Console/GeneratorCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public function handle()
8080
*/
8181
protected function qualifyClass($name)
8282
{
83+
$name = ltrim($name, '\\/');
84+
8385
$rootNamespace = $this->rootNamespace();
8486

8587
if (Str::startsWith($name, $rootNamespace)) {

0 commit comments

Comments
 (0)