Skip to content

Commit 248e117

Browse files
[11.x] Add namespace for make:trait and make:interface command (#51083)
* Update InterfaceMakeCommand.php * Update TraitMakeCommand.php * Update TraitMakeCommand.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent a0ffb2b commit 248e117

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/Illuminate/Foundation/Console/InterfaceMakeCommand.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ protected function getStub()
4040
return __DIR__.'/stubs/interface.stub';
4141
}
4242

43+
/**
44+
* Get the default namespace for the class.
45+
*
46+
* @param string $rootNamespace
47+
* @return string
48+
*/
49+
protected function getDefaultNamespace($rootNamespace)
50+
{
51+
return match (true) {
52+
is_dir(app_path('Contracts')) => $rootNamespace.'\\Contracts',
53+
is_dir(app_path('Interfaces')) => $rootNamespace.'\\Interfaces',
54+
default => $rootNamespace,
55+
};
56+
}
57+
4358
/**
4459
* Get the console command arguments.
4560
*

src/Illuminate/Foundation/Console/TraitMakeCommand.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ protected function resolveStubPath($stub)
5353
: __DIR__.$stub;
5454
}
5555

56+
/**
57+
* Get the default namespace for the class.
58+
*
59+
* @param string $rootNamespace
60+
* @return string
61+
*/
62+
protected function getDefaultNamespace($rootNamespace)
63+
{
64+
return match (true) {
65+
is_dir(app_path('Concerns')) => $rootNamespace.'\\Concerns',
66+
is_dir(app_path('Traits')) => $rootNamespace.'\\Traits',
67+
default => $rootNamespace,
68+
};
69+
}
70+
5671
/**
5772
* Get the console command arguments.
5873
*

0 commit comments

Comments
 (0)