Skip to content

Commit b711fb4

Browse files
committed
Changed signature for prepareStatementForSqlObject()
Removed unnecessary inline @var casts Closes #115
1 parent b91ce9c commit b711fb4

4 files changed

Lines changed: 4 additions & 15 deletions

File tree

‎src/RowGateway/AbstractRowGateway.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Countable;
99
// phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse
1010
use Override;
11-
use PhpDb\Adapter\Driver\StatementInterface;
1211
use PhpDb\Sql\Sql;
1312
use PhpDb\Sql\TableIdentifier;
1413
use ReturnTypeWillChange;
@@ -125,7 +124,6 @@ public function save(): int
125124
}
126125
}
127126

128-
/** @var StatementInterface $statement */
129127
$statement = $this->sql->prepareStatementForSqlObject($this->sql->update()->set($data)->where($where));
130128
$result = $statement->execute();
131129
$rowsAffected = $result->getAffectedRows();
@@ -145,7 +143,6 @@ public function save(): int
145143
$insert = $this->sql->insert();
146144
$insert->values($this->data);
147145

148-
/** @var StatementInterface $statement */
149146
$statement = $this->sql->prepareStatementForSqlObject($insert);
150147

151148
$result = $statement->execute();
@@ -166,7 +163,6 @@ public function save(): int
166163
}
167164

168165
// refresh data
169-
/** @var StatementInterface $statement */
170166
$statement = $this->sql->prepareStatementForSqlObject($this->sql->select()->where($where));
171167
$result = $statement->execute();
172168
$rowData = $result->current();
@@ -192,7 +188,6 @@ public function delete(): int
192188

193189
// @todo determine if we need to do a select to ensure 1 row will be affected
194190

195-
/** @var StatementInterface $statement */
196191
$statement = $this->sql->prepareStatementForSqlObject($this->sql->delete()->where($where));
197192
$result = $statement->execute();
198193

‎src/Sql/Sql.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use PhpDb\Adapter\AdapterInterface;
88
use PhpDb\Adapter\Driver\StatementInterface;
9-
use PhpDb\Adapter\StatementContainerInterface;
109

1110
use function sprintf;
1211

@@ -109,11 +108,13 @@ public function prepareStatementForSqlObject(
109108
PreparableSqlInterface $sqlObject,
110109
?StatementInterface $statement = null,
111110
?AdapterInterface $adapter = null
112-
): ?StatementContainerInterface {
111+
): StatementInterface {
113112
$adapter = $adapter ?: $this->adapter;
114113
$statement = $statement ?: $adapter->getDriver()->createStatement();
115114

116-
return $this->sqlPlatform->setSubject($sqlObject)->prepareStatement($adapter, $statement);
115+
$this->sqlPlatform->setSubject($sqlObject)->prepareStatement($adapter, $statement);
116+
117+
return $statement;
117118
}
118119

119120
/**

‎src/TableGateway/AbstractTableGateway.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Closure;
88
use Override;
99
use PhpDb\Adapter\AdapterInterface;
10-
use PhpDb\Adapter\Driver\StatementInterface;
1110
use PhpDb\ResultSet\ResultSet;
1211
use PhpDb\ResultSet\ResultSetInterface;
1312
use PhpDb\Sql\Delete;
@@ -191,7 +190,6 @@ protected function executeSelect(Select $select): ResultSetInterface
191190
$this->featureSet->apply(EventFeatureEventsInterface::EVENT_PRE_SELECT, [$select]);
192191

193192
// prepare and execute
194-
/** @var StatementInterface $statement */
195193
$statement = $this->sql->prepareStatementForSqlObject($select);
196194
$result = $statement->execute();
197195

@@ -249,7 +247,6 @@ protected function executeInsert(Insert $insert): int
249247
$insert->into($unaliasedTable);
250248
}
251249

252-
/** @var StatementInterface $statement */
253250
$statement = $this->sql->prepareStatementForSqlObject($insert);
254251
$result = $statement->execute();
255252
$this->lastInsertValue = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
@@ -322,7 +319,6 @@ protected function executeUpdate(Update $update): int
322319
$update->table($unaliasedTable);
323320
}
324321

325-
/** @var StatementInterface $statement */
326322
$statement = $this->sql->prepareStatementForSqlObject($update);
327323
$result = $statement->execute();
328324

@@ -381,7 +377,6 @@ protected function executeDelete(Delete $delete): int
381377
$delete->from($unaliasedTable);
382378
}
383379

384-
/** @var StatementInterface $statement */
385380
$statement = $this->sql->prepareStatementForSqlObject($delete);
386381
$result = $statement->execute();
387382

‎test/unit/Sql/AbstractSqlFunctionalTestCase.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PhpDb\Adapter\Driver\DriverInterface;
99
use PhpDb\Adapter\Driver\StatementInterface;
1010
use PhpDb\Adapter\ParameterContainer;
11-
use PhpDb\Adapter\StatementContainer;
1211
use PhpDb\Sql;
1312
use PhpDb\Sql\Ddl\Column\Column;
1413
use PhpDb\Sql\Ddl\CreateTable;
@@ -279,7 +278,6 @@ public function test(PreparableSqlInterface|SqlInterface $sqlObject, string $pla
279278

280279
if (is_array($expected) && isset($expected['prepare'])) {
281280
self::assertInstanceOf(PreparableSqlInterface::class, $sqlObject);
282-
/** @var StatementInterface|StatementContainer $actual */
283281
$actual = $sql->prepareStatementForSqlObject($sqlObject);
284282
self::assertEquals($expected['prepare'], $actual->getSql(), 'prepareStatement()');
285283
if (isset($expected['parameters'])) {

0 commit comments

Comments
 (0)