-
-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Description
The following code:
var_export((new ReflectionClass(Attribute::class))->getConstants());
In PHP 8.0-8.4 returns:
array (
'TARGET_CLASS' => 1,
'TARGET_FUNCTION' => 2,
'TARGET_METHOD' => 4,
'TARGET_PROPERTY' => 8,
'TARGET_CLASS_CONSTANT' => 16,
'TARGET_PARAMETER' => 32,
'TARGET_ALL' => 63,
'IS_REPEATABLE' => 64,
)
PHP 8.5 introduced attributes on constants, so the array in PHP 8.5 is:
array (
'TARGET_CLASS' => 1,
'TARGET_FUNCTION' => 2,
'TARGET_METHOD' => 4,
'TARGET_PROPERTY' => 8,
'TARGET_CLASS_CONSTANT' => 16,
'TARGET_PARAMETER' => 32,
'TARGET_CONSTANT' => 64,
'TARGET_ALL' => 127,
'IS_REPEATABLE' => 128,
)
How to address the issue?
Should the existing stub be updated with something like:
public const TARGET_CONSTANT = \PHP_VERSION_ID >= 80500 ? 64 : null;
public const TARGET_ALL = \PHP_VERSION_ID >= 80500 ? 127 : 63;
public const IS_REPEATABLE = \PHP_VERSION_ID >= 80500 ? 128 : 64;
Or maybe a new Attribute
class in src/Php85/Resources/stubs
?
There is no ternary operator in any constant yet, and also there are not 2 the same classes for different PHP versions, so each of the above would be the first such solution
Or any better idea to address the problem?
Metadata
Metadata
Assignees
Labels
No labels