@param ObjectType  $returnType
@param array       $fieldNodes
@param ResolveInfo $info
@param array       $path
@param mixed       $result

@return array|PromiseInterface
@throws ExecutionException
@throws InvalidReturnTypeException
@throws \Throwable
323437
protected function completeObjectValue(
        ObjectType $returnType,
        array $fieldNodes,
        ResolveInfo $info,
        array $path,
        &$result
    ) {
        // If there is an isTypeOfCallback predicate function, call it with the
        // current result. If isTypeOfCallback returns false, then raise an error rather
        // than continuing execution.
        if ($returnType->hasIsTypeOfCallback()) {
            $isTypeOf = $returnType->isTypeOf($result, $this->context->getContextValue(), $info);

            if ($isTypeOf instanceof PromiseInterface) {
                return $isTypeOf->then(function ($resolvedIsTypeOf) use ($returnType, $result, $fieldNodes, $path) {
                    if (true === $resolvedIsTypeOf) {
                        return $this->executeSubFields($returnType, $fieldNodes, $path, $result);
                    }

                    throw new InvalidReturnTypeException($returnType, $result, $fieldNodes);
                });
            }

            if (false === $isTypeOf) {
                throw new InvalidReturnTypeException($returnType, $result, $fieldNodes);
            }
        }

        return $this->executeSubFields($returnType, $fieldNodes, $path, $result);
    }
651214
public static function fromObject($data, $returnType = 'HpsCardinalMPIAuthenticateResponse')
    {
        $response = parent::fromObject($data, $returnType);
        $response->authenticateMethod = self::readDataKey($data, 'AuthenticateMethod');
        $response->authorizationCode = self::readDataKey($data, 'AuthorizationCode');
        $response->cardBin = self::readDataKey($data, 'CardBin');
        $response->cardEnrollmentMethod = self::readDataKey($data, 'CardEnrollmentMethod');
        $response->cardExpMonth = self::readDataKey($data, 'CardExpMonth');
        $response->cardExpYear = self::readDataKey($data, 'CardExpYear');
        $response->cardLastFour = self::readDataKey($data, 'CardLastFour');
        $response->cardType = self::readDataKey($data, 'CardType');
        $response->cardTypeName = self::readDataKey($data, 'CardTypeName');
        $response->longAccessToken = self::readDataKey($data, 'LongAccessToken');
        $response->mastercardAssignedId = self::readDataKey($data, 'MasterCardAssignedId');
        $response->nameOnCard = self::readDataKey($data, 'NameOnCard');
        $response->paResStatus = self::readDataKey($data, 'PaResStatus');
        $response->payPassWalletIndicator = self::readDataKey($data, 'PayPassWalletIndicator');
        $response->paymentProcessorOrderNumber = self::readDataKey($data, 'PaymentProcessorOrderNumber');
        $response->processorBillingAddress1 = self::readDataKey($data, 'ProcessorBillingAddress1');
        $response->processorBillingAddress2 = self::readDataKey($data, 'ProcessorBillingAddress2');
        $response->processorBillingCity = self::readDataKey($data, 'ProcessorBillingCity');
        $response->processorBillingCountryCode = self::readDataKey($data, 'ProcessorBillingCountryCode');
        $response->processorBillingFirstName = self::readDataKey($data, 'ProcessorBillingFirstName');
        $response->processorBillingLastName = self::readDataKey($data, 'ProcessorBillingLastName');
        $response->processorBillingMiddleName = self::readDataKey($data, 'ProcessorBillingMiddleName');
        $response->processorBillingPhone = self::readDataKey($data, 'ProcessorBillingPhone');
        $response->processorBillingPostalCode = self::readDataKey($data, 'ProcessorBillingPostalCode');
        $response->processorBillingState = self::readDataKey($data, 'ProcessorBillingState');
        $response->processorCavv = self::readDataKey($data, 'ProcessorCavv');
        $response->processorEciFlag = self::readDataKey($data, 'ProcessorEciFlag');
        $response->processorEmail = self::readDataKey($data, 'ProcessorEmail');
        $response->processorPayresStatus = self::readDataKey($data, 'ProcessorPayresStatus');
        $response->processorShippingAddress1 = self::readDataKey($data, 'ProcessorShippingAddress1');
        $response->processorShippingAddress2 = self::readDataKey($data, 'ProcessorShippingAddress2');
        $response->processorShippingCity = self::readDataKey($data, 'ProcessorShippingCity');
        $response->processorShippingCountryCode = self::readDataKey($data, 'ProcessorShippingCountryCode');
        $response->processorShippingFullName = self::readDataKey($data, 'ProcessorShippingFullName');
        $response->processorShippingPhone = self::readDataKey($data, 'ProcessorShippingPhone');
        $response->processorShippingPostalCode = self::readDataKey($data, 'ProcessorShippingPostalCode');
        $response->processorShippingState = self::readDataKey($data, 'ProcessorShippingState');
        $response->processorSignatureVerification = self::readDataKey($data, 'ProcessorSignatureVerification');
        $response->processorXid = self::readDataKey($data, 'ProcessorXid');
        $response->rewardExpMonth = self::readDataKey($data, 'RewardExpMonth');
        $response->rewardExpYear = self::readDataKey($data, 'RewardExpYear');
        $response->rewardId = self::readDataKey($data, 'RewardId');
        $response->rewardName = self::readDataKey($data, 'RewardName');
        $response->rewardNumber = self::readDataKey($data, 'RewardNumber');
        $response->scEnrollmentStatus = self::readDataKey($data, 'ScEnrollmentStatus');
        $response->signatureVerification = self::readDataKey($data, 'SignatureVerification');
        return $response;
    }
