Skip to content

Commit 0144273

Browse files
committed
Make use of some PHP 7.4 features, disable factory loading
1 parent f80a08b commit 0144273

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"require-dev": {
2222
"phpunit/phpunit": "^9.5",
23-
"mockery/mockery": "^1.0",
23+
"mockery/mockery": "^1.4",
2424
"orchestra/testbench": "^6.0"
2525
},
2626
"autoload": {

src/Module.php

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Zonneplan\ModuleLoader;
44

55
use Illuminate\Console\Scheduling\Schedule;
6-
use Illuminate\Database\Eloquent\Factory;
76
use Illuminate\Routing\Router;
87
use Illuminate\Support\Facades\Event;
98
use Illuminate\Support\Facades\Gate;
@@ -22,29 +21,24 @@
2221
abstract class Module extends ServiceProvider implements ModuleContract
2322
{
2423
protected const ROUTE_FILE_TYPES = [
25-
'routes', 'web', 'api',
24+
'routes',
25+
'web',
26+
'api',
2627
];
2728

28-
/** @var array */
29-
protected $policies = [];
29+
protected array $policies;
3030

31-
/** @var array */
32-
protected $middleware = [];
31+
protected array $middleware;
3332

34-
/** @var array */
35-
protected $listen = [];
33+
protected array $listen;
3634

37-
/** @var array */
38-
protected $subscribe = [];
35+
protected array $subscribe;
3936

40-
/** @var string */
41-
protected $modulePath;
37+
protected string $modulePath;
4238

4339
/**
4440
* Register the module.
4541
*
46-
* @throws ReflectionException
47-
*
4842
* @return void
4943
*/
5044
public function register(): void
@@ -56,9 +50,8 @@ public function register(): void
5650
/**
5751
* Boot the module.
5852
*
59-
* @throws ReflectionException
60-
*
6153
* @return void
54+
* @throws ReflectionException
6255
*/
6356
public function boot(): void
6457
{
@@ -91,9 +84,8 @@ protected function loadCommandSchedule(): void
9184
}
9285

9386
/**
94-
* @throws ReflectionException
95-
*
9687
* @return void
88+
* @throws ReflectionException
9789
*/
9890
protected function loadMigrations(): void
9991
{
@@ -105,9 +97,8 @@ protected function loadMigrations(): void
10597
}
10698

10799
/**
108-
* @throws ReflectionException
109-
*
110100
* @return void
101+
* @throws ReflectionException
111102
*/
112103
protected function loadViews(): void
113104
{
@@ -119,9 +110,8 @@ protected function loadViews(): void
119110
}
120111

121112
/**
122-
* @throws ReflectionException
123-
*
124113
* @return void
114+
* @throws ReflectionException
125115
*/
126116
protected function loadTranslations(): void
127117
{
@@ -133,9 +123,8 @@ protected function loadTranslations(): void
133123
}
134124

135125
/**
136-
* @throws ReflectionException
137-
*
138126
* @return void
127+
* @throws ReflectionException
139128
*/
140129
protected function loadConfigs(): void
141130
{
@@ -180,8 +169,6 @@ protected function registerListeners(): void
180169
}
181170

182171
/**
183-
* @throws ReflectionException
184-
*
185172
* @return string
186173
*/
187174
protected function getModulePath(): string
@@ -246,9 +233,8 @@ private function registerMiddleware(): void
246233
*/
247234
private function registerFactories(): void
248235
{
249-
$this->app->afterResolving(Factory::class, function (Factory $faker) {
250-
$faker->load($this->getModulePath().'/Database/Factories');
251-
});
236+
// Unfortunately Laravel 8 no longer supports loading factories like this
237+
// because they want you to use ModelFactories.
252238
}
253239

254240
private function registerRoutes(): void

src/Support/ModuleRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class ModuleRepository implements ModuleRepositoryContract
1414
{
1515
/** @var array */
16-
protected $modules = [];
16+
protected array $modules = [];
1717

1818
/**
1919
* Registers a new module with a path.

0 commit comments

Comments
 (0)