File tree Expand file tree Collapse file tree
modules/openapi-generator/src/main/resources/php Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -622,10 +622,16 @@ class ObjectSerializer
622622 }
623623
624624 /**
625+ * Flattens an array of Model object and generates an array compatible
626+ * with formdata - a single-level array where the keys use bracket
627+ * notation to signify nested data.
628+ *
629+ * @param \ArrayAccess|array $source
630+ *
625631 * credit: https://github.com/FranBar1966/FlatPHP
626632 */
627633 private static function flatten_array(
628- array $source,
634+ mixed $source,
629635 array & $destination,
630636 string $start = '',
631637 ) {
@@ -638,11 +644,28 @@ class ObjectSerializer
638644 ' suffix-list-end' => true ,
639645 ];
640646
641- // array_is_list only in PHP >= 8.1
647+ if (! is_array($source )) {
648+ $source = (array) $source ;
649+ }
650+
651+ /**
652+ * array_is_list only in PHP >= 8.1
653+ *
654+ * credit: https://www.php.net/manual/en/function.array-is-list.php#127044
655+ */
642656 if (!function_exists('array_is_list')) {
643- function array_is_list(array $arr )
657+ function array_is_list(array $array )
644658 {
645- return $arr === [] || (array_keys($arr ) === range(0, count($arr ) - 1));
659+ $i = -1;
660+
661+ foreach ($array as $k => $v ) {
662+ ++$i ;
663+ if ($k !== $i ) {
664+ return false ;
665+ }
666+ }
667+
668+ return true;
646669 }
647670 }
648671
You can’t perform that action at this time.
0 commit comments