-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathReflectParameter.php
56 lines (44 loc) · 1.38 KB
/
ReflectParameter.php
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
52
53
54
55
56
<?php
declare(strict_types=1);
namespace Crell\AttributeUtils\Attributes\Reflect;
use Crell\AttributeUtils\FromReflectionParameter;
use Crell\AttributeUtils\TypeDef;
#[\Attribute(\Attribute::TARGET_PARAMETER)]
class ReflectParameter implements FromReflectionParameter
{
/**
* The name of the parameter, as PHP defines it.
*/
public readonly string $phpName;
/**
* True if this parameter is passed by reference, false if not.
*/
public readonly bool $isPassByReference;
/**
* The position of the parameter, 0-based.
*/
public readonly int $position;
/**
* True if this parameter is optional, false otherwise.
*/
public readonly bool $isOptional;
/**
* True if this parameter is variadic, false otherwise.
*/
public readonly bool $isVariadic;
/**
* The type of this parameter.
*
* A missing type declaration will be treated as "mixed".
*/
public readonly TypeDef $type;
public function fromReflection(\ReflectionParameter $subject): void
{
$this->phpName = $subject->getName();
$this->isPassByReference = $subject->isPassedByReference();
$this->position = $subject->getPosition();
$this->isOptional = $subject->isOptional();
$this->isVariadic = $subject->isVariadic();
$this->type = new TypeDef($subject->getType());
}
}