Skip to content
Permalink
Browse files

Add associative-array as an alias of array

  • Loading branch information
muglug committed Dec 30, 2019
1 parent bc8952c commit 79be178146aaff0a53de602e450c993fcc12846e
Showing with 5 additions and 2 deletions.
  1. +4 −2 src/Psalm/Type.php
  2. +1 −0 src/Psalm/Type/Atomic.php
@@ -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]));
@@ -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);
}

@@ -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':

0 comments on commit 79be178

Please sign in to comment.
You can’t perform that action at this time.