Skip to content

Commit

Permalink
mago fmt using 0.0.8
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed Dec 14, 2024
1 parent cba1ab3 commit 1957c18
Show file tree
Hide file tree
Showing 28 changed files with 92 additions and 243 deletions.
3 changes: 2 additions & 1 deletion src/Psl/Collection/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ public function slice(int $start, null|int $length = null): Map
public function chunk(int $size): Vector
{
/** @psalm-suppress ImpureMethodCall */
return $this->zip($this->keys()->toArray())
return $this
->zip($this->keys()->toArray())
->values()
->chunk($size)
->map(
Expand Down
3 changes: 2 additions & 1 deletion src/Psl/Collection/MutableMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ public function slice(int $start, null|int $length = null): MutableMap
public function chunk(int $size): MutableVector
{
/** @psalm-suppress ImpureMethodCall */
return $this->zip($this->keys()->toArray())
return $this
->zip($this->keys()->toArray())
->values()
->chunk($size)
->map(
Expand Down
5 changes: 1 addition & 4 deletions tests/static-analysis/Fun/pipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ function test_output_type_is_known(): void
{
$stages = pipe(static fn(string $_x): int => 2);

Psl\invariant(
is_int($stages('hello')),
'Expected output of int',
);
Psl\invariant(is_int($stages('hello')), 'Expected output of int');
}

/**
Expand Down
9 changes: 4 additions & 5 deletions tests/unit/Async/AwaitableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,8 @@ public function testThenOnSuccess(): void
return 'hello';
});

$awaitable = $awaitable->then(
static fn(string $result) => Str\reverse($result),
static fn(Throwable $_exception) => exit(0),
)
$awaitable = $awaitable
->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),
Expand All @@ -206,7 +204,8 @@ public function testMap(): void
});

$ref = new Psl\Ref('');
$awaitable = $awaitable->map(static fn(string $result) => Str\reverse($result))
$awaitable = $awaitable
->map(static fn(string $result) => Str\reverse($result))
->map(static fn(string $result) => throw new InvariantViolationException($result))
->catch(static fn(InvariantViolationException $exception): string => $exception->getMessage())
->always(static fn() => $ref->value = 'hello');
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/Collection/AbstractMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,8 @@ public function testIsEmpty(): void
public function testCount(): void
{
static::assertCount(0, $this->default());
static::assertCount(
0,
$this->create([]),
);
static::assertCount(
1,
$this->create(['foo' => 'bar']),
);
static::assertCount(0, $this->create([]));
static::assertCount(1, $this->create(['foo' => 'bar']));
static::assertSame(
5,
$this->create([
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/Collection/AbstractSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,8 @@ public function testIsEmpty(): void
public function testCount(): void
{
static::assertCount(0, $this->default());
static::assertCount(
0,
$this->createFromList([]),
);
static::assertCount(
2,
$this->createFromList(['foo', 'bar']),
);
static::assertCount(0, $this->createFromList([]));
static::assertCount(2, $this->createFromList(['foo', 'bar']));
static::assertSame(
5,
$this->createFromList([
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/Collection/AbstractVectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,8 @@ public function testIsEmpty(): void
public function testCount(): void
{
static::assertCount(0, $this->default());
static::assertCount(
0,
$this->create([]),
);
static::assertCount(
2,
$this->create(['foo', 'bar']),
);
static::assertCount(0, $this->create([]));
static::assertCount(2, $this->create(['foo', 'bar']));
static::assertSame(
5,
$this->create([
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/Collection/MutableMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public function testAdd(): void
'bar' => 'baz',
]);

$modified = $map->add('foo', 'foo')->add('bar', 'bar')->add('baz', 'baz')->add('qux', 'qux');
$modified = $map
->add('foo', 'foo')
->add('bar', 'bar')
->add('baz', 'baz')
->add('qux', 'qux');

static::assertSame($modified, $map);

Expand Down
6 changes: 5 additions & 1 deletion tests/unit/Collection/MutableSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public function testAdd(): void
'qux',
]);

$modified = $set->add('foo')->add('bar')->add('baz')->add('qux');
$modified = $set
->add('foo')
->add('bar')
->add('baz')
->add('qux');

static::assertSame($modified, $set);

Expand Down
10 changes: 2 additions & 8 deletions tests/unit/DateTime/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,7 @@ public function testPlusMonthOverflows(): void
$expected_month = ($previous_month + 1) % 12;
$expected_month = ($expected_month === 0) ? 12 : $expected_month;

static::assertSame(
$res->getDay(),
$res->getMonthEnum()->getDaysForYear($res->getYear()),
);
static::assertSame($res->getDay(), $res->getMonthEnum()->getDaysForYear($res->getYear()));
static::assertSame($res->getMonth(), $expected_month);

$previous_month = $expected_month;
Expand Down Expand Up @@ -495,10 +492,7 @@ public function testMinusMonthOverflows(): void
$expected_month = $previous_month - 1;
$expected_month = ($expected_month === 0) ? 12 : $expected_month;

static::assertSame(
$res->getDay(),
$res->getMonthEnum()->getDaysForYear($res->getYear()),
);
static::assertSame($res->getDay(), $res->getMonthEnum()->getDaysForYear($res->getYear()));
static::assertSame($res->getMonth(), $expected_month);

$previous_month = $expected_month;
Expand Down
5 changes: 1 addition & 4 deletions tests/unit/Dict/AssociateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ public function testAssociateCollections(): void
{
static::assertSame(
['a' => 1, 'b' => 2, 'c' => 3],
Dict\associate(
Collection\Vector::fromArray(['a', 'b', 'c']),
Collection\Vector::fromArray([1, 2, 3]),
),
Dict\associate(Collection\Vector::fromArray(['a', 'b', 'c']), Collection\Vector::fromArray([1, 2, 3])),
);
}

Expand Down
59 changes: 11 additions & 48 deletions tests/unit/Dict/FilterNullsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,17 @@ final class FilterNullsTest extends TestCase
{
public function testFilterNulls(): void
{
static::assertCount(
0,
Dict\filter_nulls([]),
);
static::assertCount(
0,
Dict\filter_nulls([null, null]),
);
static::assertCount(
1,
Dict\filter_nulls([null, false]),
);
static::assertCount(
1,
Dict\filter_nulls([null, 'null']),
);
static::assertCount(
1,
Dict\filter_nulls(['null']),
);
static::assertCount(
1,
Dict\filter_nulls(Iter\Iterator::create(['null'])),
);
static::assertCount(
0,
Dict\filter_nulls(Iter\Iterator::create([null])),
);
static::assertCount(
0,
Dict\filter_nulls(Iter\Iterator::create([null, null])),
);
static::assertCount(
3,
Dict\filter_nulls(Iter\Iterator::create([null, false, '', 0])),
);
static::assertCount(
3,
Dict\filter_nulls(
new Collection\Vector([null, false, '', 0]),
),
);
static::assertCount(
3,
Dict\filter_nulls(
new Collection\Map([null, false, '', 0]),
),
);
static::assertCount(0, Dict\filter_nulls([]));
static::assertCount(0, Dict\filter_nulls([null, null]));
static::assertCount(1, Dict\filter_nulls([null, false]));
static::assertCount(1, Dict\filter_nulls([null, 'null']));
static::assertCount(1, Dict\filter_nulls(['null']));
static::assertCount(1, Dict\filter_nulls(Iter\Iterator::create(['null'])));
static::assertCount(0, Dict\filter_nulls(Iter\Iterator::create([null])));
static::assertCount(0, Dict\filter_nulls(Iter\Iterator::create([null, null])));
static::assertCount(3, Dict\filter_nulls(Iter\Iterator::create([null, false, '', 0])));
static::assertCount(3, Dict\filter_nulls(new Collection\Vector([null, false, '', 0])));
static::assertCount(3, Dict\filter_nulls(new Collection\Map([null, false, '', 0])));
static::assertCount(
3,
Dict\filter_nulls((static function (): iterable {
Expand Down
5 changes: 1 addition & 4 deletions tests/unit/Dict/GroupByTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public function testGroupByThrowsWhenKeyFunReturnsNonArrayKey(): void
'Expected $key_func to return a value of type array-key, value of type (object) returned.',
);

Dict\group_by(
[0, 1, 2, 3, 4, 5],
static fn($x) => new Collection\Vector([$x, $x]),
);
Dict\group_by([0, 1, 2, 3, 4, 5], static fn($x) => new Collection\Vector([$x, $x]));
}
}
10 changes: 2 additions & 8 deletions tests/unit/Env/SplitPathsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,8 @@ final class SplitPathsTest extends TestCase
{
public function testSplitPaths(): void
{
static::assertSame(
['/home/azjezz', '/tmp'],
Env\split_paths(Str\format('/home/azjezz%s/tmp', PATH_SEPARATOR)),
);
static::assertSame(
['/home/azjezz', '/tmp'],
Env\split_paths(Env\join_paths('/home/azjezz', '/tmp')),
);
static::assertSame(['/home/azjezz', '/tmp'], Env\split_paths(Str\format('/home/azjezz%s/tmp', PATH_SEPARATOR)));
static::assertSame(['/home/azjezz', '/tmp'], Env\split_paths(Env\join_paths('/home/azjezz', '/tmp')));
static::assertSame(['/home/azjezz'], Env\split_paths('/home/azjezz'));
}
}
13 changes: 2 additions & 11 deletions tests/unit/Json/TypedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ public function testTyped(): void
"keywords": ["php", "std", "stdlib", "utility", "psl"],
"license": "MIT"
}',
Type\map(
Type\string(),
Type\union(
Type\string(),
Type\vector(Type\string()),
),
),
Type\map(Type\string(), Type\union(Type\string(), Type\vector(Type\string()))),
);

static::assertInstanceOf(MapInterface::class, $actual);
Expand All @@ -44,10 +38,7 @@ public function testTyped(): void

public function testTypedVector(): void
{
$actual = Json\typed(
'["php", "std", "stdlib", "utility", "psl"]',
Type\vector(Type\string()),
);
$actual = Json\typed('["php", "std", "stdlib", "utility", "psl"]', Type\vector(Type\string()));

static::assertInstanceOf(VectorInterface::class, $actual);
static::assertSame(['php', 'std', 'stdlib', 'utility', 'psl'], $actual->toArray());
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/Option/NoneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,8 @@ public function testComparable(): void
$a = Option\none();

static::assertInstanceOf(Comparable::class, $a);
static::assertSame(
Order::Equal,
$a->compare(Option\none()),
);
static::assertSame(
Order::Less,
$a->compare(Option\some('some')),
);
static::assertSame(Order::Equal, $a->compare(Option\none()));
static::assertSame(Order::Less, $a->compare(Option\some('some')));
static::assertSame(Order::Greater, Option\some('some')->compare($a));
}

Expand Down
20 changes: 4 additions & 16 deletions tests/unit/Option/SomeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,10 @@ public function testComparable(): void
$a = Option\some(2);

static::assertInstanceOf(Comparable::class, $a);
static::assertSame(
Order::Equal,
$a->compare(Option\some(2)),
);
static::assertSame(
Order::Less,
Option\none()->compare(Option\some(1)),
);
static::assertSame(
Order::Greater,
$a->compare(Option\none()),
);
static::assertSame(
Order::Less,
$a->compare(Option\some(3)),
);
static::assertSame(Order::Equal, $a->compare(Option\some(2)));
static::assertSame(Order::Less, Option\none()->compare(Option\some(1)));
static::assertSame(Order::Greater, $a->compare(Option\none()));
static::assertSame(Order::Less, $a->compare(Option\some(3)));
}

public function testEquality()
Expand Down
6 changes: 1 addition & 5 deletions tests/unit/Regex/EveryMatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ public function testInvalidCaptureGroup(): void
$this->expectException(Regex\Exception\RuntimeException::class);
$this->expectExceptionMessage('Invalid capture groups');

Regex\every_match(
'hello',
'/(hello)/',
capture_groups(['doesnotexist']),
);
Regex\every_match('hello', '/(hello)/', capture_groups(['doesnotexist']));
}

public function provideMatchingData(): iterable
Expand Down
6 changes: 1 addition & 5 deletions tests/unit/Regex/FirstMatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ public function testInvalidCaptureGroup(): void
$this->expectException(Regex\Exception\RuntimeException::class);
$this->expectExceptionMessage('Invalid capture groups');

Regex\first_match(
'hello',
'/(hello)/',
capture_groups(['doesnotexist']),
);
Regex\first_match('hello', '/(hello)/', capture_groups(['doesnotexist']));
}

public function provideMatchingData(): iterable
Expand Down
5 changes: 1 addition & 4 deletions tests/unit/Str/ConcatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public function testConcat(): void
{
static::assertSame('', Str\concat(''));
static::assertSame('abc', Str\concat('a', 'b', 'c'));
static::assertSame(
'مرحبا بكم',
Str\concat(...['م', 'ر', 'ح', 'ب', 'ا', ' ', 'ب', 'ك', 'م']),
);
static::assertSame('مرحبا بكم', Str\concat(...['م', 'ر', 'ح', 'ب', 'ا', ' ', 'ب', 'ك', 'م']));
}
}
9 changes: 5 additions & 4 deletions tests/unit/TCP/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ public function testNextConnectionOnStoppedServer(): void
$server = TCP\Server::create(
'127.0.0.1',
0,
TCP\ServerOptions::create()->withNoDelay(true)->withSocketOptions(Network\SocketOptions::create()
->withAddressReuse(false)
->withPortReuse(false)
->withBroadcast(true)),
TCP\ServerOptions::create()->withNoDelay(
true,
)->withSocketOptions(Network\SocketOptions::create()->withAddressReuse(false)->withPortReuse(
false,
)->withBroadcast(true)),
);

$server->close();
Expand Down
Loading

0 comments on commit 1957c18

Please sign in to comment.