Skip to content

Commit

Permalink
chore: apply mago fix -p
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed Dec 29, 2024
1 parent 4f56226 commit 70b9b86
Show file tree
Hide file tree
Showing 29 changed files with 164 additions and 171 deletions.
26 changes: 10 additions & 16 deletions tests/static-analysis/Fun/pipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@ function test_too_few_argument_dont_matter(): int
}

/**
* @psalm-suppress InvalidArgument, UnusedClosureParam
* @psalm-suppress InvalidArgument
*/
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');
}

/**
* @psalm-suppress UnusedClosureParam
*/
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 @@ -55,40 +52,37 @@ function test_invalid_arguments(): void
}

/**
* @psalm-suppress InvalidScalarArgument, UnusedClosureParam
* @psalm-suppress InvalidScalarArgument
*/
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');
}

/**
* @psalm-suppress UnusedClosureParam, InvalidArgument
* @psalm-suppress InvalidArgument
*/
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);
}

/**
* @throws InvariantViolationException
*
* @psalm-suppress UnusedClosureParam, RedundantCondition
* @psalm-suppress RedundantCondition
*/
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')), 'Expected output of int');
}

/**
* @psalm-suppress UnusedClosureParam
*/
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);
}
6 changes: 2 additions & 4 deletions tests/static-analysis/Type/intersection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
use Psl\Type;

/**
* @psalm-suppress UnusedParam
*
* @param Map&ResultInterface&stdClass&Vector $value
* @param Map&ResultInterface&stdClass&Vector $_value
*/
function takes_valid_intersection($value): void
function takes_valid_intersection($_value): void
{
}

Expand Down
4 changes: 1 addition & 3 deletions tests/static-analysis/Type/union.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
use Psl\Type;

/**
* @psalm-suppress UnusedParam
*
* @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 @@ -186,13 +186,13 @@ public function testThenOnSuccess(): void
});

$awaitable = $awaitable
->then(static fn(string $result) => Str\reverse($result), static fn(Throwable $exception) => exit(0))
->then(static fn(string $result) => Str\reverse($result), 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 @@ -181,7 +181,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 @@ -261,14 +261,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 @@ -423,19 +423,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 @@ -481,25 +481,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 @@ -348,19 +348,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 @@ -406,25 +406,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 @@ -157,7 +157,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 @@ -237,14 +237,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 @@ -392,19 +392,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 @@ -450,25 +450,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
Loading

0 comments on commit 70b9b86

Please sign in to comment.