Skip to content

Commit b088269

Browse files
Connection can accept object as well as classname (#44149)
1 parent 7a03411 commit b088269

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Illuminate/Database/Connection.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,15 +1134,15 @@ public function getDoctrineConnection()
11341134
/**
11351135
* Register a custom Doctrine mapping type.
11361136
*
1137-
* @param string $class
1137+
* @param Type|class-string<Type> $class
11381138
* @param string $name
11391139
* @param string $type
11401140
* @return void
11411141
*
11421142
* @throws \Doctrine\DBAL\DBALException
11431143
* @throws \RuntimeException
11441144
*/
1145-
public function registerDoctrineType(string $class, string $name, string $type): void
1145+
public function registerDoctrineType(Type|string $class, string $name, string $type): void
11461146
{
11471147
if (! $this->isDoctrineAvailable()) {
11481148
throw new RuntimeException(
@@ -1151,7 +1151,8 @@ public function registerDoctrineType(string $class, string $name, string $type):
11511151
}
11521152

11531153
if (! Type::hasType($name)) {
1154-
Type::addType($name, $class);
1154+
Type::getTypeRegistry()
1155+
->register($name, is_string($class) ? new $class() : $class);
11551156
}
11561157

11571158
$this->doctrineTypeMappings[$name] = $type;

0 commit comments

Comments
 (0)