From 99c368ce0ab7b6adff8b23a9b738ec240bb361d1 Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Fri, 7 Oct 2022 01:15:41 +0300 Subject: [PATCH] Argument #1 ($key) must be of type string, int given --- src/DataTransferObject.php | 2 +- tests/Unit/IntKeyTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/Unit/IntKeyTest.php diff --git a/src/DataTransferObject.php b/src/DataTransferObject.php index eb75d9e..b0b0a12 100644 --- a/src/DataTransferObject.php +++ b/src/DataTransferObject.php @@ -101,7 +101,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); + } +}