mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Make a class for arrays
This commit is contained in:
parent
041f183d49
commit
baf9bcd4d7
@ -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')]),
|
||||
|
20
src/Psalm/Type/GenericArray.php
Normal file
20
src/Psalm/Type/GenericArray.php
Normal 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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user