mallgroup / mpapi-client-php

MPAPI client is a PHP tool created to help Internet Mall, a. s. partners easily manage article catalog, deliveries, orders, etc. using Mall Marketplace API.
Apache License 2.0
6 stars 19 forks source link

variableParameters are set to string #37

Open nime11 opened 1 year ago

nime11 commented 1 year ago

Hi, on ProductRequest.php you have one bug on function setVariableParameters it set that you need to send string to a function, but if you want to send multiple parameter you need to send array. WRONG: public function setVariableParameters(string ...$variableParameters): void { $this->variableParameters = $variableParameters; } RIGHT: public function setVariableParameters(array...$variableParameters): void { $this->variableParameters = $variableParameters; }

MichalSalon commented 1 year ago

The code is written correctly, as the input is variadic (notice the ... before $variableParameters).

If you know the parameters and they don't change, you can hard code them

$product->setVariableParameters('one', 'two', 'three');

Most often you get an array from entity or somewhere, in that case, this is the way to use the function

$myParameters = ['one', 'two', 'three'];
$product->setVariableParameters(...$myParameters);