mirror of
https://github.com/php/php-src.git
synced 2024-12-12 03:15:29 +08:00
064b464448
RFC: https://wiki.php.net/rfc/constructor_promotion Closes GH-5291.
23 lines
500 B
PHP
23 lines
500 B
PHP
--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"
|