[13.x] Fix nested enum path duplication in make:enum#60210
Open
wbrasilsousa wants to merge 1 commit into
Open
Conversation
When app/Enums directory exists, getDefaultNamespace() prepends Enums\ to the namespace. If user already includes Enums/ in the name arg, the namespace gets doubled (App\Enums\Enums\Profile\). This fix checks if input starts with Enums/ or Enums\ and skips directory-based namespace resolution, preventing duplication. Fixes laravel#60152
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.
Summary
Fixes #60152 —
make:enumproduces incorrect nested paths whenapp/Enumsdirectory exists.The Bug
The first command creates the
app/Enumsdirectory. On the second command,getDefaultNamespace()detects the now-existing directory and prependsEnums\to the namespace, doubling it with the user-providedEnums/prefix.The Fix
EnumMakeCommand::getDefaultNamespace()now checks whether the name input already starts withEnums/,Enums\,Enumerations/, orEnumerations\. When it does, the method returns the root namespace directly instead of prepending the directory-based sub-namespace.Test Added
testItCanGenerateNestedEnumsWithoutPathDuplication— creates two nested enums sequentially and asserts both land in the correct directory without path duplication.Closes #60152