Skip to content

Commit

Permalink
chore: apply mago fix --potentially-unsafe
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed Dec 9, 2024
1 parent fc5b0ea commit bf335e0
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 72 deletions.
12 changes: 6 additions & 6 deletions tests/static-analysis/Fun/pipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function test_too_few_argument_dont_matter(): int
*/
function test_too_many_argument_count_issues(): int
{
$stages = pipe(static fn(string $x, string $y): int => 2);
$stages = pipe(static fn(string $_x, string $_y): int => 2);
return $stages('hello');
}

Expand All @@ -27,7 +27,7 @@ function test_too_many_argument_count_issues(): int
*/
function test_variadic_and_default_params(): int
{
$stages = pipe(static fn(int $y, string $x = 'hello'): float => 1.2, static fn(float ...$items): int => 23);
$stages = pipe(static fn(int $_y, string $_x = 'hello'): float => 1.2, static fn(float ...$_items): int => 23);
return $stages(123);
}

Expand Down Expand Up @@ -59,7 +59,7 @@ function test_invalid_arguments(): void
*/
function test_invalid_return_to_input_type(): float
{
$stages = pipe(static fn(string $x): int => 2, static fn(string $y): float => 1.2);
$stages = pipe(static fn(string $_x): int => 2, static fn(string $_y): float => 1.2);
return $stages('hello');
}

Expand All @@ -68,7 +68,7 @@ function test_invalid_return_to_input_type(): float
*/
function test_invalid_input_type(): float
{
$stages = pipe(static fn(string $x): int => 2, static fn(int $y): float => 1.2);
$stages = pipe(static fn(string $_x): int => 2, static fn(int $_y): float => 1.2);
return $stages(143);
}

Expand All @@ -79,7 +79,7 @@ function test_invalid_input_type(): float
*/
function test_output_type_is_known(): void
{
$stages = pipe(static fn(string $x): int => 2);
$stages = pipe(static fn(string $_x): int => 2);

Psl\invariant(
is_int($stages('hello')),
Expand All @@ -92,6 +92,6 @@ function test_output_type_is_known(): void
*/
function test_first_class_callables(): int
{
$stages = pipe($assignment = static fn(string $x): int => 2, static fn(): int => 2(...));
$stages = pipe($assignment = static fn(string $_x): int => 2, static fn(): int => 2(...));
return $stages('hello');
}
2 changes: 1 addition & 1 deletion tests/static-analysis/Option/zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ function test_some_zip_with()
*/
function test_some_zip_with_2()
{
return Option\some(1)->zipWith(Option\some('2'), static fn($a, $b) => $b);
return Option\some(1)->zipWith(Option\some('2'), static fn($_a, $b) => $b);
}
2 changes: 1 addition & 1 deletion tests/static-analysis/Type/intersection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @param Map&ResultInterface&stdClass&Vector $value
*/
function takes_valid_intersection($value): void
function takes_valid_intersection($_value): void
{
}

Expand Down
2 changes: 1 addition & 1 deletion tests/static-analysis/Type/union.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @param 'PENDING'|'PROCESSING'|'COMPLETED'|'ERROR' $state
*/
function takes_valid_state(string $state): void
function takes_valid_state(string $_state): void
{
}

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/Async/AwaitableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ public function testThenOnSuccess(): void

$awaitable = $awaitable->then(
static fn(string $result) => Str\reverse($result),
static fn(Throwable $exception) => exit(0),
static fn(Throwable $_exception) => exit(0),
)
->then(
static fn(string $result) => throw new InvariantViolationException($result),
static fn(Throwable $exception) => exit(0),
static fn(Throwable $_exception) => exit(0),
)
->then(static fn($result) => exit(0), static fn(Throwable $exception) => throw $exception)
->then(static fn($result) => exit(0), static fn(Throwable $exception) => $exception->getMessage());
->then(static fn($_result) => exit(0), static fn(Throwable $exception) => throw $exception)
->then(static fn($_result) => exit(0), static fn(Throwable $exception) => $exception->getMessage());

static::assertSame('olleh', $awaitable->await());
}
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/Collection/AbstractMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function testFilterWithKey(): void
3 => 'qux',
]);

$filtered = $map->filterWithKey(static fn(int $k, string $v) => 4 === $k);
$filtered = $map->filterWithKey(static fn(int $k, string $_v) => 4 === $k);

