@@ -321,15 +321,28 @@ class ObjectSerializer
321321 *
322322 * @param string|\S plFileObject $value the value of the form parameter
323323 *
324- * @return string the form string
324+ * @return array
325325 */
326- public static function toFormValue($value)
326+ public static function toFormValue(string $key, mixed $value)
327327 {
328- if ($value instanceof \S plFileObject) {
329- return $value->getRealPath();
330- } else {
331- return self::toString($value);
328+ $stringable = self::toString($value);
329+
330+ if ($stringable !== null) {
331+ return [$key => $stringable];
332+ } elseif ($value instanceof \S plFileObject) {
333+ return [$key => $value->getRealPath()];
334+ }
335+
336+ $flattened = [];
337+ $result = [];
338+
339+ self::flatten_array(json_decode(json_encode($value), true), $flattened);
340+
341+ foreach ($flattened as $k => $v) {
342+ $result["{$key}{$k}"] = self::toString($v);
332343 }
344+
345+ return $result;
333346 }
334347
335348 /**
@@ -340,12 +353,14 @@ class ObjectSerializer
340353 *
341354 * @param float|int|bool|\DateTime $value the value of the parameter
342355 *
343- * @return string the header string
356+ * @return string|null the header string
344357 */
345358 public static function toString($value )
346359 {
347360 if ($value instanceof \DateTime) { // datetime in ISO8601 format
348361 return $value -> format (self::$dateTimeFormat );
362+ } elseif (!is_scalar($value) && $value !== null) {
363+ return null;
349364 } elseif (is_bool($value)) {
350365 return $value ? ' true' : ' false' ;
351366 } else {
0 commit comments