Open ging-dev opened 2 months ago
We have noticed that many existing frameworks misuse this syntax/semantic :/
So they usually specify both ...
and array
types (because the variable will be an array after all). Not sure what's correct.
So in case the type is array
or []
, we assume, it should not be wrapped to another array again.
We have noticed that many existing frameworks misuse this syntax/semantic :/
So they usually specify both
...
andarray
types (because the variable will be an array after all). Not sure what's correct.So in case the type is
array
or[]
, we assume, it should not be wrapped to another array again.We have noticed that many existing frameworks misuse this syntax/semantic :/
So they usually specify both
...
andarray
types (because the variable will be an array after all). Not sure what's correct.So in case the type is
array
or[]
, we assume, it should not be wrapped to another array again.
Agreed, however, I think we should require users to use the correct syntax in order to synchronize with static analysis tools, some recent frameworks have started using static analysis tools:
I think in the example below, string[]
is a more accurate input than string
:
<?php
require __DIR__.'/vendor/autoload.php';
/** @var \Illuminate\Support\Collection<int, string[]> */
$c = collect();
$c->push(['hello']); // Argument '1' passed to push() is expected to be of type string, string[] given
<?php
require __DIR__.'/vendor/autoload.php';
/** @var \Illuminate\Support\Collection<int, array{name: string}> */
$c = collect();
$c->push(['name' => 'ging']); // Argument '1' passed to push() is expected to be of type string, string[] given
I see, thanks!
Actual: Expect: