-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathReflectClassConstant.php
42 lines (31 loc) · 997 Bytes
/
ReflectClassConstant.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
<?php
declare(strict_types=1);
namespace Crell\AttributeUtils\Attributes\Reflect;
use Crell\AttributeUtils\FromReflectionClassConstant;
#[\Attribute(\Attribute::TARGET_CLASS_CONSTANT)]
class ReflectClassConstant implements FromReflectionClassConstant
{
use HasVisibility;
/**
* The name of the constant, as PHP defines it.
*/
public readonly string $phpName;
/**
* The value of the constant.
*
* @var int|string|array<mixed, mixed>|object
*/
public readonly int|string|array|object $value;
/**
* True if this is a final constant, false otherwise.
*/
public readonly bool $isFinal;
public function fromReflection(\ReflectionClassConstant $subject): void
{
$this->phpName = $subject->getName();
$this->value = $subject->getValue();
$this->parseVisibility($subject);
$this->isFinal = $subject->isFinal();
// @todo Do we include doc comment, or the declaring class?
}
}