Skip to content

Commit cfcf666

Browse files
committed
[TypeInfo] Fix Type::fromValue with empty array
1 parent e06b10c commit cfcf666

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/TypeInfo/Tests/TypeFactoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ public function offsetUnset(mixed $offset): void
276276
}
277277
};
278278

279+
yield [Type::array(Type::mixed()), []];
279280
yield [Type::list(Type::int()), [1, 2, 3]];
280281
yield [Type::dict(Type::bool()), ['a' => true, 'b' => false]];
281282
yield [Type::array(Type::string()), [1 => 'foo', 'bar' => 'baz']];

src/Symfony/Component/TypeInfo/TypeFactoryTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ public static function fromValue(mixed $value): Type
444444

445445
$valueType = $valueTypes ? CollectionType::mergeCollectionValueTypes($valueTypes) : Type::mixed();
446446

447-
return self::collection($type, $valueType, $keyType, \is_array($value) && array_is_list($value));
447+
return self::collection($type, $valueType, $keyType, \is_array($value) && [] !== $value && array_is_list($value));
448448
}
449449

450450
if ($value instanceof \ArrayAccess) {

0 commit comments

Comments
 (0)