8000 improve readability · symfony/maker-bundle@339202e · GitHub
[go: up one dir, main page]

Skip to content

Commit 339202e

Browse files
committed
improve readability
1 parent 4b6ca3a commit 339202e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/Doctrine/DoctrineHelper.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,18 +273,22 @@ public static function getPropertyTypeForColumn(string $columnType): ?string
273273
default => null,
274274
};
275275

276-
if (null === $propertyType && Type::getTypeRegistry()->has($columnType)) {
277-
$reflection = new \ReflectionClass(\get_class(Type::getTypeRegistry()->get($columnType)));
278-
if ($reflection->hasMethod('convertToPHPValue') && $returnType = $reflection->getMethod('convertToPHPValue')->getReturnType()) {
279-
if ($returnType->isBuiltin()) {
280-
$propertyType = $returnType->getName();
281-
} else {
282-
$propertyType = '\\'.$returnType->getName();
283-
}
284-
}
276+
if (null !== $propertyType || !($registry = Type::getTypeRegistry())->has($columnType)) {
277+
return $propertyType;
278+
}
279+
280+
$reflection = new \ReflectionClass(($registry->get($columnType))::class);
281+
282+
$returnType = $reflection->getMethod('convertToPHPValue')->getReturnType();
283+
284+
/*
285+
* we do not support union and intersection types
286+
*/
287+
if (!$returnType instanceof \ReflectionNamedType) {
288+
return null;
285289
}
286290

287-
return $propertyType;
291+
return $returnType->isBuiltin() ? $returnType->getName() : '\\'.$returnType->getName();
288292
}
289293

290294
/**

0 commit comments

Comments
 (0)
0