-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathDefaultParameterMap.php
More file actions
47 lines (37 loc) · 934 Bytes
/
DefaultParameterMap.php
File metadata and controls
47 lines (37 loc) · 934 Bytes
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
<?php declare(strict_types = 1);
namespace PHPStan\Symfony;
use PhpParser\Node\Expr;
use PHPStan\Analyser\Scope;
use PHPStan\Type\Type;
use PHPStan\Type\TypeUtils;
use function array_map;
final class DefaultParameterMap implements ParameterMap
{
/** @var ParameterDefinition[] */
private $parameters;
/**
* @param ParameterDefinition[] $parameters
*/
public function __construct(array $parameters)
{
$this->parameters = $parameters;
}
/**
* @return ParameterDefinition[]
*/
public function getParameters(): array
{
return $this->parameters;
}
public function getParameter(string $key): ?ParameterDefinition
{
return $this->parameters[$key] ?? null;
}
public function getParameterKeysFromNode(Expr $node, Scope $scope): array
{
$strings = TypeUtils::getConstantStrings($scope->getType($node));
return array_map(static function (Type $type) {
return $type->getValue();
}, $strings);
}
}