Skip to content

Commit f597e26

Browse files
Better naming classes with PDO - part 2. (#262)
1 parent 7df201c commit f597e26

11 files changed

+70
-31
lines changed

.github/workflows/composer-require-checker.yml

+45-6
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,48 @@ name: Composer require checker
2525

2626
jobs:
2727
composer-require-checker:
28-
uses: yiisoft/actions/.github/workflows/composer-require-checker.yml@master
29-
with:
30-
os: >-
31-
['ubuntu-latest']
32-
php: >-
33-
['8.0', '8.1']
28+
name: PHP ${{ matrix.php }}
29+
30+
env:
31+
COMPOSER_ROOT_VERSION: dev-master
32+
33+
runs-on: ${{ matrix.os }}
34+
35+
strategy:
36+
matrix:
37+
os:
38+
- ubuntu-latest
39+
40+
php:
41+
- 8.0
42+
- 8.1
43+
- 8.2
44+
45+
steps:
46+
- name: Checkout.
47+
uses: actions/checkout@v3
48+
49+
- name: Install PHP with extensions.
50+
uses: shivammathur/setup-php@v2
51+
with:
52+
php-version: ${{ matrix.php }}
53+
coverage: none
54+
tools: composer:v2
55+
56+
- name: Update composer.
57+
run: composer self-update
58+
59+
- name: Set environment variables pull request linux.
60+
uses: yiisoft/actions/db/environment-linux@master
61+
62+
- name: Install db.
63+
uses: yiisoft/actions/db/subpackage-install@master
64+
with:
65+
BRANCH_NAME: ${{ env.BRANCH_NAME }}
66+
COMPOSER_ROOT_VERSION: ${{ env.COMPOSER_ROOT_VERSION }}
67+
CURRENT_PACKAGE: db
68+
FULL_BRANCH_NAME: ${{ env.FULL_BRANCH_NAME }}
69+
WORK_PACKAGE_URL: ${{ env.WORK_PACKAGE_URL }}
70+
71+
- name: Check dependencies.
72+
run: vendor/bin/composer-require-checker

src/Command.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use PDOException;
88
use Throwable;
9-
use Yiisoft\Db\Driver\PDO\AbstractCommandPDO;
10-
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
9+
use Yiisoft\Db\Driver\Pdo\AbstractPdoCommand;
10+
use Yiisoft\Db\Driver\Pdo\PdoConnectionInterface;
1111
use Yiisoft\Db\Exception\ConvertException;
1212
use Yiisoft\Db\Exception\Exception;
1313
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
@@ -16,7 +16,7 @@
1616
* Implements a database command that can be executed against a PDO (PHP Data Object) database connection for MSSQL
1717
* Server.
1818
*/
19-
final class Command extends AbstractCommandPDO
19+
final class Command extends AbstractPdoCommand
2020
{
2121
public function showDatabases(): array
2222
{
@@ -45,7 +45,7 @@ protected function internalExecute(string|null $rawSql): void
4545
&& $this->db->getTransaction() === null
4646
) {
4747
$this->db->transaction(
48-
fn (ConnectionPDOInterface $db) => $this->internalExecute($rawSql),
48+
fn (PdoConnectionInterface $db) => $this->internalExecute($rawSql),
4949
$this->isolationLevel
5050
);
5151
} else {

src/Connection.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Yiisoft\Db\Mssql;
66

7-
use Yiisoft\Db\Driver\PDO\AbstractConnectionPDO;
8-
use Yiisoft\Db\Driver\PDO\CommandPDOInterface;
7+
use Yiisoft\Db\Driver\Pdo\AbstractPdoConnection;
8+
use Yiisoft\Db\Driver\Pdo\PdoCommandInterface;
99
use Yiisoft\Db\Query\BatchQueryResultInterface;
1010
use Yiisoft\Db\Query\QueryInterface;
1111
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
@@ -18,14 +18,14 @@
1818
*
1919
* @link https://www.php.net/manual/en/ref.pdo-sqlsrv.php
2020
*/
21-
final class Connection extends AbstractConnectionPDO
21+
final class Connection extends AbstractPdoConnection
2222
{
2323
public function createBatchQueryResult(QueryInterface $query, bool $each = false): BatchQueryResultInterface
2424
{
2525
return new BatchQueryResult($query, $each);
2626
}
2727

28-
public function createCommand(string $sql = null, array $params = []): CommandPDOInterface
28+
public function createCommand(string $sql = null, array $params = []): PdoCommandInterface
2929
{
3030
$command = new Command($this);
3131

src/Driver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
namespace Yiisoft\Db\Mssql;
66

77
use PDO;
8-
use Yiisoft\Db\Driver\PDO\AbstractPDODriver;
8+
use Yiisoft\Db\Driver\Pdo\AbstractPdoDriver;
99

1010
/**
1111
* Implements the MSSQL Server driver based on the PDO (PHP Data Objects) extension.
1212
*
1313
* @link https://www.php.net/manual/en/ref.pdo-sqlsrv.php
1414
*/
15-
final class Driver extends AbstractPDODriver
15+
final class Driver extends AbstractPdoDriver
1616
{
1717
public function createConnection(): PDO
1818
{

src/Schema.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Yiisoft\Db\Constraint\DefaultValueConstraint;
1111
use Yiisoft\Db\Constraint\ForeignKeyConstraint;
1212
use Yiisoft\Db\Constraint\IndexConstraint;
13-
use Yiisoft\Db\Driver\PDO\PdoAbstractSchema;
13+
use Yiisoft\Db\Driver\Pdo\AbstractPdoSchema;
1414
use Yiisoft\Db\Exception\Exception;
1515
use Yiisoft\Db\Exception\InvalidConfigException;
1616
use Yiisoft\Db\Helper\DbArrayHelper;
@@ -55,7 +55,7 @@
5555
* }
5656
* >
5757
*/
58-
final class Schema extends PdoAbstractSchema
58+
final class Schema extends AbstractPdoSchema
5959
{
6060
/**
6161
* @var string|null The default schema used for the current session.

src/Transaction.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
namespace Yiisoft\Db\Mssql;
66

77
use Throwable;
8-
use Yiisoft\Db\Driver\PDO\AbstractTransactionPDO;
8+
use Yiisoft\Db\Driver\Pdo\AbstractPdoTransaction;
99
use Yiisoft\Db\Exception\Exception;
1010
use Yiisoft\Db\Exception\InvalidConfigException;
1111

1212
/**
1313
* Implements the MSSQL Server specific transaction.
1414
*/
15-
final class Transaction extends AbstractTransactionPDO
15+
final class Transaction extends AbstractPdoTransaction
1616
{
1717
/**
1818
* Creates a new savepoint.

tests/ConnectionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use PDO;
88
use Throwable;
9-
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
9+
use Yiisoft\Db\Driver\Pdo\PdoConnectionInterface;
1010
use Yiisoft\Db\Exception\Exception;
1111
use Yiisoft\Db\Exception\InvalidConfigException;
1212
use Yiisoft\Db\Exception\NotSupportedException;
@@ -59,7 +59,7 @@ public function testTransactionShortcutCustom(): void
5959
$db = $this->getConnection();
6060

6161
$result = $db->transaction(
62-
static function (ConnectionPDOInterface $db): bool {
62+
static function (PdoConnectionInterface $db): bool {
6363
$db->createCommand()->insert('profile', ['description' => 'test transaction shortcut'])->execute();
6464
return true;
6565
},

tests/CommandPDOTest.php tests/PdoCommandTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
namespace Yiisoft\Db\Mssql\Tests;
66

77
use Yiisoft\Db\Mssql\Tests\Support\TestTrait;
8-
use Yiisoft\Db\Tests\Common\CommonCommandPDOTest;
8+
use Yiisoft\Db\Tests\Common\CommonPdoCommandTest;
99

1010
/**
1111
* @group mssql
1212
*
1313
* @psalm-suppress PropertyNotSetInConstructor
1414
*/
15-
final class CommandPDOTest extends CommonCommandPDOTest
15+
final class PdoCommandTest extends CommonPdoCommandTest
1616
{
1717
use TestTrait;
1818

tests/ConnectionPDOTest.php tests/PdoConnectionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
use Yiisoft\Db\Exception\InvalidConfigException;
1111
use Yiisoft\Db\Expression\Expression;
1212
use Yiisoft\Db\Mssql\Tests\Support\TestTrait;
13-
use Yiisoft\Db\Tests\Common\CommonConnectionPDOTest;
13+
use Yiisoft\Db\Tests\Common\CommonPdoConnectionTest;
1414

1515
/**
1616
* @group mssql
1717
*
1818
* @psalm-suppress PropertyNotSetInConstructor
1919
*/
20-
final class ConnectionPDOTest extends CommonConnectionPDOTest
20+
final class PdoConnectionTest extends CommonPdoConnectionTest
2121
{
2222
use TestTrait;
2323

tests/SchemaTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Throwable;
88
use Yiisoft\Db\Command\CommandInterface;
99
use Yiisoft\Db\Connection\ConnectionInterface;
10-
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
10+
use Yiisoft\Db\Driver\Pdo\PdoConnectionInterface;
1111
use Yiisoft\Db\Exception\Exception;
1212
use Yiisoft\Db\Exception\InvalidConfigException;
1313
use Yiisoft\Db\Exception\NotSupportedException;
@@ -134,7 +134,7 @@ public function testTableSchemaWithDbSchemes(string $tableName, string $expected
134134

135135
$commandMock = $this->createMock(CommandInterface::class);
136136
$commandMock->method('queryAll')->willReturn([]);
137-
$mockDb = $this->createMock(ConnectionPDOInterface::class);
137+
$mockDb = $this->createMock(PdoConnectionInterface::class);
138138
$mockDb->method('getQuoter')->willReturn($db->getQuoter());
139139
$mockDb
140140
->method('createCommand')

tests/Support/TestTrait.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Yiisoft\Db\Mssql\Tests\Support;
66

7-
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
7+
use Yiisoft\Db\Driver\Pdo\PdoConnectionInterface;
88
use Yiisoft\Db\Exception\Exception;
99
use Yiisoft\Db\Exception\InvalidConfigException;
1010
use Yiisoft\Db\Mssql\Connection;
@@ -21,7 +21,7 @@ trait TestTrait
2121
* @throws Exception
2222
* @throws InvalidConfigException
2323
*/
24-
protected function getConnection(bool $fixture = false): ConnectionPDOInterface
24+
protected function getConnection(bool $fixture = false): PdoConnectionInterface
2525
{
2626
$db = new Connection(
2727
new Driver($this->getDsn(), 'SA', 'YourStrong!Passw0rd'),
@@ -35,7 +35,7 @@ protected function getConnection(bool $fixture = false): ConnectionPDOInterface
3535
return $db;
3636
}
3737

38-
protected static function getDb(): ConnectionPDOInterface
38+
protected static function getDb(): PdoConnectionInterface
3939
{
4040
$dsn = (new Dsn('sqlsrv', 'localhost', 'yiitest'))->asString();
4141

0 commit comments

Comments
 (0)