Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/96'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jan 7, 2019
2 parents 0f697c8 + 6dce3a4 commit bdc189f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 3.0.1 - TBD
## 3.0.1 - 2019-01-07

### Added

Expand All @@ -28,6 +28,9 @@ All notable changes to this project will be documented in this file, in reverse
method could not be invoked as documented previously, these changes are
considered bugfixes and not BC breaks.

- [#96](https://github.com/zendframework/zend-hydrator/pull/96) fixes issue with integer keys in `ArraySerializableHydrator`. Keys are now
cast to strings as we have strict type declaration in the library.

## 3.0.0 - 2018-12-10

### Added
Expand Down
2 changes: 2 additions & 0 deletions src/ArraySerializableHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function extract(object $object) : array
$filter = $this->getFilter();

foreach ($data as $name => $value) {
$name = (string) $name;

if (! $filter->filter($name)) {
unset($data[$name]);
continue;
Expand Down
14 changes: 14 additions & 0 deletions test/ArraySerializableHydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace ZendTest\Hydrator;

use ArrayObject;
use PHPUnit\Framework\TestCase;
use TypeError;
use Zend\Hydrator\ArraySerializableHydrator;
Expand Down Expand Up @@ -169,4 +170,17 @@ public function testHydrationWillReplaceNestedArrayData($start, $submit, $expect

$this->assertSame($expected, $final['tags']);
}

public function testExtractArrayObject()
{
$arrayObject = new ArrayObject([
'value1',
'value2',
'value3',
]);

$data = $this->hydrator->extract($arrayObject);

$this->assertSame(['value1', 'value2', 'value3'], $data);
}
}

0 comments on commit bdc189f

Please sign in to comment.