Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.

Commit 99c368c

Browse files
Argument #1 ($key) must be of type string, int given
1 parent 6bb079b commit 99c368c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/DataTransferObject.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function setMap(array $items): void
101101
protected function setItems(array $items): void
102102
{
103103
foreach ($items as $key => $value) {
104-
$this->setValue($key, $value);
104+
$this->setValue((string) $key, $value);
105105
}
106106
}
107107

tests/Unit/IntKeyTest.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Unit;
6+
7+
use Tests\Fixtures\Map;
8+
use Tests\TestCase;
9+
10+
class IntKeyTest extends TestCase
11+
{
12+
public function testMake()
13+
{
14+
$object = Map::make([
15+
$this->foo,
16+
$this->bar,
17+
$this->baz,
18+
]);
19+
20+
$this->assertNull($object->foo);
21+
$this->assertNull($object->bar);
22+
$this->assertNull($object->baz);
23+
}
24+
}

0 commit comments

Comments
 (0)