<?php declare(strict_types=1); final class A { public function __construct( public string $a = 'default', ) { } } $property = new ReflectionProperty(A::class, 'a'); var_dump($property->hasDefaultValue()); $parameter = new ReflectionParameter([A::class, '__construct'], 'a'); var_dump($parameter->isDefaultValueAvailable()); $class = new ReflectionClass(A::class); $a = $class->newInstanceWithoutConstructor(); var_dump($a->a);
You have javascript disabled. You will not be able to edit any code.