Skip to content

Commit e0ad906

Browse files
authored
Merge pull request #1795 from deguif/is-iterable
Use is_iterable instead of multiple checks
2 parents 5295a37 + dbd2fea commit e0ad906

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Transformer/ModelToElasticaAutoTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function transform(object $object, array $fields): Document
8383
*/
8484
protected function transformNested($objects, array $fields)
8585
{
86-
if (\is_array($objects) || $objects instanceof \Traversable || $objects instanceof \ArrayAccess) {
86+
if (\is_iterable($objects)) {
8787
$documents = [];
8888
foreach ($objects as $object) {
8989
$document = $this->transformObjectToDocument($object, $fields);
@@ -119,7 +119,7 @@ protected function normalizeValue($value)
119119
}
120120
};
121121

122-
if (\is_array($value) || $value instanceof \Traversable || $value instanceof \ArrayAccess) {
122+
if (\is_iterable($value)) {
123123
$value = \is_array($value) ? $value : \iterator_to_array($value, false);
124124
\array_walk_recursive($value, $normalizeValue);
125125
} else {

0 commit comments

Comments
 (0)