Unverified Commit 8026912f authored by Benjamin Morel's avatar Benjamin Morel Committed by Sergei Morozov

Change the SQLLogger interface signature

parent a9840796
......@@ -32,7 +32,7 @@ class DebugStack implements SQLLogger
/**
* {@inheritdoc}
*/
public function startQuery($sql, ?array $params = null, ?array $types = null)
public function startQuery(string $sql, array $params = [], array $types = []) : void
{
if (! $this->enabled) {
return;
......@@ -45,7 +45,7 @@ class DebugStack implements SQLLogger
/**
* {@inheritdoc}
*/
public function stopQuery()
public function stopQuery() : void
{
if (! $this->enabled) {
return;
......
......@@ -13,7 +13,7 @@ class EchoSQLLogger implements SQLLogger
/**
* {@inheritdoc}
*/
public function startQuery($sql, ?array $params = null, ?array $types = null)
public function startQuery(string $sql, array $params = [], array $types = []) : void
{
echo $sql . PHP_EOL;
......@@ -31,7 +31,7 @@ class EchoSQLLogger implements SQLLogger
/**
* {@inheritdoc}
*/
public function stopQuery()
public function stopQuery() : void
{
}
}
......@@ -22,10 +22,8 @@ class LoggerChain implements SQLLogger
* Adds a logger in the chain.
*
* @deprecated Inject list of loggers via constructor instead
*
* @return void
*/
public function addLogger(SQLLogger $logger)
public function addLogger(SQLLogger $logger) : void
{
$this->loggers[] = $logger;
}
......@@ -33,7 +31,7 @@ class LoggerChain implements SQLLogger
/**
* {@inheritdoc}
*/
public function startQuery($sql, ?array $params = null, ?array $types = null)
public function startQuery(string $sql, array $params = [], array $types = []) : void
{
foreach ($this->loggers as $logger) {
$logger->startQuery($sql, $params, $types);
......@@ -43,7 +41,7 @@ class LoggerChain implements SQLLogger
/**
* {@inheritdoc}
*/
public function stopQuery()
public function stopQuery() : void
{
foreach ($this->loggers as $logger) {
$logger->stopQuery();
......
......@@ -10,14 +10,14 @@ final class NullLogger implements SQLLogger
/**
* {@inheritdoc}
*/
public function startQuery($sql, ?array $params = null, ?array $types = null)
public function startQuery(string $sql, ?array $params = [], ?array $types = []) : void
{
}
/**
* {@inheritdoc}
*/
public function stopQuery()
public function stopQuery() : void
{
}
}
......@@ -10,18 +10,14 @@ interface SQLLogger
/**
* Logs a SQL statement somewhere.
*
* @param string $sql The SQL to be executed.
* @param mixed[]|null $params The SQL parameters.
* @param int[]|string[]|null $types The SQL parameter types.
*
* @return void
* @param string $sql The SQL to be executed.
* @param mixed[] $params The SQL parameters.
* @param int[]|string[] $types The SQL parameter types.
*/
public function startQuery($sql, ?array $params = null, ?array $types = null);
public function startQuery(string $sql, array $params = [], array $types = []) : void;
/**
* Marks the last started query as stopped. This can be used for timing of queries.
*
* @return void
*/
public function stopQuery();
public function stopQuery() : void;
}
......@@ -27,8 +27,8 @@ class DebugStackTest extends DbalTestCase
[
1 => [
'sql' => 'SELECT column FROM table',
'params' => null,
'types' => null,
'params' => [],
'types' => [],
'executionMS' => 0,
],
],
......
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