Skip to content

Commit

Permalink
Merge branch 'bugfix/structurefactory-mixed-key-handling'
Browse files Browse the repository at this point in the history
Thanks to @staabm for finding and fixing this one!
(#3)
  • Loading branch information
Rican7 committed Jul 1, 2015
2 parents 17fc709 + 5561a76 commit 28c4fea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Incoming/Structure/StructureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected static function buildFromTraversable(Traversable $data)

// Traverse through the data, but only check the first item's key
foreach ($data as $key => &$val) {
$is_map = !is_int($key);
$is_map = $is_map || !is_int($key);

$val = self::attemptBuildTraversableLike($val);
}
Expand Down
15 changes: 15 additions & 0 deletions tests/Incoming/Test/Structure/StructureFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,19 @@ public function testBuildWithInvalidStructuralType()

$structure = (new StructureFactory)->build($data);
}

/**
* @link https://github.com/Rican7/incoming/pull/3
*/
public function testBuildWithTraversableAndMixedKeys()
{
$data = new ArrayIterator([
'name' => 'markus',
0 => 'a crazy mixed-in key'
]);

$structure = (new StructureFactory)->build($data);

$this->assertTrue($structure instanceof Map);
}
}

0 comments on commit 28c4fea

Please sign in to comment.