1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Add associative-array as an alias of array

This commit is contained in:
Matthew Brown 2019-12-30 17:01:10 -05:00
parent bc8952c793
commit 79be178146
2 changed files with 5 additions and 2 deletions

View File

@ -262,7 +262,9 @@ abstract class Type
$generic_type_value = self::fixScalarTerms($generic_type);
if (($generic_type_value === 'array' || $generic_type_value === 'non-empty-array')
if (($generic_type_value === 'array'
|| $generic_type_value === 'non-empty-array'
|| $generic_type_value === 'associative-array')
&& count($generic_params) === 1
) {
array_unshift($generic_params, new Union([new TArrayKey]));
@ -284,7 +286,7 @@ abstract class Type
throw new TypeParseTreeException('No generic params provided for type');
}
if ($generic_type_value === 'array') {
if ($generic_type_value === 'array' || $generic_type_value === 'associative-array') {
return new TArray($generic_params);
}

View File

@ -159,6 +159,7 @@ abstract class Atomic
return new TCallable();
case 'array':
case 'associative-array':
return new TArray([new Union([new TArrayKey]), new Union([new TMixed])]);
case 'non-empty-array':