Converts stdClass or stdClass[] to array recursively

@param \stdClass|array $result
@param string $soapFunction
@return mixed
484002
public function hydrateResult($result, $soapFunction)
    {
        $result = $this->hydrator->hydrateResult($result, $soapFunction);
        if (is_array($result)) {
            $hydrated = array();
            foreach ($result as $key => $value) {
                $hydrated[$key] = $this->hydrateResult($value, $soapFunction);
            }

            return $hydrated;
        }

        if ($result instanceof \stdClass) {
            return $this->stcClassToArray->toArray($result);
        }

        return $result;
    }
9280
private static function _toArray($data, $recursion = false)
    {
        $tmp  = array();
        $data = (array) $data;
        foreach ($data as $k => $v) {
            $v = (array) $v;
            if (isset($v[0]) && is_string($v[0])) {
                $tmp[$k] = $v[0];
            } else {
                $tmp[$k] = self::_toArray($v, true);
            }
        }
        return $tmp;
    }
117913
function registerFunction( $name, $params=null, $result='mixed', $description='' )
    {
        if ( is_string( $params ) )
        {
            if ( $return = parent::registerFunction( $name, null, 'mixed', $description ) )
            {
                $version = ( $result == 2 ) ? 2 : 1;
                $this->wsdl[$name][$version] = $params;
            }
        }
        else
        {
            $return = parent::registerFunction( $name, $params, $result, $description );
        }
        return $return;
    }
984836
public static function object_to_array($d) {
		if ( is_object( $d ) ) {
			// Gets the properties of the given object with get_object_vars function
			$d = get_object_vars( $d );
		}

		if ( is_array( $d ) ) {
			/*
			 * Return array converted to object
			 * Using __FUNCTION__ (Magic constant)
			 * for recursive call
			 */
			return array_map( array( __CLASS__, __FUNCTION__ ), $d);
		}
		else {
			// Return array
			return $d;
		}
	}
368064
protected function processResult(array $results)
    {
        foreach ($results as $key => $entity) {

            if (!empty($entity['data'])) {

                $entity['data'] = $this->decorator->denormalizeValue($entity['data']);
                $results[$key] = $entity;
            }
        }

        return $results;
    }
1035510
protected function _makeMultiGetResult(array $result) {
        return MultiGetResult::make($result, $this->getClient())->setModelClass($this->_fullModelClassNamePattern());
    }
1212003
public static function fromHttpResponse(HttpResponse $httpResponse)
    {
        $result = json_decode($httpResponse->getResult());
        $primaryData = self::parsePrimaryData($result);
        $resultSet = new ResultSet();
        foreach ($primaryData as $primaryDataItem) {
            if ($primaryDataItem instanceof \stdClass) {
                $primaryDataItem = ArrayHelper::stdClassToArray($primaryDataItem);
            }
            $item = new ResultItem($primaryDataItem);
            $resultSet->append($item);
        }
        return $resultSet;
    }
786494
protected function from_db_records(array $results) {
        $entityfactory = $this->get_entity_factory();
        $records = array_map(function($result) {
            return $result['record'];
        }, $results);

        return $entityfactory->get_post_read_receipt_collection_from_stdclasses($records);
    }
588070
protected function from_db_records(array $results) : array {
        $entityfactory = $this->get_entity_factory();

        return array_map(function(array $result) use ($entityfactory) {
            [
                'forum' => $forumrecord,
                'course_module' => $coursemodule,
                'course' => $course,
                'context' => $context,
            ] = $result;
            return $entityfactory->get_forum_from_stdclass($forumrecord, $context, $coursemodule, $course);
        }, $results);
    }
518390
public function processColumnListing($results)
	{
		$mapping = function ($r) {
			$r = (object) $r;

			return $r->name;
		};

		return array_map($mapping, $results);
	}
1083439
public function delete(&$result)
    {
        $entity = $this->accessor->getPropertyValue($result, $this->definition->container());
        if (empty($entity)) {
            return $result;
        }

        $mediator = [];

        foreach ($this->definition->localKeys() as $entityField => $mediatorField) {
            $mediator[$mediatorField] = $this->accessor->getPropertyValue($result, $entityField);
        }

        foreach ($this->definition->foreignKeys() as $mediatorField => $entityField) {
            $mediator[$mediatorField] = $this->accessor->getPropertyValue($entity, $entityField);
        }

        $this->storage->delete($mediator, $this->definition->mediator())->execute();
        $this->accessor->setPropertyValue($result, $this->definition->container(), $entity);

        return $result;
    }
253061
protected function processI(array $result) {
		$entity = df_ic($this->entityC(), O::class, $result); /** @var O $entity */
		$entity->validate();
		return $result;
	}
37852
protected function parseResult($result) {
 
        if (! property_exists($result, 'return')) {
            return [];
        }

        $result = $result->return;
        
        if (is_null($result)) {
            return [];
        }
        
        if (!is_array($result)) {
            $result = [$result];
        }

        return $this->filterResult($result);
    }
599984
protected static function parseSequence(&$data, &$result)
    {
        // Sequence
        $data = self::parseCommon($data, $sequenceData);
        $values = self::parseASN((string) $sequenceData);
        if (! is_array($values) || is_string($values[0])) {
            $values = [$values];
        }
        $result[] = [
            'sequence (' . self::$len . ')',
            $values, ];
    }
17575
public static function listToEntity(array $result, string $className): array
    {
        $entities = [];
        foreach ($result as $data) {
            if (!\is_array($data)) {
                continue;
            }
            $entities[] = self::arrayToEntity($data, $className);
        }

        return $entities;
    }
171687
private function processResult(array $result)
    {
        $this->checkResponseStatus($result['http_code']);

        // Get decoded response data
        $responseArr = json_decode($result['response'], true);

        $this->checkJsonError();

        return $responseArr;
    }
1150989
public function getResultsAsArray()
    {
        $new = array();
        foreach ((array) $this->results as $result) {
            if ($result instanceof Object)
                $new[] = $result->toArray();
            else if (is_array($result))
                return $this->results;
            else
                throw new Exception('Cannot convert to array: '.ClassUtils::getQualifiedType($result));
        }
        return $new;
    }