855960
FunctionTypeBuilder inferReturnType(
      @Nullable JSDocInfo info, boolean fromInlineDoc) {
    if (info != null) {
      JSTypeExpression returnTypeExpr =
          fromInlineDoc ? info.getType() : info.getReturnType();
      if (returnTypeExpr != null) {
        returnType = returnTypeExpr.evaluate(templateScope, typeRegistry);
        returnTypeInferred = false;
      }
    }

    return this;
  }
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
        );
    }
1093496
public function search(SearchQuery $searchQuery, $returnType = BaseSearch::SEARCH_RESULT)
    {
        $response = static::newResponse($returnType);

        /** @var yii\db\ActiveRecord|SearchableEntity $mainEntityClassName */
        $mainEntityClassName = $searchQuery->mainEntityClassName;

        $activeQuery = $mainEntityClassName::find();

        $success = false;

        // combine query
        $e = new SearchEvent(
            $searchQuery,
            $returnType,
            $response,
            [
                'params' => [
                    'activeQuery' => &$activeQuery,
                ],
            ]
        );
        $this->trigger(self::EVENT_BEFORE_PAGINATION, $e);

        // Pagination
        $pages = $searchQuery->getPagination();
        if ($returnType !== BaseSearch::SEARCH_COUNT && $pages !== null) {
            if ($pages->totalCount === 0) {
                $pages->totalCount = (int) $activeQuery->count();
            }
            $searchQuery->limit = $pages->limit;
            $searchQuery->offset = $pages->offset;
        }

        $e = new SearchEvent(
            $searchQuery,
            $returnType,
            $response,
            [
                'params' => [
                    'activeQuery' => &$activeQuery,
                    'pages' => $pages,
                ],
            ]
        );
        $this->trigger(self::EVENT_AFTER_PAGINATION, $e);

        $response->searchQuery = $searchQuery;

        switch ($returnType) {
            case BaseSearch::SEARCH_COUNT:
                /** @var CountResponse $response */
                $response->count = (int) $activeQuery->count();
                $success = true;
                break;
            case BaseSearch::SEARCH_QUERY:
                /** @var QueryResponse $response */
                $response->query = $activeQuery;
                $success = true;
                break;
            case BaseSearch::SEARCH_RESULT_ARRAY:
            case BaseSearch::SEARCH_RESULT:
                /** @var ResultResponse $response */
                // query for debug
                $response->query = $activeQuery;
                if (is_object($pages)) {
                    $response->pages = $pages;
                }
                if ($returnType === BaseSearch::SEARCH_RESULT_ARRAY) {
                    $activeQuery->asArray(true);
                }
                $response->entities = $activeQuery->all();
                $e = new SearchEvent(
                    $searchQuery,
                    $returnType,
                    $response,
                    [
                        'params' => [
                            'activeQuery' => &$activeQuery,
                        ],
                    ]
                );
                $this->trigger(self::EVENT_AFTER_FIND, $e);
                $success = true;
                break;
            case BaseSearch::SEARCH_IDS:
                /** @var IdsResponse $response */
                $activeQuery->select(
                    array_map(
                        function ($item) use ($mainEntityClassName) {
                            return $mainEntityClassName::tableName() . '.' . $item;
                        },
                        $mainEntityClassName::primaryKey()
                    )
                );
                $response->ids = $activeQuery
                    ->distinct(true)
                    ->asArray(true)
                    ->column();
                $response->query = $activeQuery;
                $success = true;
                break;
        }

        return $response->end($success);
    }
925090
protected function completeLeafValue($returnType, &$result)
    {
        $result = $returnType->serialize($result);

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

        return $result;
    }
1075412
public function findOne($idValue, $returnType = Table::RETURN_MODEL) {
        if (is_object($idValue)) {
            $getPK = 'get' . ucfirst(U::_toCamel($this->getPrimaryKey()));
            $idValue = $idValue->$getPK();
        }

        return $this->findOneBy($this->getPrimaryKey(), $idValue, $returnType);
    }
455492
public function newQuery($returnType=Builder::RETURN_TYPE_ELOQUENT)
    {
        $builder = $this->newQueryWithoutScopes($returnType);

        // laravel 5.1
        if (method_exists($this, 'applyGlobalScopes')) {
            return $this->applyGlobalScopes($builder);
        }

        // laravel 5.2
        foreach ($this->getGlobalScopes() as $identifier => $scope) {
            $builder->withGlobalScope($identifier, $scope);
        }

        return $builder;
    }
456224
public static function fromDict($rsp, $txnType, $returnType = 'HpsAltPaymentSale')
    {
        $charge = $rsp->Transaction->$txnType;

        $sale = parent::fromDict($rsp, $txnType, $returnType);

        $sale->status = isset($charge->Status) ? (string)$charge->Status : null;
        $sale->statusMessage = isset($charge->StatusMessage) ? (string)$charge->StatusMessage : null;

        return $sale;
    }
177834
protected static function executeFieldsSerially(ExecutionContext $context, ObjectType $parent, $source, $fields)
    {
        $results = [];
        foreach ($fields as $response => $asts) {
            $result = self::resolveField($context, $parent, $source, $asts);

            if ($result !== self::$UNDEFINED) {
                // Undefined means that field is not defined in schema.
                $results[$response] = $result;
            }
        }

        return $results;
    }
1063604
public static function generateRetrieveEntityRequest( $entityType, $entityId = null, $entityFilters = null, $showUnpublished = false ) {
        /* We can use either the entityType (Logical Name), or the entityId, but not both. */
        /* Use ID by preference, if not set, default to 0s */
        if ( $entityId != null ) {
            $entityType = null;
        } else {
            $entityId = Client::EmptyGUID;
        }

        /* If no entityFilters are supplied, assume "All" */
        if ( $entityFilters == null ) {
            $entityFilters = 'Entity Attributes Privileges Relationships';
        }

        /* Generate the RetrieveEntityRequest message */
        $retrieveEntityRequestDOM = new DOMDocument();
        $executeNode              = $retrieveEntityRequestDOM->appendChild( $retrieveEntityRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'Execute' ) );
        $requestNode              = $executeNode->appendChild( $retrieveEntityRequestDOM->createElement( 'request' ) );
        $requestNode->setAttributeNS( 'http://www.w3.org/2001/XMLSchema-instance', 'i:type', 'b:RetrieveEntityRequest' );
        $requestNode->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:b', 'http://schemas.microsoft.com/xrm/2011/Contracts' );
        $parametersNode = $requestNode->appendChild( $retrieveEntityRequestDOM->createElement( 'b:Parameters' ) );
        $parametersNode->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:c', 'http://schemas.datacontract.org/2004/07/System.Collections.Generic' );
        /* EntityFilters */
        $keyValuePairNode1 = $parametersNode->appendChild( $retrieveEntityRequestDOM->createElement( 'b:KeyValuePairOfstringanyType' ) );
        $keyValuePairNode1->appendChild( $retrieveEntityRequestDOM->createElement( 'c:key', 'EntityFilters' ) );
        $valueNode1 = $keyValuePairNode1->appendChild( $retrieveEntityRequestDOM->createElement( 'c:value', $entityFilters ) );
        $valueNode1->setAttribute( 'i:type', 'd:EntityFilters' );
        $valueNode1->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:d', 'http://schemas.microsoft.com/xrm/2011/Metadata' );
        /* MetadataId */
        $keyValuePairNode2 = $parametersNode->appendChild( $retrieveEntityRequestDOM->createElement( 'b:KeyValuePairOfstringanyType' ) );
        $keyValuePairNode2->appendChild( $retrieveEntityRequestDOM->createElement( 'c:key', 'MetadataId' ) );
        $valueNode2 = $keyValuePairNode2->appendChild( $retrieveEntityRequestDOM->createElement( 'c:value', $entityId ) );
        $valueNode2->setAttribute( 'i:type', 'd:guid' );
        $valueNode2->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:d', 'http://schemas.microsoft.com/2003/10/Serialization/' );
        /* RetrieveAsIfPublished */
        $keyValuePairNode3 = $parametersNode->appendChild( $retrieveEntityRequestDOM->createElement( 'b:KeyValuePairOfstringanyType' ) );
        $keyValuePairNode3->appendChild( $retrieveEntityRequestDOM->createElement( 'c:key', 'RetrieveAsIfPublished' ) );
        $valueNode3 = $keyValuePairNode3->appendChild( $retrieveEntityRequestDOM->createElement( 'c:value', ( $showUnpublished ? 'true' : 'false' ) ) );
        $valueNode3->setAttribute( 'i:type', 'd:boolean' );
        $valueNode3->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:d', 'http://www.w3.org/2001/XMLSchema' );
        /* LogicalName */
        $keyValuePairNode4 = $parametersNode->appendChild( $retrieveEntityRequestDOM->createElement( 'b:KeyValuePairOfstringanyType' ) );
        $keyValuePairNode4->appendChild( $retrieveEntityRequestDOM->createElement( 'c:key', 'LogicalName' ) );
        $valueNode4 = $keyValuePairNode4->appendChild( $retrieveEntityRequestDOM->createElement( 'c:value', $entityType ) );
        $valueNode4->setAttribute( 'i:type', 'd:string' );
        $valueNode4->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:d', 'http://www.w3.org/2001/XMLSchema' );
        /* Request ID and Name */
        $requestNode->appendChild( $retrieveEntityRequestDOM->createElement( 'b:RequestId' ) )->setAttribute( 'i:nil', 'true' );
        $requestNode->appendChild( $retrieveEntityRequestDOM->createElement( 'b:RequestName', 'RetrieveEntity' ) );

        /* Return the DOMNode */

        return $executeNode;
    }
1249220
protected function resolveFieldValueOrError(
        Field $field,
        FieldNode $fieldNode,
        ?callable $resolveCallback,
        $rootValue,
        ExecutionContext $context,
        ResolveInfo $info
    ) {
        try {
            // Build an associative array of arguments from the field.arguments AST, using the
            // variables scope to fulfill any variable references.
            $result = $resolveCallback(
                $rootValue,
                $this->valuesResolver->coerceArgumentValues($field, $fieldNode, $context->getVariableValues()),
                $context->getContextValue(),
                $info
            );

            if ($result instanceof PromiseInterface) {
                return $result->then(null, function ($exception) use ($fieldNode, $info) {
                    return !$exception instanceof ExecutionException
                        ? $this->normalizeException($exception, [$fieldNode], $info->getPath())
                        : $exception;
                });
            }

            return $result;
        } catch (\Throwable $exception) {
            return $exception;
        }
    }
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;
    }
