Skip to content

Commit

Permalink
Add associative-array as an alias of array
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Dec 30, 2019
1 parent bc8952c commit 79be178
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Psalm/Type.php
Expand Up @@ -262,7 +262,9 @@ public static function getTypeFromTree(

$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]));
Expand All @@ -284,7 +286,7 @@ public static function getTypeFromTree(
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);
}

Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Type/Atomic.php
Expand Up @@ -159,6 +159,7 @@ public static function create(
return new TCallable();

case 'array':
case 'associative-array':
return new TArray([new Union([new TArrayKey]), new Union([new TMixed])]);

case 'non-empty-array':
Expand Down

0 comments on commit 79be178

Please sign in to comment.