diff --git a/src/DataTransferObject.php b/src/DataTransferObject.php index dc7a346..4d9df8f 100644 --- a/src/DataTransferObject.php +++ b/src/DataTransferObject.php @@ -103,7 +103,7 @@ protected function setMap(array $items): void protected function setItems(array $items): void { foreach ($items as $key => $value) { - $this->setValue($key, $value); + $this->setValue((string) $key, $value); } } diff --git a/tests/Unit/IntKeyTest.php b/tests/Unit/IntKeyTest.php new file mode 100644 index 0000000..2077098 --- /dev/null +++ b/tests/Unit/IntKeyTest.php @@ -0,0 +1,24 @@ +foo, + $this->bar, + $this->baz, + ]); + + $this->assertNull($object->foo); + $this->assertNull($object->bar); + $this->assertNull($object->baz); + } +}