ru_php/Zend/tests/readonly_props/override_with_attributes.phpt

27 lines
429 B
PHP

--TEST--
Can override readonly property with attributes
--FILE--
<?php
#[Attribute]
class FooAttribute {}
class A {
public readonly int $prop;
public function __construct() {
$this->prop = 42;
}
}
class B extends A {
#[FooAttribute]
public readonly int $prop;
}
var_dump((new ReflectionProperty(B::class, 'prop'))->getAttributes()[0]->newInstance());
?>
--EXPECT--
object(FooAttribute)#1 (0) {
}