Skip to content

Commit

Permalink
Connection can accept object as well as classname (#44149)
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliopedrollo authored Sep 16, 2022
1 parent 7a03411 commit b088269
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1134,15 +1134,15 @@ public function getDoctrineConnection()
/**
* Register a custom Doctrine mapping type.
*
* @param string $class
* @param Type|class-string<Type> $class
* @param string $name
* @param string $type
* @return void
*
* @throws \Doctrine\DBAL\DBALException
* @throws \RuntimeException
*/
public function registerDoctrineType(string $class, string $name, string $type): void
public function registerDoctrineType(Type|string $class, string $name, string $type): void
{
if (! $this->isDoctrineAvailable()) {
throw new RuntimeException(
Expand All @@ -1151,7 +1151,8 @@ public function registerDoctrineType(string $class, string $name, string $type):
}

if (! Type::hasType($name)) {
Type::addType($name, $class);
Type::getTypeRegistry()
->register($name, is_string($class) ? new $class() : $class);
}

$this->doctrineTypeMappings[$name] = $type;
Expand Down

0 comments on commit b088269

Please sign in to comment.