mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
handle finding returnType on property type on parent classes
This commit is contained in:
parent
de4e83b3fb
commit
9f43c99acc
@ -86,19 +86,34 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
|
||||
private function getExpectedType(AttributeMetadata $attribute, ReflectionClass $reflection): string
|
||||
{
|
||||
$type = null;
|
||||
|
||||
do {
|
||||
// we have to get the expected content
|
||||
if ($reflection->hasProperty($attribute->getName())) {
|
||||
$type = $reflection->getProperty($attribute->getName())->getType();
|
||||
} elseif ($reflection->hasMethod($attribute->getName())) {
|
||||
$type = $reflection->getMethod($attribute->getName())->getReturnType();
|
||||
} else {
|
||||
if (!$reflection->getProperty($attribute->getName())->hasType()) {
|
||||
throw new \LogicException(sprintf(
|
||||
'Could not determine how the content is determined for the attribute %s. Add attribute property only on property or method',
|
||||
'Could not determine how the content is determined for the attribute %s. Add a type on this property',
|
||||
$attribute->getName()
|
||||
));
|
||||
}
|
||||
|
||||
if (null === $type) {
|
||||
$type = $reflection->getProperty($attribute->getName())->getType();
|
||||
} elseif ($reflection->hasMethod($attribute->getName())) {
|
||||
if (!$reflection->getMethod($attribute->getName())->hasReturnType()) {
|
||||
throw new \LogicException(sprintf(
|
||||
'Could not determine how the content is determined for the attribute %s. Add a return type on the method',
|
||||
$attribute->getName()
|
||||
));
|
||||
}
|
||||
|
||||
$type = $reflection->getMethod($attribute->getName())->getReturnType();
|
||||
} else {
|
||||
$reflection = $reflection->getParentClass();
|
||||
}
|
||||
} while (null === $type && $reflection instanceof ReflectionClass);
|
||||
|
||||
if (null === $type ?? null) {
|
||||
throw new \LogicException(sprintf(
|
||||
'Could not determine the type for this attribute: %s. Add a return type to the method or property declaration',
|
||||
$attribute->getName()
|
||||
|
Loading…
x
Reference in New Issue
Block a user