1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 07:28:09 +02:00
Files
archived-php-src/Zend/tests/attributes/014_class_const_group.phpt
T
Nikita Popov 36ed9966ce Allow attributes to be applied to property/constant groups
Remove arbitrary restriction that attributes cannot be applied
to property/constant groups.

The attribute applies to all elements of the group, just like
modifiers and types do.

See also https://externals.io/message/111914.

Closes GH-6186.
2020-09-27 11:35:48 +02:00

37 lines
546 B
PHP

--TEST--
Attributes can be applied to groups of class constants
--FILE--
<?php
class C
{
#[A(1, X)]
public const A = 1, B = 2;
}
const X = 2;
$rp1 = new ReflectionClassConstant('C', 'A');
$ra1 = $rp1->getAttributes()[0];
var_dump($ra1->getName(), $ra1->getArguments());
$rp2 = new ReflectionClassConstant('C', 'B');
$ra2 = $rp2->getAttributes()[0];
var_dump($ra2->getName(), $ra2->getArguments());
?>
--EXPECT--
string(1) "A"
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
string(1) "A"
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}