Skip to content

Commit 69284e3

Browse files
authored
[11.x] No need to redeclare variables (#53887)
1 parent c17277e commit 69284e3

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/Illuminate/Foundation/Console/ServeCommand.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ protected function flushOutputBuffer()
279279
->map(fn ($line) => trim($line))
280280
->filter()
281281
->each(function ($line) {
282-
if ((new Stringable($line))->contains('Development Server (http')) {
282+
$stringable = new Stringable($line);
283+
284+
if ($stringable->contains('Development Server (http')) {
283285
if ($this->serverRunningHasBeenDisplayed === false) {
284286
$this->serverRunningHasBeenDisplayed = true;
285287

@@ -292,23 +294,19 @@ protected function flushOutputBuffer()
292294
return;
293295
}
294296

295-
if ((new Stringable($line))->contains(' Accepted')) {
296-
$requestPort = static::getRequestPortFromLine($line);
297+
$requestPort = static::getRequestPortFromLine($line);
297298

299+
if ($stringable->contains(' Accepted')) {
298300
$this->requestsPool[$requestPort] = [
299301
$this->getDateFromLine($line),
300302
$this->requestsPool[$requestPort][1] ?? false,
301303
microtime(true),
302304
];
303-
} elseif ((new Stringable($line))->contains([' [200]: GET '])) {
304-
$requestPort = static::getRequestPortFromLine($line);
305-
305+
} elseif ($stringable->contains([' [200]: GET '])) {
306306
$this->requestsPool[$requestPort][1] = trim(explode('[200]: GET', $line)[1]);
307-
} elseif ((new Stringable($line))->contains('URI:')) {
308-
$requestPort = static::getRequestPortFromLine($line);
309-
307+
} elseif ($stringable->contains('URI:')) {
310308
$this->requestsPool[$requestPort][1] = trim(explode('URI: ', $line)[1]);
311-
} elseif ((new Stringable($line))->contains(' Closing')) {
309+
} elseif ($stringable->contains(' Closing')) {
312310
$requestPort = static::getRequestPortFromLine($line);
313311

314312
if (empty($this->requestsPool[$requestPort])) {
@@ -339,11 +337,11 @@ protected function flushOutputBuffer()
339337

340338
$this->output->write(' '.str_repeat('<fg=gray>.</>', $dots));
341339
$this->output->writeln(" <fg=gray>~ {$runTime}</>");
342-
} elseif ((new Stringable($line))->contains(['Closed without sending a request', 'Failed to poll event'])) {
340+
} elseif ($stringable->contains(['Closed without sending a request', 'Failed to poll event'])) {
343341
// ...
344342
} elseif (! empty($line)) {
345-
if ((new Stringable($line))->startsWith('[')) {
346-
$line = (new Stringable($line))->after('] ');
343+
if ($stringable->startsWith('[')) {
344+
$line = $stringable->after('] ');
347345
}
348346

349347
$this->output->writeln(" <fg=gray>$line</>");

0 commit comments

Comments
 (0)