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