Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Doctrine/DBAL/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public function setFilterSchemaAssetsExpression($filterExpression)
{
$this->_attributes['filterSchemaAssetsExpression'] = $filterExpression;
if ($filterExpression) {
$this->_attributes['filterSchemaAssetsExpressionCallable'] = $this->buildSchemaAssetsFilterFromExpression($filterExpression);
$this->_attributes['filterSchemaAssetsExpressionCallable']
= $this->buildSchemaAssetsFilterFromExpression($filterExpression);
} else {
$this->_attributes['filterSchemaAssetsExpressionCallable'] = null;
}
Expand Down
22 changes: 19 additions & 3 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,12 @@ public function executeQuery($sql, array $params = [], $types = [], ?QueryCacheP
$stmt = $connection->query($sql);
}
} catch (Throwable $ex) {
throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $sql, $this->resolveParams($params, $types));
throw DBALException::driverExceptionDuringQuery(
$this->_driver,
$ex,
$sql,
$this->resolveParams($params, $types)
);
}

$stmt->setFetchMode($this->defaultFetchMode);
Expand Down Expand Up @@ -961,7 +966,13 @@ public function executeCacheQuery($sql, $params, $types, QueryCacheProfile $qcp)
}

if (! isset($stmt)) {
$stmt = new ResultCacheStatement($this->executeQuery($sql, $params, $types), $resultCache, $cacheKey, $realKey, $qcp->getLifetime());
$stmt = new ResultCacheStatement(
$this->executeQuery($sql, $params, $types),
$resultCache,
$cacheKey,
$realKey,
$qcp->getLifetime()
);
}

$stmt->setFetchMode($this->defaultFetchMode);
Expand Down Expand Up @@ -1069,7 +1080,12 @@ public function executeUpdate($sql, array $params = [], array $types = [])
$result = $connection->exec($sql);
}
} catch (Throwable $ex) {
throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $sql, $this->resolveParams($params, $types));
throw DBALException::driverExceptionDuringQuery(
$this->_driver,
$ex,
$sql,
$this->resolveParams($params, $types)
);
}

if ($logger) {
Expand Down
11 changes: 8 additions & 3 deletions lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
* )
* ));
*
* You can also pass 'driverOptions' and any other documented option to each of this drivers to pass additional information.
* You can also pass 'driverOptions' and any other documented option to each of this drivers
* to pass additional information.
*/
class MasterSlaveConnection extends Connection
{
Expand All @@ -91,8 +92,12 @@ class MasterSlaveConnection extends Connection
*
* @throws InvalidArgumentException
*/
public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null)
{
public function __construct(
array $params,
Driver $driver,
?Configuration $config = null,
?EventManager $eventManager = null
) {
if (! isset($params['slaves'], $params['master'])) {
throw new InvalidArgumentException('master or slaves configuration missing');
}
Expand Down
8 changes: 6 additions & 2 deletions lib/Doctrine/DBAL/DBALException.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ public static function invalidWrapperClass($wrapperClass)
*/
public static function invalidDriverClass($driverClass)
{
return new self("The given 'driverClass' " . $driverClass . ' has to implement the ' . Driver::class . ' interface.');
return new self(
"The given 'driverClass' " . $driverClass . ' has to implement the ' . Driver::class . ' interface.'
);
}

/**
Expand Down Expand Up @@ -288,7 +290,9 @@ public static function typeNotFound($name)

public static function typeNotRegistered(Type $type): self
{
return new self(sprintf('Type of the class %s@%s is not registered.', get_class($type), spl_object_hash($type)));
return new self(
sprintf('Type of the class %s@%s is not registered.', get_class($type), spl_object_hash($type))
);
}

public static function typeAlreadyRegistered(Type $type): self
Expand Down
6 changes: 5 additions & 1 deletion lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public function __construct(array $params, $username, $password, array $driverOp
});
try {
if (! $this->conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) {
throw new MysqliException($this->conn->connect_error, $this->conn->sqlstate ?? 'HY000', $this->conn->connect_errno);
throw new MysqliException(
$this->conn->connect_error,
$this->conn->sqlstate ?? 'HY000',
$this->conn->connect_errno
);
}
} finally {
restore_error_handler();
Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ private function bindTypedParameters(): void
if ($types[$parameter - 1] === static::$_paramTypeMap[ParameterType::LARGE_OBJECT]) {
if (is_resource($value)) {
if (get_resource_type($value) !== 'stream') {
throw new InvalidArgumentException('Resources passed with the LARGE_OBJECT parameter type must be stream resources.');
throw new InvalidArgumentException(
'Resources passed with the LARGE_OBJECT parameter type must be stream resources.'
);
}

$streams[$parameter] = $value;
Expand Down
10 changes: 7 additions & 3 deletions lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,12 @@ public static function convertPositionalToNamedPlaceholders($statement)
* @param string $statement The SQL statement to parse
* @param string $tokenOffset The offset to start searching from
* @param int $fragmentOffset The offset to build the next fragment from
* @param string[] $fragments Fragments of the original statement not containing placeholders
* @param string[] $fragments Fragments of the original statement
* not containing placeholders
* @param string|null $currentLiteralDelimiter The delimiter of the current string literal
* or NULL if not currently in a literal
* @param array<int, string> $paramMap Mapping of the original parameter positions to their named replacements
* @param array<int, string> $paramMap Mapping of the original parameter positions
* to their named replacements
*
* @return bool Whether the token was found
*/
Expand Down Expand Up @@ -282,7 +284,9 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le
{
if (is_int($param)) {
if (! isset($this->_paramMap[$param])) {
throw new OCI8Exception(sprintf('Could not find variable mapping with index %d, in the SQL statement', $param));
throw new OCI8Exception(
sprintf('Could not find variable mapping with index %d, in the SQL statement', $param)
);
}

$param = $this->_paramMap[$param];
Expand Down
9 changes: 0 additions & 9 deletions lib/Doctrine/DBAL/Driver/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\ParameterType;
use PDO;

use function assert;
Expand Down Expand Up @@ -93,14 +92,6 @@ public function query()
}
}

/**
* {@inheritdoc}
*/
public function quote($input, $type = ParameterType::STRING)
{
return parent::quote($input, $type);
}

/**
* {@inheritdoc}
*/
Expand Down
6 changes: 4 additions & 2 deletions lib/Doctrine/DBAL/Driver/ResultStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX
* @param int|null $fetchMode Controls how the next row will be returned to the caller.
* The value must be one of the {@link FetchMode} constants,
* defaulting to {@link FetchMode::MIXED}.
* @param int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter:
* @param int|null $fetchArgument This argument has a different meaning depending on the value
* of the $fetchMode parameter:
* * {@link FetchMode::COLUMN}:
* Returns the indicated 0-indexed column.
* * {@link FetchMode::CUSTOM_OBJECT}:
* Returns instances of the specified class, mapping the columns of each row
* to named properties in the class.
* * {@link PDO::FETCH_FUNC}: Returns the results of calling the specified function, using each row's
* * {@link PDO::FETCH_FUNC}: Returns the results of calling
* the specified function, using each row's
* columns as parameters in the call.
* @param mixed[]|null $ctorArgs Controls how the next row will be returned to the caller.
* The value must be one of the {@link FetchMode} constants,
Expand Down
11 changes: 9 additions & 2 deletions lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ public function getName()
*
* @return string
*/
private function buildDsn($host, $port, $server, $dbname, $username = null, $password = null, array $driverOptions = [])
{
private function buildDsn(
$host,
$port,
$server,
$dbname,
$username = null,
$password = null,
array $driverOptions = []
) {
$host = $host ?: 'localhost';
$port = $port ?: 2638;

Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ public function bindValue($param, $value, $type = ParameterType::STRING)
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null)
{
if (! is_numeric($param)) {
throw new SQLSrvException('sqlsrv does not support named parameters to queries, use question mark (?) placeholders instead.');
throw new SQLSrvException(
'sqlsrv does not support named parameters to queries, use question mark (?) placeholders instead.'
);
}

$this->variables[$param] =& $variable;
Expand Down
5 changes: 4 additions & 1 deletion lib/Doctrine/DBAL/DriverManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ private static function _checkParams(array $params): void
throw DBALException::unknownDriver($params['driver'], array_keys(self::$_driverMap));
}

if (isset($params['driverClass']) && ! in_array(Driver::class, class_implements($params['driverClass'], true))) {
if (
isset($params['driverClass'])
&& ! in_array(Driver::class, class_implements($params['driverClass'], true))
) {
throw DBALException::invalidDriverClass($params['driverClass']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Event/ConnectionEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Doctrine\DBAL\Schema\AbstractSchemaManager;

/**
* Event Arguments used when a Driver connection is established inside Doctrine\DBAL\Connection.
* Event Arguments used when a Driver connection is established inside {@link Connection}.
*/
class ConnectionEventArgs extends EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use function is_array;

/**
* Event Arguments used when SQL queries for adding table columns are generated inside Doctrine\DBAL\Platform\*Platform.
* Event Arguments used when SQL queries for adding table columns are generated inside {@link AbstractPlatform}.
*/
class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use function is_array;

/**
* Event Arguments used when SQL queries for changing table columns are generated inside Doctrine\DBAL\Platform\*Platform.
* Event Arguments used when SQL queries for changing table columns are generated inside {@link AbstractPlatform}.
*/
class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function is_array;

/**
* Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\*Platform.
* Event Arguments used when SQL queries for creating tables are generated inside {@link AbstractPlatform}.
*/
class SchemaAlterTableEventArgs extends SchemaEventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use function is_array;

/**
* Event Arguments used when SQL queries for removing table columns are generated inside Doctrine\DBAL\Platform\*Platform.
* Event Arguments used when SQL queries for removing table columns are generated inside {@link AbstractPlatform}.
*/
class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use function is_array;

/**
* Event Arguments used when SQL queries for renaming table columns are generated inside Doctrine\DBAL\Platform\*Platform.
* Event Arguments used when SQL queries for renaming table columns are generated inside {@link AbstractPlatform}.
*/
class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Doctrine\DBAL\Schema\Column;

/**
* Event Arguments used when the portable column definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager.
* Event Arguments used when the portable column definition is generated inside {@link AbstractPlatform}.
*/
class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use function is_array;

/**
* Event Arguments used when SQL queries for creating table columns are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
* Event Arguments used when SQL queries for creating table columns are generated inside {@link AbstractPlatform}.
*/
class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function is_array;

/**
* Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
* Event Arguments used when SQL queries for creating tables are generated inside {@link AbstractPlatform}.
*/
class SchemaCreateTableEventArgs extends SchemaEventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use InvalidArgumentException;

/**
* Event Arguments used when the SQL query for dropping tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
* Event Arguments used when the SQL query for dropping tables are generated inside {@link AbstractPlatform}.
*/
class SchemaDropTableEventArgs extends SchemaEventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Doctrine\DBAL\Schema\Index;

/**
* Event Arguments used when the portable index definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager.
* Event Arguments used when the portable index definition is generated inside {@link AbstractSchemaManager}.
*/
class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
{
Expand Down
9 changes: 7 additions & 2 deletions lib/Doctrine/DBAL/Id/TableGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public function __construct(Connection $conn, $generatorTableName = 'sequences')
throw new DBALException('Cannot use TableGenerator with SQLite.');
}

$this->conn = DriverManager::getConnection($params, $conn->getConfiguration(), $conn->getEventManager());
$this->conn = DriverManager::getConnection($params, $conn->getConfiguration(), $conn->getEventManager());

$this->generatorTableName = $generatorTableName;
}

Expand Down Expand Up @@ -145,7 +146,11 @@ public function nextValue($sequence)
} catch (Throwable $e) {
$this->conn->rollBack();

throw new DBALException('Error occurred while generating ID with TableGenerator, aborted generation: ' . $e->getMessage(), 0, $e);
throw new DBALException(
'Error occurred while generating ID with TableGenerator, aborted generation: ' . $e->getMessage(),
0,
$e
);
}

return $value;
Expand Down
10 changes: 8 additions & 2 deletions lib/Doctrine/DBAL/Logging/DebugStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ public function startQuery($sql, ?array $params = null, ?array $types = null)
return;
}

$this->start = microtime(true);
$this->queries[++$this->currentQuery] = ['sql' => $sql, 'params' => $params, 'types' => $types, 'executionMS' => 0];
$this->start = microtime(true);

$this->queries[++$this->currentQuery] = [
'sql' => $sql,
'params' => $params,
'types' => $types,
'executionMS' => 0,
];
}

/**
Expand Down
Loading