DigitalOceanPHP / Client

DigitalOcean API v2 client for PHP
MIT License
709 stars 205 forks source link

Unknown named parameter $type when using pagination with array #279

Closed kcalliauw closed 3 years ago

kcalliauw commented 3 years ago

Hello!

Below error when calling this:

$imageTypeFilter = ['type' => 'distribution'];
$images = $pager->fetchAll($client->image(), 'getAll', $imageTypeFilter);

image

Not exactly sure why this happens, but changing ...$parameters to just $parameters on ResultPager.php line 87 fixes the issue in this specific case. Not sure if this breaks other things.

GrahamCampbell commented 3 years ago

This is because your array needs to be of the format ['distribution'] and not ['type' => 'distribution']. PHP 8 has started to be fussy about this.

kcalliauw commented 3 years ago

This yields another error. Also I don't understand how this would be the solution. The getAll function for the Image API can take both "type" as a parameter and "private". Passing that array ['distribution'] just yields a string inside that function, while it's expecting an associative array, as far as I can see in the code.

image

GrahamCampbell commented 3 years ago

Oh, you need [['type' => 'distribution']], then.

kcalliauw commented 3 years ago

Worked like a charm! Thank you :+1: