__construct(
public string $id,
optional public string $name,
optional public null|int $age,
) {}
}
new DTO('some-id');
new DTO(...['id' => 'some-id']); // no error for missing keys for
named arguments
On Thu, Jun 5, 2025 at 2:33 PM Br
ed, Jun 4, 2025 at 7:11 PM Claude Pache wrote:
>
>
> Le 3 juin 2025 à 06:22, Bradley Hayes a écrit :
>
> Uninitialized properties are really useful.
> Being skipped in foreach loops and JSON encoded results and other
> behaviours around uninitialized properties save a lot of
on get(string $name, mixed $default = uninitialized): string
{
$value = getenv($name);
if ($value === false) {
if (isInitialized($default)) return $default;throw new
\Exception("Environment variable '$name' not found.");
}
return $value;
}
On Tue, Jun
the properties can be seen from the same scope forcing
every extender of the class to copy paste the constructor code from the
parent class.
--
Bradley Hayes / Engineer / TITHE.LY <http://tithe.ly/>
<http://tithe.ly>