From 40a50d170848b9babca130fb935fe807af0166af Mon Sep 17 00:00:00 2001 From: zkwbbr <45949485+zkwbbr@users.noreply.github.com> Date: Sat, 3 Feb 2024 18:54:58 +0800 Subject: [PATCH] Make sure only arrays are passed in foreach() Fix errors like this: foreach() argument must be of type array|object, string given on /vendor/aura/web/src/Request/Files.php (79) --- src/Request/Files.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Request/Files.php b/src/Request/Files.php index c5a205b..203541c 100644 --- a/src/Request/Files.php +++ b/src/Request/Files.php @@ -69,9 +69,11 @@ protected function init($src, &$tgt) } } else { // not a target, create sub-elements and init them too - foreach ($src as $key => $val) { - $tgt[$key] = array(); - $this->init($val, $tgt[$key]); + if (is_array($src)) { + foreach ($src as $key => $val) { + $tgt[$key] = array(); + $this->init($val, $tgt[$key]); + } } } }