static::assertInstanceOf($this->mapClass, $filtered);
static::assertNotContains('bar', $filtered);
Expand Down Expand Up @@ -267,14 +267,14 @@ public function testMapWithKey(): void
3 => 'qux',
]);

$mapped = $map->mapWithKey(static fn(int $k, string $v) => $k);
$mapped = $map->mapWithKey(static fn(int $k, string $_v) => $k);

static::assertInstanceOf($this->mapClass, $mapped);
static::assertNotSame($map, $mapped);
static::assertSame($map->keys()->toArray(), $mapped->toArray());
static::assertCount(4, $mapped);

$mapped = $map->mapWithKey(static fn(int $k, string $v) => $v);
$mapped = $map->mapWithKey(static fn(int $_k, string $v) => $v);

static::assertInstanceOf($this->mapClass, $mapped);
static::assertNotSame($map, $mapped);
Expand Down Expand Up @@ -429,19 +429,19 @@ public function testTake(): void
public function testTakeWhile(): void
{
$map = $this->create([]);
$rest = $map->takeWhile(static fn($v) => false);
$rest = $map->takeWhile(static fn($_v) => false);
static::assertInstanceOf($this->mapClass, $rest);
static::assertNotSame($map, $rest);
static::assertCount(0, $rest);

$map = $this->create([]);
$rest = $map->takeWhile(static fn($v) => true);
$rest = $map->takeWhile(static fn($_v) => true);
static::assertInstanceOf($this->mapClass, $rest);
static::assertNotSame($map, $rest);
static::assertCount(0, $rest);

$map = $this->create(['foo' => 'bar', 'baz' => 'qux']);
$rest = $map->takeWhile(static fn($v) => true);
$rest = $map->takeWhile(static fn($_v) => true);
static::assertInstanceOf($this->mapClass, $rest);
static::assertNotSame($map, $rest);
static::assertCount(2, $rest);
Expand Down Expand Up @@ -487,25 +487,25 @@ public function testDrop(): void
public function testDropWhile(): void
{
$map = $this->create([]);
$rest = $map->dropWhile(static fn($v) => true);
$rest = $map->dropWhile(static fn($_v) => true);
static::assertInstanceOf($this->mapClass, $rest);
static::assertNotSame($map, $rest);
static::assertCount(0, $rest);

$map = $this->create([]);
$rest = $map->dropWhile(static fn($v) => false);
$rest = $map->dropWhile(static fn($_v) => false);
static::assertInstanceOf($this->mapClass, $rest);
static::assertNotSame($map, $rest);
static::assertCount(0, $rest);

$map = $this->create(['foo' => 'bar', 'baz' => 'qux']);
$rest = $map->dropWhile(static fn($v) => true);
$rest = $map->dropWhile(static fn($_v) => true);
static::assertInstanceOf($this->mapClass, $rest);
static::assertNotSame($map, $rest);
static::assertCount(0, $rest);

$map = $this->create(['foo' => 'bar', 'baz' => 'qux']);
$rest = $map->dropWhile(static fn($v) => false);
$rest = $map->dropWhile(static fn($_v) => false);
static::assertInstanceOf($this->mapClass, $rest);
static::assertNotSame($map, $rest);
static::assertCount(2, $rest);
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/Collection/AbstractSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,19 +354,19 @@ public function testTake(): void
public function testTakeWhile(): void
{
$set = $this->default();
$rest = $set->takeWhile(static fn($v) => false);
$rest = $set->takeWhile(static fn($_v) => false);
static::assertInstanceOf($this->setClass, $rest);
static::assertNotSame($set, $rest);
static::assertCount(0, $rest);

$set = $this->default();
$rest = $set->takeWhile(static fn($v) => true);
$rest = $set->takeWhile(static fn($_v) => true);
static::assertInstanceOf($this->setClass, $rest);
static::assertNotSame($set, $rest);
static::assertCount(0, $rest);

$set = $this->createFromList(['bar', 'qux']);
$rest = $set->takeWhile(static fn($v) => true);
$rest = $set->takeWhile(static fn($_v) => true);
static::assertInstanceOf($this->setClass, $rest);
static::assertNotSame($set, $rest);
static::assertCount(2, $rest);
Expand Down Expand Up @@ -412,25 +412,25 @@ public function testDrop(): void
public function testDropWhile(): void
{
$set = $this->default();
$rest = $set->dropWhile(static fn($v) => true);
$rest = $set->dropWhile(static fn($_v) => true);
static::assertInstanceOf($this->setClass, $rest);
static::assertNotSame($set, $rest);
static::assertCount(0, $rest);

$set = $this->default();
$rest = $set->dropWhile(static fn($v) => false);
$rest = $set->dropWhile(static fn($_v) => false);
static::assertInstanceOf($this->setClass, $rest);
static::assertNotSame($set, $rest);
static::assertCount(0, $rest);

$set = $this->createFromList(['bar', 'qux']);
$rest = $set->dropWhile(static fn($v) => true);
$rest = $set->dropWhile(static fn($_v) => true);
static::assertInstanceOf($this->setClass, $rest);
static::assertNotSame($set, $rest);
static::assertCount(0, $rest);

$set = $this->createFromList(['bar', 'qux']);
$rest = $set->dropWhile(static fn($v) => false);
$rest = $set->dropWhile(static fn($_v) => false);
static::assertInstanceOf($this->setClass, $rest);
static::assertNotSame($set, $rest);
static::assertCount(2, $rest);
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/Collection/AbstractVectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function testFilterWithKey(): void
'qux',
]);

$filtered = $vector->filterWithKey(static fn(int $k, string $v) => 4 === $k);
$filtered = $vector->filterWithKey(static fn(int $k, string $_v) => 4 === $k);

static::assertInstanceOf($this->vectorClass, $filtered);
static::assertNotContains('bar', $filtered);
Expand Down Expand Up @@ -243,14 +243,14 @@ public function testMapWithKey(): void
'qux',
]);

