Skip to content

Commit c0fec88

Browse files
committed
refactor(output): replace variable name 'dispatcher' with 'outputter'
- Standardize variable naming convention across all files to improve clarity. - Update the parameter names in method signatures to reflect the new variable name. - Modify corresponding code logic to align with the updated variable name. - Ensure consistency in comments and docblocks to avoid ambiguity. - Verify that the renamed variables match the context of their usage.
1 parent f69bb2d commit c0fec88

14 files changed

+59
-59
lines changed

README-zh_CN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,14 @@ use Illuminate\Support\Collection;
508508
interface Output
509509
{
510510
/**
511-
* @param \Illuminate\Console\Events\CommandFinished|\Symfony\Component\HttpFoundation\Response $dispatcher
511+
* @param \Illuminate\Console\Events\CommandFinished|\Symfony\Component\HttpFoundation\Response $outputter
512512
*/
513-
public function shouldOutput($dispatcher): bool;
513+
public function shouldOutput($outputter): bool;
514514

515515
/**
516-
* @param \Illuminate\Console\Events\CommandFinished|\Symfony\Component\HttpFoundation\Response $dispatcher
516+
* @param \Illuminate\Console\Events\CommandFinished|\Symfony\Component\HttpFoundation\Response $outputter
517517
*/
518-
public function output(Collection $scores, $dispatcher);
518+
public function output(Collection $scores, $outputter);
519519
}
520520
```
521521

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,14 @@ use Illuminate\Support\Collection;
508508
interface Output
509509
{
510510
/**
511-
* @param \Illuminate\Console\Events\CommandFinished|\Symfony\Component\HttpFoundation\Response $dispatcher
511+
* @param \Illuminate\Console\Events\CommandFinished|\Symfony\Component\HttpFoundation\Response $outputter
512512
*/
513-
public function shouldOutput($dispatcher): bool;
513+
public function shouldOutput($outputter): bool;
514514

515515
/**
516-
* @param \Illuminate\Console\Events\CommandFinished|\Symfony\Component\HttpFoundation\Response $dispatcher
516+
* @param \Illuminate\Console\Events\CommandFinished|\Symfony\Component\HttpFoundation\Response $outputter
517517
*/
518-
public function output(Collection $scores, $dispatcher);
518+
public function output(Collection $scores, $outputter);
519519
}
520520
```
521521

src/Contracts/OutputContract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
interface OutputContract
2121
{
22-
public function shouldOutput(CommandFinished|Response $dispatcher): bool;
22+
public function shouldOutput(CommandFinished|Response $outputter): bool;
2323

24-
public function output(Collection $scores, CommandFinished|Response $dispatcher): mixed;
24+
public function output(Collection $scores, CommandFinished|Response $outputter): mixed;
2525
}

src/Events/OutputtingEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ class OutputtingEvent
2323
public function __construct(
2424
public OutputContract $output,
2525
public Collection $scores,
26-
public CommandFinished|Response $dispatcher
26+
public CommandFinished|Response $outputter
2727
) {}
2828
}

src/OutputManager.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,33 @@
2626

