Skip to content

Commit 213de8b

Browse files
committed
refactor(bootstrapper, service-provider): replace Container with Application
- Updated the type hint for the constructor and dependencies from `Container` to `Application` in `Bootstrapper.php`. - Adjusted service bindings in `SoarServiceProvider.php` to use `Application` instead of `Container`. - Ensured all references to container usage reflect the updated dependency. - Improved alignment with Laravel's core conventions and better contextual understanding of application-level services.
1 parent 706abee commit 213de8b

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

baselines/loader.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 7 errors
1+
# total 8 errors
22
includes:
33
- method.notFound.neon
44
- offsetAccess.nonArray.neon

baselines/method.notFound.neon

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
# total 1 error
1+
# total 2 errors
22

33
parameters:
44
ignoreErrors:
5+
-
6+
message: '#^Call to an undefined method Illuminate\\Contracts\\Http\\Kernel\:\:prependMiddleware\(\)\.$#'
7+
count: 1
8+
path: ../src/Bootstrapper.php
9+
510
-
611
message: '#^Call to an undefined method DebugBar\\DataCollector\\DataCollectorInterface\:\:addMessage\(\)\.$#'
712
count: 1

src/Bootstrapper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
use Guanguans\LaravelSoar\Middleware\OutputScoresMiddleware;
1717
use Illuminate\Console\Events\CommandFinished;
1818
use Illuminate\Contracts\Container\BindingResolutionException;
19-
use Illuminate\Contracts\Container\Container;
2019
use Illuminate\Contracts\Http\Kernel;
2120
use Illuminate\Database\Events\QueryExecuted;
21+
use Illuminate\Foundation\Application;
2222
use Illuminate\Support\Collection;
2323
use Illuminate\Support\Facades\Event;
2424
use Illuminate\Support\Str;
@@ -31,7 +31,7 @@ class Bootstrapper
3131
private static Collection $queries;
3232
private static Collection $scores;
3333

34-
public function __construct(private Container $container)
34+
public function __construct(private Application $application)
3535
{
3636
self::$queries = collect();
3737
self::$scores = collect();
@@ -170,13 +170,13 @@ private function registerOutputMonitor(): void
170170
{
171171
Event::listen(
172172
CommandFinished::class,
173-
fn (CommandFinished $commandFinished) => $this->container->make(OutputManager::class)->output(
173+
fn (CommandFinished $commandFinished) => $this->application->make(OutputManager::class)->output(
174174
$this->getScores(),
175175
$commandFinished
176176
)
177177
);
178178

179-
$this->container->make(Kernel::class)->prependMiddleware(OutputScoresMiddleware::class);
179+
$this->application->make(Kernel::class)->prependMiddleware(OutputScoresMiddleware::class);
180180
}
181181

182182
/**

src/SoarServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
use Guanguans\LaravelSoar\Commands\RunCommand;
1919
use Guanguans\LaravelSoar\Commands\ScoreCommand;
2020
use Guanguans\LaravelSoar\Mixins\QueryBuilderMixin;
21-
use Illuminate\Contracts\Container\Container;
2221
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
2322
use Illuminate\Database\Eloquent\Relations\Relation as RelationBuilder;
2423
use Illuminate\Database\Query\Builder as QueryBuilder;
24+
use Illuminate\Foundation\Application;
2525
use Illuminate\Foundation\Console\AboutCommand;
2626
use Illuminate\Support\Collection;
2727
use Illuminate\Support\ServiceProvider;
@@ -98,14 +98,14 @@ private function registerOutputManager(): void
9898
{
9999
$this->app->singleton(
100100
OutputManager::class,
101-
static fn (Container $container): OutputManager => collect(config('soar.outputs'))
102-
->mapWithKeys(static function (array|string $parameters, int|string $class) use ($container): array {
101+
static fn (Application $application): OutputManager => collect(config('soar.outputs'))
102+
->mapWithKeys(static function (array|string $parameters, int|string $class) use ($application): array {
103103
if (!\is_array($parameters)) {
104104
[$parameters, $class] = [(array) $class, $parameters];
105105
}
106106

107107
/** @var string $class */
108-
return [$class => $container->make($class, $parameters)];
108+
return [$class => $application->make($class, $parameters)];
109109
})
110110
->pipe(static fn (Collection $outputs): OutputManager => new OutputManager($outputs->all()))
111111
);

0 commit comments

Comments
 (0)