> On 6 January 2022 07:29:58 GMT, James Titcumb <ja...@asgrim.com> wrote:
> >Just thinking out loud, being able to identify an array type might be a
> way
> >forward here (using "syntax" already in use by static analysis tools in
> >docblocks, for familiarity), e.g.
> >
> >private array<string, mixed> $property;
> >
> >This might "turn off" the automatic type juggling behaviour, for example.
> >If the existing strict_types=1 mode is on, this might fail:
> >
> >$this->property[3] = "hi";
> >
> >If strict_types=0 or not declared, the key would be cast to a string.
>
>
> Yes, something similar occurred to me earlier, and I honestly think that
> some new types like this are the only way this can practically be solved.
>
>
So a solution, which doesn't require generics, would be to introduce
something new like a `dict` as a way to create an `array<string, mixed>`.
`{}` could be used instead of `[]`.

$dict = {'1' => '1', 'key' => 'value'};
\is_array($dict); // true

Reply via email to