Skip to content

Commit 6214b42

Browse files
committed
Fixes #43
1 parent c93abd8 commit 6214b42

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/ParameterHelper.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ private static function filterInvalidType($value)
7676
*/
7777
private static function emptySequenceToArray($value): ?array
7878
{
79-
if ($value instanceof Sequence && $value->count() === 0) {
79+
if (($value instanceof Sequence && $value->count() === 0) ||
80+
(is_array($value) && count($value) === 0)) {
8081
return [];
8182
}
8283

@@ -88,9 +89,7 @@ private static function emptySequenceToArray($value): ?array
8889
*/
8990
private static function emptyDictionaryToStdClass($value): ?stdClass
9091
{
91-
if (($value instanceof Map && $value->count() === 0) ||
92-
(is_array($value) && count($value) === 0)
93-
) {
92+
if ($value instanceof Map && $value->count() === 0) {
9493
return new stdClass();
9594
}
9695

tests/Unit/ParameterHelperTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,23 @@ public function testFormatParameterInvalidIterable2(): void
117117
]);
118118
}
119119

120-
public function testAsParmeterEmptyVector(): void
120+
public function testAsParameterEmptyVector(): void
121121
{
122122
$result = ParameterHelper::asParameter(new Vector());
123123
self::assertIsArray($result);
124124
self::assertCount(0, $result);
125125
}
126126

127-
public function testAsParmeterEmptyMap(): void
127+
public function testAsParameterEmptyMap(): void
128128
{
129129
$result = ParameterHelper::asParameter(new Map());
130130
self::assertInstanceOf(stdClass::class, $result);
131131
}
132132

133-
public function testAsParmeterEmptyArray(): void
133+
public function testAsParameterEmptyArray(): void
134134
{
135135
$result = ParameterHelper::asParameter([]);
136-
self::assertInstanceOf(stdClass::class, $result);
136+
self::assertIsArray($result);
137137
}
138138

139139
public function testStringable(): void

0 commit comments

Comments
 (0)