|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yiisoft\Proxy\Config; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @internal |
|
9
|
|
|
* |
|
10
|
|
|
* A parameter metadata. {@see ClassConfigFactory} is used for creation. Note that it relies only on PHP type hints and |
|
11
|
|
|
* ignores PHPDoc completely. |
|
12
|
|
|
*/ |
|
13
|
|
|
final class ParameterConfig |
|
14
|
|
|
{ |
|
15
|
7 |
|
public function __construct( |
|
16
|
|
|
/** |
|
17
|
|
|
* @var TypeConfig|null Type config. `null` means no type specified. |
|
18
|
|
|
*/ |
|
19
|
|
|
public ?TypeConfig $type, |
|
20
|
|
|
/** |
|
21
|
|
|
* @var string A name without dollar sign (`$`). For example: `previousNodesCount`. |
|
22
|
|
|
*/ |
|
23
|
|
|
public string $name, |
|
24
|
|
|
/** |
|
25
|
|
|
* @var bool Whether the default value available. |
|
26
|
|
|
* |
|
27
|
|
|
* @link https://www.php.net/manual/en/functions.arguments.php#functions.arguments.default |
|
28
|
|
|
*/ |
|
29
|
|
|
public bool $isDefaultValueAvailable, |
|
30
|
|
|
/** |
|
31
|
|
|
* @var bool|null Whether the default value refers to a constant (when {@see $isDefaultValueAvailable} is |
|
32
|
|
|
* `true`}). `null` means no default value specified ({@see $isDefaultValueAvailable} is `false`). |
|
33
|
|
|
* |
|
34
|
|
|
* @link https://www.php.net/manual/en/language.constants.syntax.php |
|
35
|
|
|
*/ |
|
36
|
|
|
public ?bool $isDefaultValueConstant, |
|
37
|
|
|
/** |
|
38
|
|
|
* @var string|null A constant name for default value (when it's specified, {@see $isDefaultValueAvailable} and |
|
39
|
|
|
* {@see $isDefaultValueConstant} must be `true` at the same time). `null` means no default value specified or |
|
40
|
|
|
* it's not a constant (either {@see $isDefaultValueAvailable} or {@see $isDefaultValueConstant} is `false`). |
|
41
|
|
|
* |
|
42
|
|
|
* @link https://www.php.net/manual/en/language.constants.syntax.php |
|
43
|
|
|
*/ |
|
44
|
|
|
public ?string $defaultValueConstantName, |
|
45
|
|
|
/** |
|
46
|
|
|
* @var mixed The actual value specified as default with corresponding type. `null` means no default value (only |
|
47
|
|
|
* when {@see $isDefaultValueAvailable} is `false`). |
|
48
|
|
|
*/ |
|
49
|
|
|
public mixed $defaultValue, |
|
50
|
|
|
) { |
|
51
|
7 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Whether a parameter has type. |
|
55
|
|
|
* |
|
56
|
|
|
* @return bool `true` if type specified and `false` otherwise. |
|
57
|
|
|
* |
|
58
|
|
|
* @psalm-assert-if-true TypeConfig $this->type |
|
59
|
|
|
*/ |
|
60
|
3 |
|
public function hasType(): bool |
|
61
|
|
|
{ |
|
62
|
3 |
|
return $this->type !== null; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|