Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[php] make ObjectSerializer::toString actually return a string
  • Loading branch information
fengelniederhammer committed Apr 18, 2022
commit 8f59bfd04786f3b80f87ee63a416fd0e4aada8ef
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class ObjectSerializer
} elseif (is_bool($value)) {
return $value ? 'true' : 'false';
} else {
return $value;
return (string) $value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ docs/Model/Tag.md
docs/Model/User.md
docs/Model/UserType.md
git_push.sh
lib/ApiException.php
lib/Api/AnotherFakeApi.php
lib/Api/DefaultApi.php
lib/Api/FakeApi.php
lib/Api/FakeClassnameTags123Api.php
lib/Api/PetApi.php
lib/Api/StoreApi.php
lib/Api/UserApi.php
lib/ApiException.php
lib/Configuration.php
lib/HeaderSelector.php
lib/Model/AdditionalPropertiesClass.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public static function toString($value)
} elseif (is_bool($value)) {
return $value ? 'true' : 'false';
} else {
return $value;
return (string) $value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,44 @@ public function provideDeepObjects(): array
],
];
}

/**
* @dataProvider provideToStringInput
*/
public function testToString($input, string $expected): void
{
$result = ObjectSerializer::toString($input);

$this->assertSame($expected, $result);
}

public function provideToStringInput(): array
{
return [
'int' => [
'input' => 1,
'expected' => '1',
],
'int 0' => [
'input' => 0,
'expected' => '0',
],
'false' => [
'input' => false,
'expected' => 'false',
],
'true' => [
'input' => true,
'expected' => 'true',
],
'some string' => [
'input' => 'some string',
'expected' => 'some string',
],
'a date' => [
'input' => new \DateTime('14-04-2022'),
'expected' => '2022-04-14T00:00:00+00:00',
],
];
}
}