Skip to content

Commit

Permalink
improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
IndraGunawan committed Feb 29, 2024
1 parent 4b6ca3a commit 339202e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Doctrine/DoctrineHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,22 @@ public static function getPropertyTypeForColumn(string $columnType): ?string
default => null,
};

if (null === $propertyType && Type::getTypeRegistry()->has($columnType)) {
$reflection = new \ReflectionClass(\get_class(Type::getTypeRegistry()->get($columnType)));
if ($reflection->hasMethod('convertToPHPValue') && $returnType = $reflection->getMethod('convertToPHPValue')->getReturnType()) {
if ($returnType->isBuiltin()) {
$propertyType = $returnType->getName();
} else {
$propertyType = '\\'.$returnType->getName();
}
}
if (null !== $propertyType || !($registry = Type::getTypeRegistry())->has($columnType)) {
return $propertyType;
}

$reflection = new \ReflectionClass(($registry->get($columnType))::class);

$returnType = $reflection->getMethod('convertToPHPValue')->getReturnType();

/*
* we do not support union and intersection types
*/
if (!$returnType instanceof \ReflectionNamedType) {
return null;
}

return $propertyType;
return $returnType->isBuiltin() ? $returnType->getName() : '\\'.$returnType->getName();
}

/**
Expand Down

0 comments on commit 339202e

Please sign in to comment.