2727
class OutputManager extends Fluent implements OutputContract
2828
{
29-
public function shouldOutput(CommandFinished|Response $dispatcher): bool
29+
public function shouldOutput(CommandFinished|Response $outputter): bool
3030
{
3131
$exclusions = config('soar.exclusions', []);
3232

33-
if ($dispatcher instanceof CommandFinished) {
34-
return !Str::is($exclusions, $dispatcher->command);
33+
if ($outputter instanceof CommandFinished) {
34+
return !Str::is($exclusions, $outputter->command);
3535
}
3636

3737
return !Request::is($exclusions) && !Request::routeIs($exclusions);
3838
}
3939

40-
public function output(Collection $scores, CommandFinished|Response $dispatcher): mixed
40+
public function output(Collection $scores, CommandFinished|Response $outputter): mixed
4141
{
42-
if (!$this->shouldOutput($dispatcher)) {
42+
if (!$this->shouldOutput($outputter)) {
4343
return null;
4444
}
4545

4646
foreach ($this->attributes as $output) {
4747
\assert($output instanceof OutputContract);
4848

49-
if (!$output->shouldOutput($dispatcher)) {
49+
if (!$output->shouldOutput($outputter)) {
5050
continue;
5151
}
5252

5353
$output instanceof SanitizerContract and $scores = $output->sanitize($scores);
54-
event(new OutputtingEvent($output, $scores, $dispatcher));
55-
$result = $output->output($scores, $dispatcher);
54+
event(new OutputtingEvent($output, $scores, $outputter));
55+
$result = $output->output($scores, $outputter);
5656
event(new OutputtedEvent($output, $scores, $result));
5757
}
5858

src/Outputs/AbstractOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class AbstractOutput implements OutputContract, SanitizerContract
2727
use ScoresHydrator;
2828
use ScoresSanitizer;
2929

30-
public function shouldOutput(CommandFinished|Response $dispatcher): bool
30+
public function shouldOutput(CommandFinished|Response $outputter): bool
3131
{
3232
return true;
3333
}

src/Outputs/ClockworkOutput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ class ClockworkOutput extends AbstractOutput
2222
/**
2323
* @noinspection PhpMissingParentCallCommonInspection
2424
*/
25-
public function shouldOutput(CommandFinished|Response $dispatcher): bool
25+
public function shouldOutput(CommandFinished|Response $outputter): bool
2626
{
2727
return \function_exists('clock');
2828
}
2929

30-
public function output(Collection $scores, CommandFinished|Response $dispatcher): mixed
30+
public function output(Collection $scores, CommandFinished|Response $outputter): mixed
3131
{
3232
return clock(...$scores);
3333
}

src/Outputs/Concerns/OutputConditions.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@
2121

2222
trait OutputConditions
2323
{
24-
protected function isCommandFinished(CommandFinished|Response $dispatcher): bool
24+
protected function isCommandFinished(CommandFinished|Response $outputter): bool
2525
{
26-
return $dispatcher instanceof CommandFinished;
26+
return $outputter instanceof CommandFinished;
2727
}
2828

29-
protected function isHtmlResponse(CommandFinished|Response $dispatcher): bool
29+
protected function isHtmlResponse(CommandFinished|Response $outputter): bool
3030
{
31-
return $dispatcher instanceof Response
32-
&& false !== $dispatcher->getContent()
33-
&& str($dispatcher->headers->get('Content-Type'))->contains('text/html')
34-
&& !$this->isJsonResponse($dispatcher);
31+
return $outputter instanceof Response
32+
&& false !== $outputter->getContent()
33+
&& str($outputter->headers->get('Content-Type'))->contains('text/html')
34+
&& !$this->isJsonResponse($outputter);
3535
}
3636

37-
protected function isJsonResponse(CommandFinished|Response $dispatcher): bool
37+
protected function isJsonResponse(CommandFinished|Response $outputter): bool
3838
{
39-
return $dispatcher instanceof JsonResponse
40-
&& false !== $dispatcher->getContent()
41-
&& str($dispatcher->headers->get('Content-Type'))->contains('application/json')
42-
&& transform($dispatcher, static function (JsonResponse $jsonResponse): bool {
39+
return $outputter instanceof JsonResponse
40+
&& false !== $outputter->getContent()
41+
&& str($outputter->headers->get('Content-Type'))->contains('application/json')
42+
&& transform($outputter, static function (JsonResponse $jsonResponse): bool {
4343
if ('' === ($content = $jsonResponse->getContent())) {
4444
return false;
4545
}

src/Outputs/ConsoleOutput.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,32 @@ public function __construct(protected string $method = 'warn') {}
2424
/**
2525
* @noinspection PhpMissingParentCallCommonInspection
2626
*/
27-
public function shouldOutput(CommandFinished|Response $dispatcher): bool
27+
public function shouldOutput(CommandFinished|Response $outputter): bool
2828
{
29-
return $this->isHtmlResponse($dispatcher);
29+
return $this->isHtmlResponse($outputter);
3030
}
3131

3232
/**
3333
* @noinspection PhpMixedReturnTypeCanBeReducedInspection
3434
*
3535
* @throws \JsonException
3636
*/
37-
public function output(Collection $scores, CommandFinished|Response $dispatcher): mixed
37+
public function output(Collection $scores, CommandFinished|Response $outputter): mixed
3838
{
39-
\assert($dispatcher instanceof Response);
39+
\assert($outputter instanceof Response);
4040

4141
$js = $this->toJavaScript($scores);
42-
$content = $dispatcher->getContent();
42+
$content = $outputter->getContent();
4343

4444
// Try to put the widget at the end, directly before the </body>
4545
$pos = strripos($content, '</body>');
4646
$content = false !== $pos ? substr($content, 0, $pos).$js.substr($content, $pos) : $content.$js;
4747

4848
// Update the new content and reset the content length
49-
$dispatcher->setContent($content);
50-
$dispatcher->headers->remove('Content-Length');
49+
$outputter->setContent($content);
50+
$outputter->headers->remove('Content-Length');
5151

52-
return $dispatcher;
52+
return $outputter;
5353
}
5454

5555
/**

src/Outputs/DebugBarOutput.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ public function __construct(
2929
/**
3030
* @noinspection PhpMissingParentCallCommonInspection
3131
*/
32-
public function shouldOutput(CommandFinished|Response $dispatcher): bool
32+
public function shouldOutput(CommandFinished|Response $outputter): bool
3333
{
3434
// app(LaravelDebugbar::class)->isEnabled()
3535
return class_exists(LaravelDebugbar::class)
3636
&& app()->has(LaravelDebugbar::class)
37-
&& $this->isHtmlResponse($dispatcher);
37+
&& $this->isHtmlResponse($outputter);
3838
}
3939

4040
/**
@@ -43,7 +43,7 @@ public function shouldOutput(CommandFinished|Response $dispatcher): bool
4343
* @throws \DebugBar\DebugBarException
4444
* @throws \JsonException
4545
*/
46-
public function output(Collection $scores, CommandFinished|Response $dispatcher): LaravelDebugbar
46+
public function output(Collection $scores, CommandFinished|Response $outputter): LaravelDebugbar
4747
{
4848
$debugBar = resolve(LaravelDebugbar::class);
4949

0 commit comments

Comments
 (0)