APIMatic CodeGen has made improvements by updating type hints of dictionaries in PHP SDKs to better capture the type information.
Previously, PHP SDKs were using the type
array for a dictionary of any type. For example, following is a model named
TeamMembersRequest with a field
teamMembers of type
Dictionary<string,TeamMember>. In PHP, this model would look like:
* @var array
array not only loses the dictionary's inner type information but also affects the users Developer Experience. Likewise in PHP, type
array means a dictionary of mixed types, which leads to type hint
array in PhpStrom IDE, as shown:
What has Changed?
To improve the code readability, correctness and to preserve the inner type of a dictionary in PHP, APIMatic now uses the
Phan analyzer's approach of dealing with maps. Therefore, the above-mentioned snippet of a model class
TeamMembersRequest would now look like:
* @var array<string,TeamMember>
This code leads to
TeamMember type hint in PhpStorm IDE which is equivalent to a PHP map of
TeamMember. These type hints are later used by
JsonMapper to deserialize a JSON string into the model and the suppport for map of type A i.e.
array<string,A> with the release of JsonMapper.