blood72 / laravel-riot-api

Riot API wrapper for Laravel
MIT License
3 stars 1 forks source link

Proxy is not compatible with named arguments #3

Closed innocenzi closed 3 years ago

innocenzi commented 3 years ago

Hi,

There is an issue where the __call forwarding made by the proxy is not compatible with PHP 8's named arguments:

$matches = LeagueAPI::getMatchIdsByPUUID(
    puuid: $summoner->puuid,
    start: 0,
    count: 1
);

I think a fix would be as easy as to filtering null values from $parameters:

public function __call($method, $parameters)
{
    if (method_exists($this->api, $method)) {
        $this->modifyParameters($method, $parameters);
    }

-    return $this->api->$method(...$parameters);
+    return $this->api->$method(...array_filter($parameters));
}
blood72 commented 3 years ago

Thank you for reporting!

According to the current error, when using named arguments, 0,1 and 2 ordered pair data are arranged in a posterior row.

If PHP 8 is the standard, the parameter order can be excluded to some extent,
At least I still plan to support PHP 7.4, so I modified it to suit compatibility.

innocenzi commented 3 years ago

Thanks a lot for your quick fix!