Skip to content

Commit 2ac0ada

Browse files
committed
Changed key default to string|int for an array
1 parent 7bea912 commit 2ac0ada

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Types/Array_.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ final class Array_ implements Type
4141
public function __construct(Type $valueType = null, Type $keyType = null)
4242
{
4343
if ($keyType === null) {
44-
$keyType = new Mixed();
44+
$keyType = new Compound([ new String_(), new Integer() ]);
4545
}
4646
if ($valueType === null) {
4747
$valueType = new Mixed();

tests/unit/TypeResolverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function testResolvingTypedArrays()
137137

138138
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $resolvedType);
139139
$this->assertSame('string[]', (string)$resolvedType);
140-
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Mixed', $resolvedType->getKeyType());
140+
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Compound', $resolvedType->getKeyType());
141141
$this->assertInstanceOf('phpDocumentor\Reflection\Types\String_', $resolvedType->getValueType());
142142
}
143143

@@ -163,11 +163,11 @@ public function testResolvingNestedTypedArrays()
163163
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $resolvedType);
164164

165165
$this->assertSame('string[][]', (string)$resolvedType);
166-
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Mixed', $resolvedType->getKeyType());
166+
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Compound', $resolvedType->getKeyType());
167167
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $childValueType);
168168

169169
$this->assertSame('string[]', (string)$childValueType);
170-
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Mixed', $childValueType->getKeyType());
170+
$this->assertInstanceOf('phpDocumentor\Reflection\Types\Compound', $childValueType->getKeyType());
171171
$this->assertInstanceOf('phpDocumentor\Reflection\Types\String_', $childValueType->getValueType());
172172
}
173173

0 commit comments

Comments
 (0)