Skip to content

Commit

Permalink
Narrow types
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jun 27, 2024
1 parent 55a0c54 commit 72744de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/unit/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#[Small]
final class ParserTest extends TestCase
{
/**
* @return non-empty-array<non-empty-string, array{0: array, 1: Schema, 2: non-empty-string, 3: bool, 4: ?non-empty-string, 5: ?non-empty-string, 6: ?non-empty-string}>
*/
public static function provider(): array
{
$allFieldsSchema = Schema::from(
Expand Down Expand Up @@ -165,6 +168,9 @@ public static function provider(): array
];
}

/**
* @param array<string, bool|float|int|object|string> $expected
*/
#[DataProvider('provider')]
public function test_Parses_CSV_file_according_to_schema(array $expected, Schema $schema, string $filename, bool $ignoreFirstLine, ?string $separator, ?string $enclosure, ?string $escape): void
{
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/schema/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public function map(string $value): DateTimeImmutable
}
};

$this->assertSame('2023-03-24', Type::object($callback)->apply('2023-03-24')->format('Y-m-d'));
$object = Type::object($callback)->apply('2023-03-24');

$this->assertInstanceOf(DateTimeImmutable::class, $object);
$this->assertSame('2023-03-24', $object->format('Y-m-d'));
}

public function testKeepsStringsAsTheyAre(): void
Expand Down

0 comments on commit 72744de

Please sign in to comment.