Who Modifies This Property?¶
<?php
class x {
function __construct(
int &$y { get => $this->y; },
) {}
}
$w = 4;
$x = new x($w);
Several observations in this code:
it is possible to define a property without visibility: the property hook makes it a promoted property.
It is also possible possible to create a reference on a property, as promoted properties are also an argument.
When all these features are together, it yields an error about accessing an uninitialized property.
See Also¶
Uninitialized property [Try me]
PHP Error Messages¶
PHP Features¶
Last updated: 14 July 2026