various improvements

This commit is contained in:
2021-12-04 01:13:55 +01:00
parent 6c1a946608
commit 063ceb2c53
17 changed files with 163 additions and 69 deletions

View File

@@ -99,7 +99,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
}
$type = $reflection->getProperty($attribute->getName())->getType();
} elseif ($reflection->hasMethod($method = 'get'.ucfirst($attribute->getName()))) {
} elseif ($reflection->hasMethod($method = 'get' . ucfirst($attribute->getName()))) {
if (!$reflection->getMethod($method)->hasReturnType()) {
throw new \LogicException(sprintf(
'Could not determine how the content is determined for the attribute %s. Add a return type on the method',
@@ -108,7 +108,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
}
$type = $reflection->getMethod($method)->getReturnType();
} elseif ($reflection->hasMethod($method = 'is'.ucfirst($attribute->getName()))) {
} elseif ($reflection->hasMethod($method = 'is' . ucfirst($attribute->getName()))) {
if (!$reflection->getMethod($method)->hasReturnType()) {
throw new \LogicException(sprintf(
'Could not determine how the content is determined for the attribute %s. Add a return type on the method',
@@ -168,12 +168,14 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
switch ($type) {
case 'array':
return [];
case 'bool':
case 'double':
case 'float':
case 'int':
case 'resource':
return null;
case 'string':
return '';