forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemplateAppliedGenericObjectType.php
More file actions
51 lines (44 loc) · 1.21 KB
/
TemplateAppliedGenericObjectType.php
File metadata and controls
51 lines (44 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php declare(strict_types = 1);
namespace PHPStan\Type\Generic;
use PHPStan\Type\Type;
use function array_values;
/**
* Represents a template type used with explicit generic args at the usage site.
* For example, K<T> where @template K of IFoo.
*
* This is distinct from TemplateGenericObjectType which represents a template
* declared with a generic bound (@template K of IFoo<T>).
*/
final class TemplateAppliedGenericObjectType extends GenericObjectType
{
/**
* @param non-empty-string $templateName
* @param list<Type> $types
* @param list<TemplateTypeVariance> $variances
*/
public function __construct(
private string $templateName,
string $className,
array $types,
?Type $subtractedType = null,
array $variances = [],
)
{
parent::__construct($className, $types, $subtractedType, variances: $variances);
}
/** @return non-empty-string */
public function getTemplateName(): string
{
return $this->templateName;
}
protected function recreate(string $className, array $types, ?Type $subtractedType, array $variances = []): GenericObjectType
{
return new self(
$this->templateName,
$className,
array_values($types),
$subtractedType,
array_values($variances),
);
}
}