fix: make:enum creates Enums directory if none exists#59334
Closed
Waris10 wants to merge 1 commit intolaravel:13.xfrom
Closed
fix: make:enum creates Enums directory if none exists#59334Waris10 wants to merge 1 commit intolaravel:13.xfrom
Waris10 wants to merge 1 commit intolaravel:13.xfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this fixes
When running
make:enumin a fresh Laravel application (or any app without an existingEnumsorEnumerationsdirectory), the generated enum is dropped directly intoapp/withnamespace App;instead of the expectedapp/Enums/withnamespace App\Enums;.This happens because
getDefaultNamespace()falls back to the root namespace when neither folder exists, and no directory is created.The fix
The
defaultcase ingetDefaultNamespace()now returns$rootNamespace.'\\Enums'instead of$rootNamespace. The existingmakeDirectory()call in the parentGeneratorCommandclass handles the actual folder creation — so no additional infrastructure changes are needed.Why this doesn't break existing behaviour
app/Enumsalready exists → same behaviour as beforeapp/Enumerationsalready exists → same behaviour as beforeapp/), now correctly createsapp/Enums/and places the file thereBenefit to end users
Running
make:enum Statuson a fresh app now works exactly as a developer would expect — consistent with how othermake:*commands handle their target directories. No manual folder creation needed.Tests
Updated three existing tests that were asserting the old broken behaviour (
namespace App;/app/*.php) to reflect the correct output. The two existing directory-specific tests are unchanged.