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

Commit 1e2d258

Browse files
author
Andrey Helldar
authored
Merge pull request #32 from TheDragonCode/2.x
Argument #1 ($key) must be of type string, int given
2 parents 8cdba93 + 99c368c commit 1e2d258

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
@@ -103,7 +103,7 @@ protected function setMap(array $items): void
103103
protected function setItems(array $items): void
104104
{
105105
foreach ($items as $key => $value) {
106-
$this->setValue($key, $value);
106+
$this->setValue((string) $key, $value);
107107
}
108108
}
109109

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)