summaryrefslogtreecommitdiff
path: root/Zend/tests/ctor_promotion_attributes.phpt
blob: 1b02eef9df6edc763e69d363faf736e6968474af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--TEST--
Attributes on promoted properties are assigned to both the property and parameter
--FILE--
<?php

class Test {
    public function __construct(
        #[NonNegative]
        public int $num,
    ) {}
}

$prop = new ReflectionProperty(Test::class, 'num');
var_dump($prop->getAttributes()[0]->getName());

$param = new ReflectionParameter([Test::class, '__construct'], 'num');
var_dump($param->getAttributes()[0]->getName());

?>
--EXPECT--
string(11) "NonNegative"
string(11) "NonNegative"