diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c2f622a8..2b937d69d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Changed + +- [@solomon-ochepa](https://github.com/solomon-ochepa) updated stubs to use return types + + ## 10.0.2 - 2023-09-18 ## Changed @@ -13,7 +18,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## 10.0.1 - 2023-09-18 ## Added - + - [@JaberWiki](https://github.com/JaberWiki) Added Include an optional flag `subpath` for rolling back a module's specific migration file [#1626](https://github.com/nWidart/laravel-modules/pull/1626) - [@sergiy-petrov](https://github.com/sergiy-petrov) Added support for testing GitHub actions against PHP versions 8.2 and 8.3. [#1624](https://github.com/nWidart/laravel-modules/pull/1624) - [@hanieas](https://github.com/hanieas) Added make Observer command. [#1623](https://github.com/nWidart/laravel-modules/pull/1623) diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt index 7d3e83261..166c7c5cf 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class MyController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt index 836193ff0..608c92496 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class MyController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 836193ff0..608c92496 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class MyController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt index 8068f08af..b8a2e2bd6 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers\Api; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class MyController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt index 7d3e83261..166c7c5cf 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class MyController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt index d13a9ac18..201ff4148 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt @@ -2,59 +2,61 @@ namespace Modules\Blog\Http\Controllers; +use App\Http\Controllers\Controller; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; -use Illuminate\Routing\Controller; class MyController extends Controller { + public array $data = []; + /** * Display a listing of the resource. - * @return Response */ - public function index() + public function index(): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Response */ - public function store(Request $request) + public function store(Request $request): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Show the specified resource. - * @param int $id - * @return Response */ - public function show($id) + public function show($id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Response */ - public function update(Request $request, $id) + public function update(Request $request, $id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Remove the specified resource from storage. - * @param int $id - * @return Response */ - public function destroy($id) + public function destroy($id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt index 0bbb67f04..8d5aef5e5 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class PostController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt index 0bbb67f04..8d5aef5e5 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class PostController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt index 0bbb67f04..8d5aef5e5 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class PostController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt index e268f9e16..e20768cf9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt index 7a087461e..821f40f57 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt @@ -2,59 +2,61 @@ namespace Modules\Blog\Http\Controllers; +use App\Http\Controllers\Controller; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; -use Illuminate\Routing\Controller; class BlogController extends Controller { + public array $data = []; + /** * Display a listing of the resource. - * @return Response */ - public function index() + public function index(): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Response */ - public function store(Request $request) + public function store(Request $request): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Show the specified resource. - * @param int $id - * @return Response */ - public function show($id) + public function show($id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Response */ - public function update(Request $request, $id) + public function update(Request $request, $id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Remove the specified resource from storage. - * @param int $id - * @return Response */ - public function destroy($id) + public function destroy($id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt index a3a8161a5..1a47cf6ec 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class ModuleNameServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'ModuleName'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'modulename'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class ModuleNameServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class ModuleNameServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class ModuleNameServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class ModuleNameServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt index e268f9e16..e20768cf9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt index fa3f878dd..01959660b 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class BlogController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt index e268f9e16..e20768cf9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt index fa3f878dd..01959660b 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class BlogController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index e268f9e16..e20768cf9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt index fa3f878dd..01959660b 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class BlogController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index 2ac74b875..85f47ec7a 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 2ac74b875..85f47ec7a 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt index 162c75a99..be6dd9df1 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt index e268f9e16..e20768cf9 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } }