@param ObjectType  $returnType
@param FieldNode[] $fieldNodes
@param array       $path
@param mixed       $result

@return array|PromiseInterface
@throws \Throwable
358464
protected function executeSubFields(ObjectType $returnType, array $fieldNodes, array $path, &$result)
    {
        $subFields            = [];
        $visitedFragmentNames = [];

        foreach ($fieldNodes as $fieldNode) {
            if (null !== $fieldNode->getSelectionSet()) {
                $subFields = $this->fieldCollector->collectFields(
                    $returnType,
                    $fieldNode->getSelectionSet(),
                    $subFields,
                    $visitedFragmentNames
                );
            }
        }

        if (!empty($subFields)) {
            return $this->executeFields($returnType, $result, $path, $subFields);
        }

        return $result;
    }
40359
public static function fromDict($rsp, $txnType, $returnType = 'HpsAttachment')
    {
        $attResponse = $rsp->Transaction->$txnType->Details;
        $transaction = parent::fromDict($rsp, $txnType, $returnType);
        foreach (get_object_vars($attResponse) as $key => $prop) {
            if (property_exists($transaction, lcfirst($key))) {
                $transaction->__set(lcfirst($key), $prop);
            }
        }
        return $transaction;
    }
645622
public static Converter<String, Object> createPathParamConverter(final Type resultType) {
    if (!(resultType instanceof Class)) {
      throw new IllegalArgumentException("Unsupported @PathParam type " + resultType);
    }
    return new Converter<String, Object>() {
      @Override
      public Object convert(String value) {
        return ConvertUtils.convert(value, (Class<?>) resultType);
      }
    };
  }
612369
private function prepareData(PropertyInterface $property, callable $dataCallback, $returnType = true)
    {
        /** @var BlockPropertyInterface $blockProperty */
        $blockProperty = $property;
        while (!($blockProperty instanceof BlockPropertyInterface)) {
            $blockProperty = $blockProperty->getProperty();
        }

        $data = [];
        for ($i = 0; $i < $blockProperty->getLength(); ++$i) {
            $blockPropertyType = $blockProperty->getProperties($i);

            if ($returnType) {
                $type = $blockPropertyType->getName();
                $data[$i] = ['type' => $type];
            }

            foreach ($blockPropertyType->getChildProperties() as $childProperty) {
                $contentType = $this->contentTypeManager->get($childProperty->getContentTypeName());
                $data[$i][$childProperty->getName()] = $dataCallback($contentType, $childProperty);
            }
        }

        if (!$property->getIsMultiple() && count($data) > 0) {
            $data = $data[0];
        }

        return $data;
    }
1353131
protected function completeAbstractValue(
        AbstractTypeInterface $returnType,
        array $fieldNodes,
        ResolveInfo $info,
        array $path,
        &$result
    ) {
        $runtimeType = $returnType->hasResolveTypeCallback()
            ? $returnType->resolveType($result, $this->context->getContextValue(), $info)
            : \call_user_func(
                $this->typeResolverCallback,
                $result,
                $this->context->getContextValue(),
                $info,
                $returnType
            );

        if ($runtimeType instanceof PromiseInterface) {
            return $runtimeType->then(function ($resolvedRuntimeType) use (
                $returnType,
                $fieldNodes,
                $info,
                $path,
                &$result
            ) {
                return $this->completeObjectValue(
                    $this->ensureValidRuntimeType($resolvedRuntimeType, $returnType, $info, $result),
                    $fieldNodes,
                    $info,
                    $path,
                    $result
                );
            });
        }

        $returnType = $this->ensureValidRuntimeType($runtimeType, $returnType, $info, $result);

        return $this->completeObjectValue(
            $returnType,
            $fieldNodes,
            $info,
            $path,
            $result
        );
    }
707994
public static function fromDict($rsp, $txnType, $returnType = 'HpsTransaction')
    {
        $transaction = new $returnType();

        // Hydrate the header
        $transaction->_header = new HpsTransactionHeader();
        $transaction->_header->gatewayResponseCode = (string)$rsp->Header->GatewayRspCode;
        $transaction->_header->gatewayResponseMessage = (string)$rsp->Header->GatewayRspMsg;
        $transaction->_header->responseDt = (string)$rsp->Header->RspDT;
        $transaction->_header->clientTxnId = (isset($rsp->Header->ClientTxnId) ? (string)$rsp->Header->ClientTxnId : null);

        $transaction->transactionId = (string)$rsp->Header->GatewayTxnId;
        if (isset($rsp->Header->ClientTxnId)) {
            $transaction->clientTransactionId = (string)$rsp->Header->ClientTxnId;
        }

        // Hydrate the body
        if (!isset($rsp->Transaction) || !isset($rsp->Transaction->{$txnType})) {
            return $transaction;
        }
        // Hydrate the body
        $item = $rsp->Transaction->{$txnType};
        if ($item != null) {
            $transaction->responseCode = (isset($item->RspCode) ? (string)$item->RspCode : null);
            $transaction->responseText = (isset($item->RspText) ? (string)$item->RspText : null);
            $transaction->referenceNumber = (isset($item->RefNbr) ? (string)$item->RefNbr : null);
        }

        return $transaction;
    }
1143713
protected function parse($locale, $returnType = null)
    {
        if (extension_loaded('intl')) {
            $info = \Locale::parseLocale($locale);
        } else {
            $info = array();

            if (!preg_match('~^(?<language>[a-z]{2,4})([_-](?<region>[a-z]{2,4}))?$~i', $locale, $info)) {
                return null;
            }

            if (isset($info['region'])) {
                $info['region'] = strtoupper($info['region']);
            }
        }

        if ($returnType !== null) {
            $value = ($info && isset($info[$returnType]))? $info[$returnType] : null;
            return $value;
        }

        return $info;
    }
1060601
public function findOneWhere($criteria, $returnType = Table::RETURN_MODEL) {
        $this->limit(1);
        $result = $this->findWhere($criteria, $returnType);
        if (is_array($result)) {
            $result = array_values($result);
            return ($returnType === Table::RETURN_JSON) ? json_encode($result[0])
                        : $result[0];
        }
        else if (is_object($result)) {
            return $result->first();
        }
    }
1332527
public static function post(
        $attributes,
        $return = \Phramework\Database\Operations\Create::RETURN_ID
    ) {
        return \Phramework\Database\Operations\Create::create(
            $attributes,
            static::getTable(),
            static::getSchema(),
            $return
        );
    }
298362
public static ResultDescriptor analyzeReturnType(final DescriptorContext context,
                                                     final Class<? extends Collection> returnCollectionType) {
        final Method method = context.method;
        final MethodGenericsContext generics = context.generics.method(method);
        final Class<?> returnClass = generics.resolveReturnClass();
        final ResultDescriptor descriptor = new ResultDescriptor();
        descriptor.expectType = resolveExpectedType(returnClass, returnCollectionType);

        final ResultType type;
        final Class<?> entityClass;
        if (isCollection(returnClass)) {
            type = COLLECTION;
            entityClass = resolveGenericType(method, generics);
        } else if (returnClass.isArray()) {
            type = ARRAY;
            entityClass = returnClass.getComponentType();
        } else if (VOID_TYPES.contains(returnClass)) {
            type = VOID;
            entityClass = Void.class;
        } else {
            type = PLAIN;
            // support for guava and jdk8 optionals
            entityClass = Optionals.isOptional(returnClass)
                    ? resolveGenericType(method, generics) : returnClass;
        }
        descriptor.returnType = type;
        descriptor.entityType = entityClass;
        return descriptor;
    }
878616
public function newQueryWithoutScopes($returnType=Builder::RETURN_TYPE_ELOQUENT)
    {
        $builder = $this->newEloquentBuilder(
            $this->newBaseQueryBuilder(),
            $returnType
        );

        // Once we have the query builders, we will set the model instances so the
        // builder can easily access any information it may need from the model
        // while it is constructing and executing various queries against it.
        return $builder->setModel($this)->with($this->with);
    }
912585
function (err, result) {
          // If we got here via a upsert() call, then options._returnObject will
          // be set and we should return the whole object. Otherwise, we should
          // just return the number of affected docs to match the mongo API.
          if (result && ! options._returnObject)
            callback(err, result.numberAffected);
          else
            callback(err, result);
        }
925090
protected function completeLeafValue($returnType, &$result)
    {
        $result = $returnType->serialize($result);

        if (null === $result) {
            throw new InvalidReturnTypeException($returnType, $result);
        }

        return $result;
    }
904933
public function getReturnType(): Type
    {
        if (! isset($this->returnType)) {
            $this->returnType = app(DefinitionNodeConverter::class)->toType(
                $this->field->type
            );
        }

        return $this->returnType;
    }
1166917
public static function fromDict($rsp, $txnType = null, $returnType = 'HpsManageTokensResponse')
    {
        $transaction = parent::fromDict($rsp, $txnType, $returnType);
        $transaction->responseCode = '00';
        $transaction->responseText = '';
        return $transaction;
    }
1312146
private function buildEventAggregate(array $events, $returnType)
    {
        if ($returnType === self::RETURN_AS_ARRAY) {
            return $this->buildEventAggregateAsArray($events);
        }

        return $this->buildEventAggregateAsObject($events);
    }
469526
protected function assertChainableReturnType(File $phpCsFile, int $stackPointer, array $parts, array $returnTypes): void
    {
        if ($returnTypes && $parts === ['$this'] && $returnTypes !== ['$this']) {
            $phpCsFile->addError('Chainable method (@return $this) cannot have multiple return types in code.', $stackPointer, 'InvalidChainable');
        }
    }