Skip to content

Commit

Permalink
fix(metadata) : fix string being cast to int
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRebeilleau committed Apr 3, 2023
1 parent 6157332 commit 2ab609b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class IntegerUriVariableTransformer implements UriVariableTransformerInter
{
public function transform(mixed $value, array $types, array $context = []): int
{
return (int) $value;
return is_numeric($value) ? (int) $value : $value;
}

public function supportsTransformation(mixed $value, array $types, array $context = []): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public function testTransform(): void
$this->assertSame(2, (new IntegerUriVariableTransformer())->transform('2', ['int']));
}

public function testCastString()
{
$this->assertSame('7foo', (new IntegerUriVariableTransformer())->transform('7foo', ['int']));
}

public function testSupportsTransformation(): void
{
$normalizer = new IntegerUriVariableTransformer();
Expand Down

0 comments on commit 2ab609b

Please sign in to comment.