Skip to content

Commit 62e80f3

Browse files
committed
Merge branch 'fix-spinner'
2 parents 177f71a + 13061a7 commit 62e80f3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Toolkit/Console/ConsoleFormatter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,11 @@ public function __construct(
176176
*/
177177
public function withSpinnerState(?array &$state)
178178
{
179+
if ($state === null) {
180+
$state = [0, 0.0];
181+
}
179182
$clone = clone $this;
180-
$clone->SpinnerState = $state ??= [0, 0.0];
183+
$clone->SpinnerState = &$state;
181184
return $clone;
182185
}
183186

tests/unit/Toolkit/Console/ConsoleWriterTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ public function testLogProgress(): void
3737
$state = $this->getState();
3838
for ($i = 0; $i < 11; $i++) {
3939
if (isset($state->SpinnerState)) {
40-
$state->SpinnerState = [
41-
$state->SpinnerState[0] + 1,
42-
(float) (hrtime(true) / 1000),
43-
];
40+
// @phpstan-ignore assign.propertyType
41+
$state->SpinnerState[1] = (float) (hrtime(true) / 1000) - 80000;
4442
}
4543
Console::logProgress('Complete:', sprintf('%d%%', ($i + 1) * 100 / 11));
4644
}

0 commit comments

Comments
 (0)