Skip to content

Commit

Permalink
Merge pull request #32 from TheDragonCode/2.x
Browse files Browse the repository at this point in the history
Argument #1 ($key) must be of type string, int given
  • Loading branch information
Andrey Helldar authored Oct 6, 2022
2 parents 8cdba93 + 99c368c commit 1e2d258
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DataTransferObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
24 changes: 24 additions & 0 deletions tests/Unit/IntKeyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Tests\Unit;

use Tests\Fixtures\Map;
use Tests\TestCase;

class IntKeyTest extends TestCase
{
public function testMake()
{
$object = Map::make([
$this->foo,
$this->bar,
$this->baz,
]);

$this->assertNull($object->foo);
$this->assertNull($object->bar);
$this->assertNull($object->baz);
}
}

0 comments on commit 1e2d258

Please sign in to comment.