On Thu, 26 Mar 2020 at 12:39, Enno Woortmann <[email protected]> wrote:
>
> $handle = fopen('test.csv', 'r');
> while (($data = fgetcsv($handle)) !== false) {
> [int $id, string $data, int $year] = $data;
> // do something with the correctly typed variables
> }
>
> The code would trigger a fatal error when strict_types are enabled. With
> strict_types disabled it would behave identically as the currently
> proposed casts.
>
As I mentioned in a previous e-mail, if it followed current strict_types=0
semantics, it would error if the input row was something like
"42,hello,not-a-valid-year".
Following standard cast semantics, that input would instead silently give
you a value of 0 in $year, which is often not what you want.
Regards,
--
Rowan Tommins
[IMSoP]