Skip to content

Commit c2207d4

Browse files
Remove src\TestSupport\TestCommandTrait::class from yiisoft/db. (#141)
* Remove src\TestSupport\TestCommandTrait::class from yiisoft/db.
1 parent e25a0b9 commit c2207d4

18 files changed

Lines changed: 593 additions & 310 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
/.gitignore export-ignore
2929
/.scrutinizer.yml export-ignore
3030
/phpunit.xml.dist export-ignore
31+
/tests export-ignore
3132
/docs export-ignore
3233

3334
# Avoid merge conflicts in CHANGELOG

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
phpunit:
2626
uses: yiisoft/actions/.github/workflows/phpunit.yml@master
2727
with:
28+
composer-command: composer config preferred-install.yiisoft/db source && composer update --no-interaction --no-progress --optimize-autoloader --ansi
2829
extensions: pdo, pdo_sqlite
2930
os: >-
3031
['ubuntu-latest', 'windows-latest']

.github/workflows/mutation.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
mutation:
2424
uses: yiisoft/actions/.github/workflows/roave-infection.yml@master
2525
with:
26+
composer-command: composer config preferred-install.yiisoft/db source && composer update --no-interaction --no-progress --optimize-autoloader --ansi
2627
os: >-
2728
['ubuntu-latest']
2829
php: >-

.scrutinizer.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ build:
2929
- export PATH="/usr/local/lib:$PATH"
3030
- sqlite3 --version && cd ..
3131
- composer self-update
32-
- composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
32+
- composer config preferred-install.yiisoft/db source
33+
- composer update --no-interaction --no-progress --optimize-autoloader --ansi
3334

3435
tests:
3536
override:

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ It is used in [Yii Framework] but is supposed to be usable separately.
1919
[![Latest Stable Version](https://poser.pugx.org/yiisoft/db-sqlite/v/stable.png)](https://packagist.org/packages/yiisoft/db-sqlite)
2020
[![Total Downloads](https://poser.pugx.org/yiisoft/db-sqlite/downloads.png)](https://packagist.org/packages/yiisoft/db-sqlite)
2121
[![rector](https://github.com/yiisoft/db-sqlite/actions/workflows/rector.yml/badge.svg)](https://github.com/yiisoft/db-sqlite/actions/workflows/rector.yml)
22-
[![codecov](https://codecov.io/gh/yiisoft/db-sqlite/branch/dev/graph/badge.svg?token=YXUHCPPITH)](https://codecov.io/gh/yiisoft/db-sqlite)
22+
[![codecov](https://codecov.io/gh/yiisoft/db-sqlite/branch/master/graph/badge.svg?token=YXUHCPPITH)](https://codecov.io/gh/yiisoft/db-sqlite)
2323
[![StyleCI](https://github.styleci.io/repos/145220194/shield?branch=master)](https://github.styleci.io/repos/145220194?branch=master)
2424

2525

@@ -46,11 +46,11 @@ Di-Container:
4646

4747
```php
4848
use Yiisoft\Db\Connection\ConnectionInterface;
49-
use Yiisoft\Db\Sqlite\Connection as SqliteConnection;
49+
use Yiisoft\Db\Sqlite\ConnectionPDO;
5050

5151
return [
5252
ConnectionInterface::class => [
53-
'class' => SqliteConnection::class,
53+
'class' => ConnectionPDO::class,
5454
'__construct()' => [
5555
'dsn' => $params['yiisoft/db-sqlite']['dsn'],
5656
]
@@ -101,6 +101,16 @@ use either newest or any specific version of PHP:
101101
./vendor/bin/rector
102102
```
103103

104+
### Composer require checker
105+
106+
This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all dependencies are correctly defined in `composer.json`.
107+
108+
To run the checker, execute the following command:
109+
110+
```shell
111+
./vendor/bin/composer-require-checker
112+
```
113+
104114
### Support the project
105115

106116
[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective&logoColor=7eadf1&labelColor=555555)](https://opencollective.com/yiisoft)

composer.dev.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"autoload-dev": {
3+
"psr-4": {
4+
"Yiisoft\\Db\\Tests\\": "vendor/yiisoft/db/tests"
5+
}
6+
}
7+
}

composer.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"roave/infection-static-analysis-plugin": "^1.16",
3535
"spatie/phpunit-watcher": "^1.23",
3636
"vimeo/psalm": "^4.18",
37+
"wikimedia/composer-merge-plugin": "^2.0",
3738
"yiisoft/aliases": "^2.0",
3839
"yiisoft/json": "^1.0"
3940
},
@@ -50,14 +51,21 @@
5051
"extra": {
5152
"branch-alias": {
5253
"dev-master": "3.0.x-dev"
54+
},
55+
"merge-plugin": {
56+
"include": [
57+
"composer.dev.json"
58+
],
59+
"merge-dev": true
5360
}
5461
},
5562
"config": {
56-
"sort-packages": true,
5763
"allow-plugins": {
5864
"infection/extension-installer": true,
59-
"composer/package-versions-deprecated": true
60-
}
65+
"composer/package-versions-deprecated": true,
66+
"wikimedia/composer-merge-plugin": true
67+
},
68+
"sort-packages": true
6169
},
6270
"scripts": {
6371
"test": "phpunit --testdox --no-interaction",

phpunit.xml.dist

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit backupGlobals="false"
4-
colors="true"
5-
verbose="true"
6-
bootstrap="vendor/autoload.php"
7-
failOnRisky="true"
8-
failOnWarning="true"
9-
executionOrder="default"
10-
resolveDependencies="true">
3+
<phpunit
4+
backupGlobals="false"
5+
colors="true"
6+
verbose="true"
7+
bootstrap="vendor/autoload.php"
8+
failOnRisky="true"
9+
failOnWarning="true"
10+
executionOrder="default"
11+
resolveDependencies="true"
12+
>
1113

1214
<coverage>
1315
<include>

src/CommandPDO.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
use PDOException;
88
use Throwable;
99
use Yiisoft\Db\Driver\PDO\CommandPDO as AbstractCommandPDO;
10+
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
1011
use Yiisoft\Db\Exception\ConvertException;
1112
use Yiisoft\Db\Exception\Exception;
1213
use Yiisoft\Db\Exception\InvalidArgumentException;
1314
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
14-
use Yiisoft\Db\Schema\SchemaInterface;
1515
use Yiisoft\Strings\StringHelper;
1616

1717
use function array_pop;
@@ -45,7 +45,7 @@ public function insertEx(string $table, array $columns): bool|array
4545
continue;
4646
}
4747

48-
/** @var mixed */
48+
/** @psalm-var mixed */
4949
$result[$name] = $columns[$name] ?? $tableSchema?->getColumn($name)?->getDefaultValue();
5050
}
5151

@@ -57,11 +57,6 @@ public function queryBuilder(): QueryBuilderInterface
5757
return $this->db->getQueryBuilder();
5858
}
5959

60-
public function schema(): SchemaInterface
61-
{
62-
return $this->db->getSchema();
63-
}
64-
6560
/**
6661
* Executes the SQL statement.
6762
*
@@ -76,7 +71,7 @@ public function execute(): int
7671
{
7772
$sql = $this->getSql();
7873

79-
/** @var array<string, string> */
74+
/** @psalm-var array<string, string> $params */
8075
$params = $this->params;
8176

8277
$statements = $this->splitStatements($sql, $params);
@@ -101,6 +96,11 @@ public function execute(): int
10196
return $result;
10297
}
10398

99+
/**
100+
* @psalm-suppress UnusedClosureParam
101+
*
102+
* @throws Throwable
103+
*/
104104
protected function internalExecute(string|null $rawSql): void
105105
{
106106
$attempt = 0;
@@ -113,7 +113,7 @@ protected function internalExecute(string|null $rawSql): void
113113
&& $this->db->getTransaction() === null
114114
) {
115115
$this->db->transaction(
116-
fn (string|null $rawSql) => $this->internalExecute($rawSql),
116+
fn (ConnectionPDOInterface $db) => $this->internalExecute($rawSql),
117117
$this->isolationLevel,
118118
);
119119
} else {
@@ -144,7 +144,7 @@ protected function queryInternal(int $queryMode): mixed
144144
{
145145
$sql = $this->getSql();
146146

147-
/** @var array<string, string> */
147+
/** @psalm-var array<string, string> $params */
148148
$params = $this->params;
149149

150150
$statements = $this->splitStatements($sql, $params);
@@ -170,7 +170,7 @@ protected function queryInternal(int $queryMode): mixed
170170

171171
$this->setSql($lastStatementSql)->bindValues($lastStatementParams);
172172

173-
/** @var string */
173+
/** @psalm-var string $result */
174174
$result = parent::queryInternal($queryMode);
175175

176176
$this->setSql($sql)->bindValues($params);

src/DDLQueryBuilder.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public function addCommentOnTable(string $table, string $comment): string
4949
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
5050
}
5151

52+
/**
53+
* @throws NotSupportedException
54+
*/
55+
public function addDefaultValue(string $name, string $table, string $column, mixed $value): string
56+
{
57+
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
58+
}
59+
5260
/**
5361
* @throws NotSupportedException
5462
*/
@@ -149,6 +157,14 @@ public function dropCommentFromTable(string $table): string
149157
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
150158
}
151159

160+
/**
161+
* @throws NotSupportedException
162+
*/
163+
public function dropDefaultValue(string $name, string $table): string
164+
{
165+
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
166+
}
167+
152168
/**
153169
* @throws NotSupportedException
154170
*/

0 commit comments

Comments
 (0)