Cannot specify default value for virtual hooked property¶
Description¶
It is possible to create a virtual property, by defining one accessor that doesn’t refer to the defined property. In the illustration here, the get
method is empty. In that case, the property’s value doesn’t have an impact on the operation, and the default value of that property shall not be defined.
Example¶
<?php
class X {
public int $property = 3 {
get {}
}
}
?>
Solutions¶
Remove the property hooks, to regain usage of the default value.
Define a property hook that makes use of the property
$this->property
.