[5.5] Fix class name in generated class file #20961
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes the class name in a generated class file if the class name begins with a slash.
If a class name used in a make command starts with a slash the generated file will have the slash in the class name creating a syntax error in class file. For example, "php artisan make:model \Foo" will generate a file with the class name \Foo (i.e. namespace App; .... class \Foo { ..... } ).
Although a user would see the invalid class name in the generated file when they edit it to add their content, it seems more appropriate for the generator to create syntactically correct files.
Removing the beginning slash in the GeneratorCommand::qualifyClass() method generates a file with a valid class name.