返回方法的奇怪问题


strange issue with return of method

我似乎可以让该方法返回一个数组。我可以在 myRecursiveFunction 中返回之前获得var_dump

if($return){
            var_dump($myArray);
            return $myArray;
        }

但是在调用函数中,我的var_dump是空的。不知道我做错了什么

private function myCallingFunction(){
            $x = $this->myRecursiveFunction();
var_dump($x);
    }
private function myRecursiveFunction($next = null, $recursion = false, $myArray = array())
{
    $return = false;
    if (!$recursion) {
        $result = json_decode($this->getMyResults);
        $myArray = $result->myResults;
        if ($result->getMore) {
            $this->myRecursiveFunction($result->getMore, true, $myArray);
            $return = false;
        }else{
            $return = true;
        }
    } else {
        $result = json_decode($this->getMyResults);
        $myArray = array_merge($myArray,$result->myResults);
        if ($result->getMore) {
            $this->myRecursiveFunction($result->getMore, true, $myArray);
            $return = false;
        }else{
            $return = true;
        }
    }
    if($return){
        var_dump($myArray);
        return $myArray;
    }
}

只需要这样做

return $this->myRecursiveFunction($result->getMore, true, $myArray);