864508
final protected function getTypeFromReturnTypeHint(ReflectionMethod $method, string $fieldName): ?Type
    {
        $returnType = $method->getReturnType();
        if (!$returnType) {
            return null;
        }

        $returnTypeName = (string) $returnType;
        if (is_a($returnTypeName, Collection::class, true) || $returnTypeName === 'array') {
            $targetEntity = $this->getTargetEntity($fieldName);
            if (!$targetEntity) {
                throw new Exception('The method ' . $this->getMethodFullName($method) . ' is type hinted with a return type of `' . $returnTypeName . '`, but the entity contained in that collection could not be automatically detected. Either fix the type hint, fix the doctrine mapping, or specify the type with `@API\Field` annotation.');
            }

            $type = Type::listOf($this->getTypeFromRegistry($targetEntity, false));
            if (!$returnType->allowsNull()) {
                $type = Type::nonNull($type);
            }

            return $type;
        }

        return $this->reflectionTypeToType($returnType);
    }
713505
function publishObject( &$result, &$errors, &$notices,
                            $object, $publishVersion, $class, $parentNodes, $parentMainNode )
    {
        $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $object->attribute( 'id' ),
                                                                                     'version' => $publishVersion ) );

        $objectID = $object->attribute( 'id' );
        unset( $object );
        $object = eZContentObject::fetch( $objectID );
        $result['contentobject'] = $object;
        $result['contentobject_id'] = $object->attribute( 'id' );
        $result['contentobject_version'] = $publishVersion;
        $result['contentobject_main_node'] = false;
        $result['contentobject_main_node_id'] = false;

        $this->setResult( array( 'node_id' => false,
                                 'object_id' => $object->attribute( 'id' ),
                                 'object_version' => $publishVersion ) );

        switch ( $operationResult['status'] )
        {
            case eZModuleOperationInfo::STATUS_HALTED:
            {
                if ( isset( $operationResult['redirect_url'] ) )
                {
                    $result['redirect_url'] = $operationResult['redirect_url'];
                    $notices[] = array( 'description' => ezpI18n::tr( 'kernel/content/upload',
                                                                 'Publishing of content object was halted.' ) );
                    return true;
                }
                else if ( isset( $operationResult['result'] ) )
                {
                    $result['result'] = $operationResult['result'];
                    return true;
                }
            } break;

            case eZModuleOperationInfo::STATUS_CANCELLED:
            {
                $result['result'] = ezpI18n::tr( 'kernel/content/upload',
                                            'Publish process was cancelled.' );
                return true;
            } break;

            case eZModuleOperationInfo::STATUS_CONTINUE:
            {
            }
        }

        $mainNode = $object->mainNode();
        $result['contentobject_main_node'] = $mainNode;

        // The published object may not have a node if publishing was interrupted
        $mainNodeId = $mainNode ? $mainNode->attribute( 'node_id' ) : 0;

        $result['contentobject_main_node_id'] = $mainNodeId;
        $this->setResult( array( 'node_id' => $mainNodeId,
                                 'object_id' => $object->attribute( 'id' ),
                                 'object_version' => $publishVersion ) );

        return true;
    }
1259883
public function request(TypeInfo $resultTypeInfo, Request $apiRequest)
    {
        $headers = $apiRequest->getHeaders();

        $headers['Accept'] = JsonRequest::CONTENT_TYPE;

        if ($this->bearerToken !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->bearerToken;
        }

        $request = new Psr7\Request(
            $apiRequest->method,
            $apiRequest->getUrl($this->baseUrl),
            $headers,
            $apiRequest->getBody()
        );

        $options = $apiRequest->getOptions();
        $options['query'] = $apiRequest->getQuery();

        $response = $this->httpClient->send($request, $options);

        $responseBody = $response->getBody();
        $contents = $responseBody->getContents();
        $rawResult = Common::decode($contents);

        return $resultTypeInfo->deserialize($rawResult);
    }
1275386
public static function setArrayReturnType($returnType)
    {
        if (($returnType == self::RETURN_ARRAY_AS_VALUE) ||
            ($returnType == self::RETURN_ARRAY_AS_ERROR) ||
            ($returnType == self::RETURN_ARRAY_AS_ARRAY)) {
            self::$returnArrayAsType = $returnType;
            return true;
        }
        return false;
    }