@param ExecutableDefinitionInterface $definition
@param string                        $targetType
@param Endpoint                      $endpoint

@throws \ReflectionException

@deprecated since v1.2, should use `where` instead
190169
private function addFilters(ExecutableDefinitionInterface $definition, string $targetType, Endpoint $endpoint): void
    {
        $filterName = ucfirst($definition->getName()).'Filter';
        if ($endpoint->hasType($filterName)) {
            $filters = $endpoint->getType($filterName);
        } else {
            $filters = new InputObjectDefinition();
            $filters->setName($filterName);
            $endpoint->add($filters);

            $object = $endpoint->getType($targetType);
            if ($object instanceof FieldsAwareDefinitionInterface) {
                foreach ($object->getFields() as $field) {
                    if ('id' === $field->getName()
                        || !$field->getOriginName()
                        || \ReflectionProperty::class !== $field->getOriginType()) {
                        continue;
                    }

                    $filter = new FieldDefinition();
                    $filter->setName($field->getName());
                    $type = $field->getType();
                    if ($endpoint->hasType($type)) {
                        $typeDefinition = $endpoint->getType($type);
                        if (!$typeDefinition instanceof EnumDefinition) {
                            $type = 'ID';
                        }
                        $filter->setList(true);
                    }

                    // fields using custom object as type
                    // are not available for filters
                    if (TypeRegistry::getTypeMapp()) {
                        if (isset(TypeRegistry::getTypeMapp()[$type])) {
                            $class = TypeRegistry::getTypeMapp()[$type];
                            $ref = new \ReflectionClass($class);
                            if ($ref->isSubclassOf(ObjectType::class)) {
                                continue;
                            }
                        }
                    }

                    $filter->setType($type);
                    $filters->addField($filter);
                }
            }
        }

        if (!$filters->getFields()) {
            return;
        }

        $search = new ArgumentDefinition();
        $search->setName('filters');
        $search->setType($filters->getName());
        $deprecateMessage = \is_string($this->bcConfig['filters']) ? $this->bcConfig['filters'] : '**DEPRECATED** use `where` instead to filter the list.';
        $search->setDescription($deprecateMessage);
        $search->setNonNull(false);
        $definition->addArgument($search);
    }
434209
public static function resolveConcreteType(Endpoint $endpoint, PolymorphicDefinitionInterface $definition, $object)
    {
        //if discriminator map is set is used to get the value type
        if ($map = $definition->getDiscriminatorMap()) {
            //get concrete type based on property
            if ($definition->getDiscriminatorProperty()) {
                $property = $definition->getDiscriminatorProperty();
                $accessor = new PropertyAccessor();
                $propValue = $accessor->getValue($object, $property);
                $resolvedType = $map[$propValue] ?? null;
            }

            //get concrete type based on class
            if (!$resolvedType) {
                $class = DoctrineClassUtils::getClass($object);
                $resolvedType = $map[$class] ?? null;
            }
        }

        //final solution in case of not mapping is guess type based on class
        if (!$resolvedType && $definition instanceof InterfaceDefinition) {
            foreach ($definition->getImplementors() as $implementor) {
                $implementorDef = $endpoint->getType($implementor);
                if ($implementorDef instanceof ClassAwareDefinitionInterface
                    && $implementorDef->getClass() === DoctrineClassUtils::getClass($object)) {
                    $resolvedType = $implementorDef->getName();
                }
            }
        }

        if ($endpoint->hasType($resolvedType)) {
            $resolvedTypeDefinition = $endpoint->getType($resolvedType);
            if ($resolvedTypeDefinition instanceof PolymorphicDefinitionInterface) {
                $resolvedType = self::resolveConcreteType($endpoint, $resolvedTypeDefinition, $object);
            }
        }

        return $resolvedType;
    }
71731
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
    {
        $specificTargetType = $this->objectContainer->getImplementationClassName($targetType);

        if (Core::get()->classExists($specificTargetType)) {
            $propertyTags = $this->reflectionService->getPropertyTagValues($specificTargetType, $propertyName, 'var');

            if (!empty($propertyTags)) {
                return current($propertyTags);
            }
        }

        return parent::getTypeOfChildProperty($targetType, $propertyName, $configuration);
    }