$mapped = $vector->mapWithKey(static fn(int $k, string $v) => $k);
$mapped = $vector->mapWithKey(static fn(int $k, string $_v) => $k);

static::assertInstanceOf($this->vectorClass, $mapped);
static::assertNotSame($vector, $mapped);
static::assertSame($vector->keys()->toArray(), $mapped->toArray());
static::assertCount(4, $mapped);

$mapped = $vector->mapWithKey(static fn(int $k, string $v) => $v);
$mapped = $vector->mapWithKey(static fn(int $_k, string $v) => $v);

static::assertInstanceOf($this->vectorClass, $mapped);
static::assertNotSame($vector, $mapped);
Expand Down Expand Up @@ -398,19 +398,19 @@ public function testTake(): void
public function testTakeWhile(): void
{
$vector = $this->create([]);
$rest = $vector->takeWhile(static fn($v) => false);
$rest = $vector->takeWhile(static fn($_v) => false);
static::assertInstanceOf($this->vectorClass, $rest);
static::assertNotSame($vector, $rest);
static::assertCount(0, $rest);

$vector = $this->create([]);
$rest = $vector->takeWhile(static fn($v) => true);
$rest = $vector->takeWhile(static fn($_v) => true);
static::assertInstanceOf($this->vectorClass, $rest);
static::assertNotSame($vector, $rest);
static::assertCount(0, $rest);

$vector = $this->create(['bar', 'qux']);
$rest = $vector->takeWhile(static fn($v) => true);
$rest = $vector->takeWhile(static fn($_v) => true);
static::assertInstanceOf($this->vectorClass, $rest);
static::assertNotSame($vector, $rest);
static::assertCount(2, $rest);
Expand Down Expand Up @@ -456,25 +456,25 @@ public function testDrop(): void
public function testDropWhile(): void
{
$vector = $this->create([]);
$rest = $vector->dropWhile(static fn($v) => true);
$rest = $vector->dropWhile(static fn($_v) => true);
static::assertInstanceOf($this->vectorClass, $rest);
static::assertNotSame($vector, $rest);
static::assertCount(0, $rest);

$vector = $this->create([]);
$rest = $vector->dropWhile(static fn($v) => false);
$rest = $vector->dropWhile(static fn($_v) => false);
static::assertInstanceOf($this->vectorClass, $rest);
static::assertNotSame($vector, $rest);
static::assertCount(0, $rest);

$vector = $this->create(['bar', 'qux']);
$rest = $vector->dropWhile(static fn($v) => true);
$rest = $vector->dropWhile(static fn($_v) => true);
static::assertInstanceOf($this->vectorClass, $rest);
static::assertNotSame($vector, $rest);
static::assertCount(0, $rest);

$vector = $this->create(['bar', 'qux']);
$rest = $vector->dropWhile(static fn($v) => false);
$rest = $vector->dropWhile(static fn($_v) => false);
static::assertInstanceOf($this->vectorClass, $rest);
static::assertNotSame($vector, $rest);
static::assertCount(2, $rest);
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Dict/PartitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public function provideData(): array
[
[[], ['foo', 'bar', 'baz', 'qux']],
['foo', 'bar', 'baz', 'qux'],
static fn(string $str) => false,
static fn(string $_str) => false,
],
[
[['foo', 'bar', 'baz', 'qux'], []],
['foo', 'bar', 'baz', 'qux'],
static fn(string $str) => true,
static fn(string $_str) => true,
],
];
}
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/Dict/PartitionWithKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public function provideData(): array
[
[[1 => 'bar', 2 => 'baz'], [0 => 'foo', 3 => 'qux']],
['foo', 'bar', 'baz', 'qux'],
static fn(int $k, string $str) => Str\starts_with($str, 'b'),
static fn(int $_k, string $str) => Str\starts_with($str, 'b'),
],
[
[[0 => 'foo', 3 => 'qux'], [1 => 'bar', 2 => 'baz']],
['foo', 'bar', 'baz', 'qux'],
static fn(int $k, string $str) => !Str\starts_with($str, 'b'),
static fn(int $_k, string $str) => !Str\starts_with($str, 'b'),
],
[
[[], []],
Expand All @@ -39,22 +39,22 @@ public function provideData(): array
[
[[], ['foo', 'bar', 'baz', 'qux']],
['foo', 'bar', 'baz', 'qux'],
static fn(int $k, string $str) => false,
static fn(int $_k, string $_str) => false,
],
[
[['foo', 'bar', 'baz', 'qux'], []],
['foo', 'bar', 'baz', 'qux'],
static fn(int $k, string $str) => true,
static fn(int $_k, string $_str) => true,
],
[
[[1 => 'bar', 2 => 'baz', 3 => 'qux'], ['foo']],
['foo', 'bar', 'baz', 'qux'],
static fn(int $k, string $str) => (bool) $k,
static fn(int $k, string $_str) => (bool) $k,
],
[
[['foo'], [1 => 'bar', 2 => 'baz', 3 => 'qux']],
['foo', 'bar', 'baz', 'qux'],
static fn(int $k, string $str) => !((bool) $k),
static fn(int $k, string $_str) => !((bool) $k),
],
];
}
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/Iter/AllTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function provideData(): iterable
yield [false, [true, true, true], static fn(bool $value): bool => !$value];
yield [false, [false, false, false], static fn(bool $value): bool => $value];
yield [true, [false, false, false], static fn(bool $value): bool => !$value];
yield [true, [false, false, false], static fn(bool $value): bool => true];
yield [false, [false, false, false], static fn(bool $value): bool => false];
yield [true, [false, false, false], static fn(bool $_value): bool => true];
yield [false, [false, false, false], static fn(bool $_value): bool => false];
yield [false, [1, 2, 3], static fn(int $i): bool => $i > 3];
yield [true, [4, 5, 6], static fn(int $i): bool => $i > 3];
yield [false, [1, 2, 3, 4, 5, 6], static fn(int $i): bool => $i > 3];
yield [true, [], static fn(bool $value): bool => false];
yield [true, [], static fn(bool $_value): bool => false];
}
}
6 changes: 3 additions & 3 deletions tests/unit/Iter/AnyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function provideData(): iterable
yield [false, [true, true, true], static fn(bool $value): bool => !$value];
yield [false, [false, false, false], static fn(bool $value): bool => $value];
yield [true, [false, false, false], static fn(bool $value): bool => !$value];
yield [true, [false, false, false], static fn(bool $value): bool => true];
yield [false, [false, false, false], static fn(bool $value): bool => false];
yield [true, [false, false, false], static fn(bool $_value): bool => true];
yield [false, [false, false, false], static fn(bool $_value): bool => false];
yield [false, [1, 2, 3], static fn(int $i): bool => $i > 3];
yield [true, [4, 5, 6], static fn(int $i): bool => $i > 3];
yield [true, [1, 2, 3, 4, 5, 6], static fn(int $i): bool => $i > 3];
yield [false, [], static fn(bool $value): bool => false];
yield [false, [], static fn(bool $_value): bool => false];
}
}
Loading

0 comments on commit bf335e0

Please sign in to comment.