Skip to content

Commit

Permalink
fix stan ii
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jan 22, 2022
1 parent 9c0715a commit 1ebf496
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
22 changes: 16 additions & 6 deletions src/Persistence/Sql/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,27 @@ public function connection()
}

/**
* Execute Expression by using this connection.
*
* @return DbalResult|int
* Execute Expression by using this connection and return result.
*/
public function executeQuery(Expression $expr): DbalResult
{
if ($this->connection === null) {
throw new Exception('DBAL connection is not set');
}

return $expr->executeQuery($this->connection);
}

/**
* Execute Expression by using this connection and return affected rows.
*/
public function execute(Expression $expr, bool $fromExecuteStatement)
public function executeStatement(Expression $expr): int
{
if ($this->connection === null) {
throw new Exception('Queries cannot be executed through this connection');
throw new Exception('DBAL connection is not set');
}

return $expr->execute($this->connection, $fromExecuteStatement);
return $expr->executeStatement($this->connection);
}

/**
Expand Down
20 changes: 15 additions & 5 deletions src/Persistence/Sql/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,26 @@ function ($matches) use ($params, &$numParams, &$i, &$j) {
*
* @return DbalResult|int
*
* @deprecated Expression::execute() is deprecated, use Expression::executeQuery() or Expression::executeStatement() instead
* @deprecated Expression::execute() is deprecated and will be removed in v4.0, use Expression::executeQuery() or Expression::executeStatement() instead
*/
public function execute(object $connection = null, bool $fromExecuteStatement)
public function execute(object $connection = null, bool $fromExecuteStatement = null)
{
if ($connection === null) {
$connection = $this->connection;
}

if ($fromExecuteStatement === null) {
'trigger_error'('Method is deprecated. Use executeQuery() or executeStatement() instead', \E_USER_DEPRECATED);

$fromExecuteStatement = false;
}

if (!$connection instanceof DbalConnection) {
return $connection->execute($this, $fromExecuteStatement);
if ($fromExecuteStatement) {
return $connection->executeStatement($this);
}

return $connection->executeQuery($this);
}

[$query, $params] = $this->updateRenderBeforeExecute($this->render());
Expand Down Expand Up @@ -630,15 +640,15 @@ public function execute(object $connection = null, bool $fromExecuteStatement)
*/
public function executeQuery(object $connection = null): DbalResult
{
return $this->execute($connection, false);
return $this->execute($connection, false); // @phpstan-ignore-line
}

/**
* @param DbalConnection|Connection $connection
*/
public function executeStatement(object $connection = null): int
{
return $this->execute($connection, true);
return $this->execute($connection, true); // @phpstan-ignore-line
}

// {{{ Result Querying
Expand Down

0 comments on commit 1ebf496

Please sign in to comment.