196895
public function canConvertFrom($source, $targetType)
    {
        $identifier = $this->persistenceManager->getIdentifierByObject($source);
        return ($identifier !== null);
    }
101697
public function parse(\Imi\Bean\Annotation\Base $annotation, string $className, string $target, string $targetName)
    {
    }
512563
protected function getTypeConverter($source, $targetType, $configuration)
    {
        $compositeType = $this->parseCompositeType($targetType);

        if (in_array($compositeType, ['\\ArrayObject', 'array'])) {
            $typeConverter = $this->objectManager->get(ArrayConverter::class);
        } else {
            $typeConverter = $this->findTypeConverter($source, $targetType, $configuration);

            if ($typeConverter instanceof ExtbaseArrayConverter) {
                $typeConverter = $this->objectManager->get(ArrayConverter::class);
            } elseif ($typeConverter instanceof ObjectConverter) {
                $typeConverter = $this->getObjectConverter();
            }
        }

        if (!is_object($typeConverter) || !$typeConverter instanceof TypeConverterInterface) {
            throw new TypeConverterException('Type converter for "' . $source . '" -> "' . $targetType . '" not found.');
        }

        return $typeConverter;
    }
241163
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
    {
        $configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(\Neos\Flow\Property\TypeConverter\PersistentObjectConverter::class, self::CONFIGURATION_TARGET_TYPE);
        if ($configuredTargetType !== null) {
            return $configuredTargetType;
        }

        $schema = $this->reflectionService->getClassSchema($targetType);
        $setterMethodName = ObjectAccess::buildSetterMethodName($propertyName);
        $constructorParameters = $this->reflectionService->getMethodParameters($targetType, '__construct');

        if (isset($constructorParameters[$propertyName]) && isset($constructorParameters[$propertyName]['type'])) {
            return $constructorParameters[$propertyName]['type'];
        } elseif ($schema->hasProperty($propertyName)) {
            $propertyInformation = $schema->getProperty($propertyName);
            return $propertyInformation['type'] . ($propertyInformation['elementType'] !== null ? '<' . $propertyInformation['elementType'] . '>' : '');
        } elseif ($this->reflectionService->hasMethod($targetType, $setterMethodName)) {
            $methodParameters = $this->reflectionService->getMethodParameters($targetType, $setterMethodName);
            $methodParameter = current($methodParameters);
            if (!isset($methodParameter['type'])) {
                throw new InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $targetType . '".', 1303379158);
            } else {
                return $methodParameter['type'];
            }
        } else {
            throw new InvalidTargetException('Property "' . $propertyName . '" was not found in target object of type "' . $targetType . '".', 1297978366);
        }
    }
221472
public function process(\ReflectionClass $reflection, Definition $definition)
    {
        $annotations = $this->reader->getClassAnnotations($reflection);

        foreach ($annotations as $annotation)
        {
            if ($annotation instanceof Link) {
                $link = $this->createLink($annotation);

                $definition->addLink($link);
                continue;
            }

            if ($annotation instanceof ResourceIdentifier && $annotation->type !== null) {
                $definition->setType($annotation->type);
            }
        }
    }
