1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Make a class for arrays

This commit is contained in:
Matthew Brown 2016-09-21 22:15:46 -04:00
parent 041f183d49
commit baf9bcd4d7
2 changed files with 26 additions and 2 deletions

View File

@ -89,6 +89,10 @@ abstract class Type
throw new \InvalidArgumentException('No generic params provided for type');
}
if ($generic_type_value === 'array') {
return new Type\GenericArray($generic_type_value, $generic_params);
}
return new Generic($generic_type_value, $generic_params);
}
@ -222,7 +226,7 @@ abstract class Type
public static function getArray()
{
$type = new Generic(
$type = new Type\GenericArray(
'array',
[
Type::getMixed(),
@ -236,7 +240,7 @@ abstract class Type
public static function getEmptyArray()
{
return new Type\Union([
new Type\Generic(
new Type\GenericArray(
'array',
[
new Type\Union([new Type\Atomic('empty')]),

View File

@ -0,0 +1,20 @@
<?php
namespace Psalm\Type;
use Psalm\Type;
class GenericArray extends Generic
{
public $value = 'array';
/**
* Constructs a new instance of a generic type
* @param string $value
* @param array<Type\Union> $type_params
*/
public function __construct($value, array $type_params)
{
$this->type_params = $type_params;
}
}