Re: [PHP-DEV] Allowing class properties to remain Uninitialized as a default value.

2025-06-04 Thread Bradley Hayes
__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

Re: [PHP-DEV] Allowing class properties to remain Uninitialized as a default value.

2025-06-04 Thread Bradley Hayes
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

Re: [PHP-DEV] Allowing class properties to remain Uninitialized as a default value.

2025-06-03 Thread Bradley Hayes
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

[PHP-DEV] Allowing class properties to remain Uninitialized as a default value.

2025-06-02 Thread Bradley Hayes
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>