Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Objects/DocBlockParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ private function parseType(string $contents, int &$i): string
continue;
}

if (\in_array($char, ['|', ','])) {
if (\in_array($char, ['|', ',', ':'])) {
$type .= $char;
$lastChar = $char;
$sawSpace = false;
continue;
}

if ($sawSpace && ! \in_array($lastChar, ['|', ','])) {
if ($sawSpace && ! \in_array($lastChar, ['|', ',', ':'])) {
break;
}

Expand Down
16 changes: 16 additions & 0 deletions tests/MapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Jerodev\DataMapper\Mapper;
use Jerodev\DataMapper\MapperConfig;
use Jerodev\DataMapper\Tests\_Mocks\Aliases;
use Jerodev\DataMapper\Tests\_Mocks\ArrayProperties;
use Jerodev\DataMapper\Tests\_Mocks\Constructor;
use Jerodev\DataMapper\Tests\_Mocks\Nullable;
use Jerodev\DataMapper\Tests\_Mocks\SelfMapped;
Expand Down Expand Up @@ -209,5 +210,20 @@ public static function objectValuesDataProvider(): Generator
],
$dto,
];

// Special array cases
$dto = new ArrayProperties();
$dto->ints = [2, 5, 8];
$dto->fieldsWithKeys = [
3 => [
'foo' => 'bar',
'bar' => 8,
],
];
yield [
ArrayProperties::class,
(array)$dto,
$dto,
];
}
}
12 changes: 12 additions & 0 deletions tests/_Mocks/ArrayProperties.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Jerodev\DataMapper\Tests\_Mocks;

class ArrayProperties
{
/** @var array<int> */
public array $ints;

/** @var array<int, array{foo: string, bar: int}> */
public array $fieldsWithKeys;
}