Skip to content

Commit

Permalink
Fix formatParameter() for boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
jderusse committed Nov 20, 2023
1 parent e4e0855 commit 2bbab09
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/Migrations/InlineParameterFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function formatParameters(array $params, array $types): string
return sprintf('with parameters (%s)', implode(', ', $formattedParameters));
}

private function formatParameter(mixed $value, string|int $type): string|int|float|null
private function formatParameter(mixed $value, string|int $type): string|int|bool|float|null
{
if (is_string($type) && Type::hasType($type)) {
return Type::getType($type)->convertToDatabaseValue(
Expand Down
28 changes: 16 additions & 12 deletions tests/Doctrine/Migrations/Tests/InlineParameterFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@ public function testFormatParameters(): void
{
$params = [
0 => 'string value',
1 => 1,
2 => 1.5,
3 => [1, true, false, 'string value'],
4 => true,
5 => false,
6 => 'string value',
7 => 1,
8 => 1.5,
9 => true,
10 => false,
11 => [1, true, false, 'string value'],
1 => true,
2 => false,
3 => 1,
4 => 1.5,
5 => [1, true, false, 'string value'],
6 => true,
7 => false,
8 => 'string value',
9 => 1,
10 => 1.5,
11 => true,
12 => false,
13 => [1, true, false, 'string value'],
'named' => 'string value',
];

$types = [
Types::STRING,
Types::STRING,
Types::STRING,
Types::INTEGER,
Types::FLOAT,
Expand All @@ -54,7 +58,7 @@ public function testFormatParameters(): void

$result = $this->parameterFormatter->formatParameters($params, $types);

$expected = 'with parameters ([string value], [1], [1.5], [1,1,,string value], [], [], [string value], [1], [1.5], [true], [false], [1, true, false, string value], :named => [string value])';
$expected = 'with parameters ([string value], [1], [], [1], [1.5], [1,1,,string value], [], [], [string value], [1], [1.5], [true], [false], [1, true, false, string value], :named => [string value])';

self::assertSame($expected, $result);
}
Expand Down

0 comments on commit 2bbab09

Please sign in to comment.