Skip to content

Commit

Permalink
Fix class name in generated class file. (#20961)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jrl05k authored and taylorotwell committed Sep 4, 2017
1 parent 3cd20ad commit d44c435
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Illuminate/Console/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function handle()
*/
protected function qualifyClass($name)
{
$name = ltrim($name, '\\/');

$rootNamespace = $this->rootNamespace();

if (Str::startsWith($name, $rootNamespace)) {
Expand Down

0 comments on commit d44c435

Please sign in to comment.