53140
public function publishTypeAndFields($typeId, $sourceStatus, $targetStatus)
    {
        try {
            return $this->innerGateway->publishTypeAndFields($typeId, $sourceStatus, $targetStatus);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
442882
protected function errorCheckConfiguredSubdependencyType($subdependencyReflectionParam, $proposedType, $dependencyClassname)
    {
        $reflectionClassOfParamTypehint = $subdependencyReflectionParam->getClass();
        $paramTypehint                  = $reflectionClassOfParamTypehint->name;

        if ($reflectionClassOfParamTypehint->isInterface())
        {
            $interfacesImplemented = class_implements($proposedType);
            if (!in_array($paramTypehint, $interfacesImplemented)) {
                throw new BadDiInterfaceConfigurationException(
                    "Configured to use type '$proposedType' as implentation of interface '" . $paramTypehint . "' when producing a '$dependencyClassname', but it doesn't implement the interface."
                );
            }
        } else {
            $requiredClassname = '\\' . $paramTypehint;
            if ( ! ($proposedType === $requiredClassname || is_subclass_of($proposedType, $requiredClassname) )) {
                throw new BadDiSubclassConfigurationException(
                    "Configured to use type '$proposedType' as subclass of '$requiredClassname' when producing a '$dependencyClassname', but it is failing an instanceof test."
                );
            }
        }
    }
1373913
private function createConnection(Endpoint $endpoint, DefinitionInterface $node): ObjectDefinition
    {
        $connection = new ObjectDefinition();
        $connection->setName("{$node->getName()}Connection");

        if (!$endpoint->hasType($connection->getName())) {
            $endpoint->addType($connection);

            $totalCount = new FieldDefinition();
            $totalCount->setName('totalCount');
            $totalCount->setType('Int');
            $totalCount->setNonNull(true);
            $connection->addField($totalCount);

            $pages = new FieldDefinition();
            $pages->setName('pages');
            $pages->setType('Int');
            $pages->setNonNull(true);
            $connection->addField($pages);

            $pageInfo = new FieldDefinition();
            $pageInfo->setName('pageInfo');
            $pageInfo->setType('PageInfo');
            $pageInfo->setNonNull(true);
            $connection->addField($pageInfo);

            $edgeObject = new ObjectDefinition();
            $edgeObject->setName("{$node->getName()}Edge");
            if (!$endpoint->hasType($edgeObject->getName())) {
                $endpoint->addType($edgeObject);

                $nodeField = new FieldDefinition();
                $nodeField->setName('node');
                $nodeField->setType($node->getName());
                $nodeField->setNonNull(true);
                $edgeObject->addField($nodeField);

                $cursor = new FieldDefinition();
                $cursor->setName('cursor');
                $cursor->setType('string');
                $cursor->setNonNull(true);
                $edgeObject->addField($cursor);
            }

            $edges = new FieldDefinition();
            $edges->setName('edges');
            $edges->setType($edgeObject->getName());
            $edges->setList(true);
            $connection->addField($edges);
        } else {
            $connection = $endpoint->getType($connection->getName());
        }

        return $connection;
    }
677411
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
    {
        try {
            $role = $this->policyService->getRole($source);
        } catch (NoSuchRoleException $exception) {
            return new Error('Could not find a role with the identifier "%s".', 1397212327, [$source]);
        }
        return $role;
    }
365300
public static final void injectEndpoints(final Object target, final TestContext context) {
        ReflectionUtils.doWithFields(target.getClass(), new ReflectionUtils.FieldCallback() {
            @Override
            public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
                log.debug(String.format("Injecting Citrus endpoint on test class field '%s'", field.getName()));
                CitrusEndpoint endpointAnnotation = field.getAnnotation(CitrusEndpoint.class);

                for (Annotation annotation : field.getAnnotations()) {
                    if (annotation.annotationType().getAnnotation(CitrusEndpointConfig.class) != null) {
                        ReflectionUtils.setField(field, target, context.getEndpointFactory().create(getEndpointName(field), annotation, context));
                        return;
                    }
                }

                Endpoint endpoint;
                if (StringUtils.hasText(endpointAnnotation.name())) {
                    endpoint = context.getReferenceResolver().resolve(endpointAnnotation.name(), (Class<Endpoint>) field.getType());
                } else {
                    endpoint = context.getReferenceResolver().resolve((Class<Endpoint>) field.getType());
                }

                ReflectionUtils.setField(field, target, endpoint);
            }
        }, new ReflectionUtils.FieldFilter() {
            @Override
            public boolean matches(Field field) {
                if (field.isAnnotationPresent(CitrusEndpoint.class) &&
                        Endpoint.class.isAssignableFrom(field.getType())) {
                    if (!field.isAccessible()) {
                        ReflectionUtils.makeAccessible(field);
                    }

                    return true;
                }

                return false;
            }
        });
    }
674643
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
    {
        if (!$targetEntity->reflClass->implementsInterface(\WellCommerce\Bundle\LocaleBundle\Entity\LocaleAwareInterface::class)) {
            return "";
        }

        return $targetTableAlias . '.locale = ' . $this->getParameter('locale');
    }
291032
protected function fetchObjectFromPersistence($identity, $targetType)
    {
        if (is_string($identity)) {
            $object = $this->persistenceManager->getObjectByIdentifier($identity, $targetType);
        } elseif (is_array($identity)) {
            $object = $this->findObjectByIdentityProperties($identity, $targetType);
        } else {
            throw new InvalidSourceException(sprintf('The identity property is neither a string nor an array but of type "%s".', gettype($identity)), 1297931020);
        }

        return $object;
    }
625037
public function setDefinition(ExecutableDefinitionInterface $definition): ContextBuilder
    {
        $this->definition = $definition;

        $type = null;
        if ($definition instanceof NodeAwareDefinitionInterface && $definition->getNode()) {
            $type = $definition->getNode();
        }

        if (!$type) {
            $type = $definition->getType();
        }

        if ($this->endpoint->hasType($type)
            && ($nodeDefinition = $this->endpoint->getType($type))
            && ($nodeDefinition instanceof ObjectDefinition || $nodeDefinition instanceof InterfaceDefinition)) {
            $this->node = $nodeDefinition;
        }

        return $this;
    }
325943
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
    {
        $configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(ObjectConverter::class, self::CONFIGURATION_TARGET_TYPE);
        if ($configuredTargetType !== null) {
            return $configuredTargetType;
        }

        $methodParameters = $this->reflectionService->getMethodParameters($targetType, '__construct');
        if (isset($methodParameters[$propertyName]) && isset($methodParameters[$propertyName]['type'])) {
            return $methodParameters[$propertyName]['type'];
        } elseif ($this->reflectionService->hasMethod($targetType, ObjectAccess::buildSetterMethodName($propertyName))) {
            $methodParameters = $this->reflectionService->getMethodParameters($targetType, ObjectAccess::buildSetterMethodName($propertyName));
            $methodParameter = current($methodParameters);
            if (!isset($methodParameter['type'])) {
                throw new InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $targetType . '".', 1303379158);
            } else {
                return $methodParameter['type'];
            }
        } else {
            $targetPropertyNames = $this->reflectionService->getClassPropertyNames($targetType);
            if (in_array($propertyName, $targetPropertyNames)) {
                $varTagValues = $this->reflectionService->getPropertyTagValues($targetType, $propertyName, 'var');
                if (count($varTagValues) > 0) {
                    // This ensures that FQCNs are returned without leading backslashes. Otherwise, something like @var \DateTime
                    // would not find a property mapper. It is needed because the ObjectConverter doesn't use class schemata,
                    // but reads the annotations directly.
                    $declaredType = strtok(trim(current($varTagValues), " \n\t"), " \n\t");
                    try {
                        $parsedType = TypeHandling::parseType($declaredType);
                    } catch (InvalidTypeException $exception) {
                        throw new \InvalidArgumentException(sprintf($exception->getMessage(), 'class "' . $targetType . '" for property "' . $propertyName . '"'), 1467699674);
                    }
                    return $parsedType['type'] . ($parsedType['elementType'] !== null ? '<' . $parsedType['elementType'] . '>' : '');
                } else {
                    throw new InvalidTargetException(sprintf('Public property "%s" had no proper type annotation (i.e. "@var") in target object of type "%s".', $propertyName, $targetType), 1406821818);
                }
            }
        }

        if ($configuration->shouldSkipUnknownProperties() || $configuration->shouldSkip($propertyName)) {
            return null;
        }

        throw new InvalidTargetException(sprintf('Property "%s" has neither a setter or constructor argument, nor is public, in target object of type "%s".', $propertyName, $targetType), 1303379126);
    }