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);
}
}