UnknownColumnType.php 1.11 KB
Newer Older
1 2 3 4 5 6 7
<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Types\Exception;

use Doctrine\DBAL\DBALException;
Sergei Morozov's avatar
Sergei Morozov committed
8

9 10
use function sprintf;

Grégoire Paris's avatar
Grégoire Paris committed
11 12 13
/**
 * @psalm-immutable
 */
14 15
final class UnknownColumnType extends DBALException implements TypesException
{
Sergei Morozov's avatar
Sergei Morozov committed
16
    public static function new(string $name): self
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
    {
        return new self(
            sprintf(
                'Unknown column type "%s" requested. Any Doctrine type that you use has '
                    . 'to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the '
                    . 'known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database '
                    . 'introspection then you might have forgotten to register all database types for a Doctrine Type. '
                    . 'Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement '
                    . 'Type#getMappedDatabaseTypes(). If the type name is empty you might '
                    . 'have a problem with the cache or forgot some mapping information.',
                $name
            )
        );
    }
}