Reuse Mysqli\UnknownType as Exception\UnknownParameterType for other drivers

parent bb9f47f5
......@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
namespace Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\AbstractException;
......@@ -13,13 +13,13 @@ use function sprintf;
*
* @psalm-immutable
*/
final class UnknownType extends AbstractException
final class UnknownParameterType extends AbstractException
{
/**
* @param mixed $type
*/
public static function new($type): self
{
return new self(sprintf('Unknown type, %d given.', $type));
return new self(sprintf('Unknown parameter type, %d given.', $type));
}
}
......@@ -3,10 +3,10 @@
namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\Exception\UnknownParameterType;
use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError;
use Doctrine\DBAL\Driver\Mysqli\Exception\FailedReadingStreamOffset;
use Doctrine\DBAL\Driver\Mysqli\Exception\StatementError;
use Doctrine\DBAL\Driver\Mysqli\Exception\UnknownType;
use Doctrine\DBAL\Driver\Result as ResultInterface;
use Doctrine\DBAL\Driver\Statement as StatementInterface;
use Doctrine\DBAL\Exception\InvalidArgumentException;
......@@ -91,7 +91,7 @@ final class Statement implements StatementInterface
assert(is_int($column));
if (! isset(self::$_paramTypeMap[$type])) {
throw UnknownType::new($type);
throw UnknownParameterType::new($type);
}
$this->_bindedValues[$column] =& $variable;
......@@ -108,7 +108,7 @@ final class Statement implements StatementInterface
assert(is_int($param));
if (! isset(self::$_paramTypeMap[$type])) {
throw UnknownType::new($type);
throw UnknownParameterType::new($type);
}
$this->_values[$param] = $value;
......
......@@ -2,10 +2,11 @@
namespace Doctrine\DBAL\Driver\PDO;
use Doctrine\DBAL\Driver\Exception as ExceptionInterface;
use Doctrine\DBAL\Driver\Exception\UnknownParameterType;
use Doctrine\DBAL\Driver\Result as ResultInterface;
use Doctrine\DBAL\Driver\Statement as StatementInterface;
use Doctrine\DBAL\ParameterType;
use InvalidArgumentException;
use PDO;
use PDOException;
use PDOStatement;
......@@ -89,11 +90,13 @@ class Statement implements StatementInterface
* Converts DBAL parameter type to PDO parameter type
*
* @param int $type Parameter type
*
* @throws ExceptionInterface
*/
private function convertParamType(int $type): int
{
if (! isset(self::PARAM_TYPE_MAP[$type])) {
throw new InvalidArgumentException('Invalid parameter type: ' . $type);
throw UnknownParameterType::new($type);
}
return self::PARAM_TYPE_MAP[$type];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment