Feature request from augsteyer, posted on GitHub Feb 03, 2016
I believe this is a bug where I am trying to pass a JSON object like this
{
"action":"get_setting",
"settings":
[
{
"name": "t",
"value": "p"
}
]
}
Where the interface looks like this
/**
* @param string $action
* @param array[][] $settings - the type here is the problem area
*
* @return string
*/
public function setSettings($action, $settings);
I have currently tried many variations of string[][], array[], string[], mixed[], Array[], etc, without any way of passing settings without getting an error thrown at the lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php:rocess() function.
The root cause of the problem is that in lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php::convertValue() it has no way of parsing array of arrays. If it's something like "string[][]" it will consider it a simple type and will try to match it to !settype(array(...), string), which results into an error. If it's something unknown like array[][]. It will consider it complex, and try to initialize it as a class, where it will figure out that 'array' is not a class.
A way of solving, would be to make array a simple type, however I do not know the implications of such change, hence why it's not a pull request. The change would also allow this case to be accepted whether it's array[][] or array[] or array, so most likely not a good solution.
lib/internal/Magento/Framework/Reflection/TypeProcessor.php::isTypeSimple()
...
return in_array(
$type,
[
self::NORMALIZED_STRING_TYPE,
self::NORMALIZED_INT_TYPE,
self::NORMALIZED_FLOAT_TYPE,
self::NORMALIZED_DOUBLE_TYPE,
self::NORMALIZED_BOOLEAN_TYPE,
self::NORMALIZED_ARRAY_TYPE //'array' <------
]
);