<?php
class DTO
{
public function __construct(
public array $prop = []
) {}
}
$default = (new ReflectionProperty(DTO::class, 'prop'))->getDefaultValue();
var_dump($default); // Здесь NULL
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
NULL
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting variable (T_VARIABLE) in /in/r9iv4 on line 6
Process exited with code 255.