Skip to content

Commit

Permalink
Merge pull request #58 from artemeon/deps/symfony7-phpunit9-psalm5
Browse files Browse the repository at this point in the history
Deps/symfony7 phpunit9 psalm5
  • Loading branch information
marcreichel authored Feb 15, 2024
2 parents 1a7bee3 + c4a6bac commit 778b20e
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 48 deletions.
30 changes: 18 additions & 12 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
name: "Continuous Integration"
on:
- pull_request
- push
pull_request:
push:
branches:
- master
- 3.0.x
- 2.0.x
- 1.0.x
- 0.2.x
jobs:
phpunit-smoke-check:
name: "PHPUnit with SQLite"
runs-on: "ubuntu-20.04"
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
Expand All @@ -30,7 +36,7 @@ jobs:
run: "vendor/bin/phpunit"
# phpunit-oci8:
# name: "PHPUnit on OCI8"
# runs-on: "ubuntu-20.04"
# runs-on: ubuntu-latest
# needs: "phpunit-smoke-check"
# strategy:
# matrix:
Expand Down Expand Up @@ -75,8 +81,8 @@ jobs:
# run: "vendor/bin/phpunit"
phpunit-postgres:
name: "PHPUnit with PostgreSQL"
runs-on: "ubuntu-20.04"
needs: "phpunit-smoke-check"
runs-on: ubuntu-latest
needs: phpunit-smoke-check
strategy:
matrix:
php-version:
Expand Down Expand Up @@ -115,8 +121,8 @@ jobs:
run: "vendor/bin/phpunit"
phpunit-mariadb:
name: "PHPUnit with MariaDB"
runs-on: "ubuntu-20.04"
needs: "phpunit-smoke-check"
runs-on: ubuntu-latest
needs: phpunit-smoke-check
strategy:
matrix:
php-version:
Expand Down Expand Up @@ -159,8 +165,8 @@ jobs:
run: "vendor/bin/phpunit"
phpunit-mysql:
name: "PHPUnit with MySQL"
runs-on: "ubuntu-20.04"
needs: "phpunit-smoke-check"
runs-on: ubuntu-latest
needs: phpunit-smoke-check
strategy:
matrix:
php-version:
Expand Down Expand Up @@ -205,8 +211,8 @@ jobs:
run: "vendor/bin/phpunit"
phpunit-mssql:
name: "PHPUnit with SQL Server"
runs-on: "ubuntu-20.04"
needs: "phpunit-smoke-check"
runs-on: ubuntu-latest
needs: phpunit-smoke-check
strategy:
matrix:
php-version:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: Psalm
on:
- pull_request
- push
pull_request:
push:
branches:
- master
- 3.0.x
- 2.0.x
- 1.0.x
- 0.2.x
jobs:
psalm:
name: Psalm
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor
.idea
.phpunit.cache
.phpunit.result.cache
composer.lock
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"require": {
"php": "^8.1",
"psr/log": "^1.1",
"symfony/process": "^5.0|^6.0.0",
"symfony/process": "^5.0|^6.0|^7.0",
"symfony/polyfill-mbstring": "^1.15"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"vimeo/psalm": "^3.16"
"phpunit/phpunit": "^9.0",
"vimeo/psalm": "^5.21.1"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<psalm
errorLevel="4"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
4 changes: 2 additions & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ public function getDbInfo(): array
$this->dbconnect();
}

if (!$this->dbDriver === null) {
if (!$this->dbDriver) {
return [];
}

Expand Down Expand Up @@ -1197,7 +1197,7 @@ private function dbsafeParams(array $params, array $escapes = []): array
/**
* Makes a string db-safe.
*
* @return int|null|string
* @return int|float|null|string
* @deprecated we need to get rid of this
*/
public function dbsafeString(mixed $input, bool $htmlSpecialChars = true, bool $addSlashes = true): mixed
Expand Down
8 changes: 4 additions & 4 deletions src/Driver/MysqliDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function getPArray(string $query, array $params): Generator
return [];
}

while ($metadata && $field = $metadata->fetch_field()) {
while ($field = $metadata->fetch_field()) {
$params[] = &$row[$field->name];
}

Expand Down Expand Up @@ -266,7 +266,7 @@ public function getTableInformation(string $tableName): Table
$table = new Table($tableName);

// fetch all columns
$columnInfo = $this->getPArray("SHOW COLUMNS FROM $tableName", []) ?: [];
$columnInfo = $this->getPArray("SHOW COLUMNS FROM $tableName", []);
foreach ($columnInfo as $column) {
$table->addColumn(
TableColumn::make($column['Field'])
Expand All @@ -277,7 +277,7 @@ public function getTableInformation(string $tableName): Table
}

//fetch all indexes
$indexes = $this->getPArray("SHOW INDEX FROM $tableName WHERE Key_name != 'PRIMARY'", []) ?: [];
$indexes = $this->getPArray("SHOW INDEX FROM $tableName WHERE Key_name != 'PRIMARY'", []);
$indexAggr = [];
foreach ($indexes as $indexInfo) {
$indexAggr[$indexInfo['Key_name']] = $indexAggr[$indexInfo['Key_name']] ?? [];
Expand All @@ -290,7 +290,7 @@ public function getTableInformation(string $tableName): Table
}

//fetch all keys
$keys = $this->getPArray("SHOW KEYS FROM $tableName WHERE Key_name = 'PRIMARY'", []) ?: [];
$keys = $this->getPArray("SHOW KEYS FROM $tableName WHERE Key_name = 'PRIMARY'", []);
foreach ($keys as $keyInfo) {
$key = new TableKey($keyInfo['Column_name']);
$table->addPrimaryKey($key);
Expand Down
10 changes: 5 additions & 5 deletions src/Driver/Oci8Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function _pQuery(string $query, array $params): bool
}

foreach ($params as $pos => $value) {
if (!oci_bind_by_name($statement, ':' . ($pos + 1), $params[$pos])) {
if (!oci_bind_by_name($statement, ':' . ((int) $pos + 1), $params[$pos])) {
// echo 'oci_bind_by_name failed to bind at pos >' . $pos . "<, \n value: " . $value . "\nquery: " . $query;
return false;
}
Expand Down Expand Up @@ -300,7 +300,7 @@ public function getTableInformation(string $tableName): Table
$tableName = strtoupper($tableName);

// fetch all columns
$columnInfo = $this->getPArray('SELECT * FROM user_tab_columns WHERE table_name = ?', [$tableName]) ?: [];
$columnInfo = $this->getPArray('SELECT * FROM user_tab_columns WHERE table_name = ?', [$tableName]);
foreach ($columnInfo as $column) {
$table->addColumn(
TableColumn::make(strtolower($column['column_name']))
Expand All @@ -319,7 +319,7 @@ public function getTableInformation(string $tableName): Table
and a.table_name = ?
order by a.index_name, a.column_position',
[$tableName]
) ?: [];
);
$indexAggr = [];
foreach ($indexes as $indexInfo) {
$indexAggr[$indexInfo['index_name']] = $indexAggr[$indexInfo['index_name']] ?? [];
Expand All @@ -341,7 +341,7 @@ public function getTableInformation(string $tableName): Table
AND cons.owner = cols.owner
",
[$tableName]
) ?: [];
);
foreach ($keys as $keyInfo) {
$key = new TableKey(strtolower($keyInfo['column_name']));
$table->addPrimaryKey($key);
Expand Down Expand Up @@ -739,7 +739,7 @@ public function flushQueryCache(): void


/** @var bool caching the version parse & compare */
private static bool $is12c = false;
private static bool | null $is12c = false;

/**
* @inheritdoc
Expand Down
9 changes: 4 additions & 5 deletions src/Driver/PostgresDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function dbconnect(ConnectionParameters $params): bool
*/
public function dbclose(): void
{
if (is_resource($this->linkDB)) {
if ($this->linkDB instanceof Connection) {
pg_close($this->linkDB);
$this->linkDB = null;
}
Expand Down Expand Up @@ -214,8 +214,7 @@ public function getTableInformation(string $tableName): Table
$table = new Table($tableName);

// fetch all columns
$columnInfo = $this->getPArray('SELECT * FROM information_schema.columns WHERE table_name = ?', [$tableName]
) ?: [];
$columnInfo = $this->getPArray('SELECT * FROM information_schema.columns WHERE table_name = ?', [$tableName]);
foreach ($columnInfo as $column) {
$table->addColumn(
TableColumn::make($column['column_name'])
Expand All @@ -229,7 +228,7 @@ public function getTableInformation(string $tableName): Table
$indexes = $this->getPArray(
"select * from pg_indexes where tablename = ? AND indexname NOT LIKE '%_pkey'",
[$tableName],
) ?: [];
);
foreach ($indexes as $indexInfo) {
$index = new TableIndex($indexInfo['indexname']);
//scrape the columns from the indexdef
Expand Down Expand Up @@ -257,7 +256,7 @@ public function getTableInformation(string $tableName): Table
AND t.relname LIKE ?
ORDER BY t.relname, i.relname";

$keys = $this->getPArray($query, [$tableName]) ?: [];
$keys = $this->getPArray($query, [$tableName]);
foreach ($keys as $keyInfo) {
$key = new TableKey($keyInfo['column_name']);
$table->addPrimaryKey($key);
Expand Down
4 changes: 2 additions & 2 deletions src/Driver/Sqlite3Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public function getTableInformation(string $tableName): Table
$table = new Table($tableName);

// fetch all columns
$columnInfo = $this->getPArray("PRAGMA table_info('$tableName')", []) ?: [];
$columnInfo = $this->getPArray("PRAGMA table_info('$tableName')", []);
foreach ($columnInfo as $column) {
$table->addColumn(
TableColumn::make($column['name'])
Expand All @@ -368,7 +368,7 @@ public function getTableInformation(string $tableName): Table
}

// fetch all indexes
$indexes = $this->getPArray("SELECT * FROM sqlite_master WHERE type = 'index' AND tbl_name = ?", [$tableName]) ?: [];
$indexes = $this->getPArray("SELECT * FROM sqlite_master WHERE type = 'index' AND tbl_name = ?", [$tableName]);
foreach ($indexes as $indexInfo) {
$index = new TableIndex($indexInfo['name']);
$index->setDescription($indexInfo['sql'] ?? '');
Expand Down
8 changes: 4 additions & 4 deletions src/Driver/SqlsrvDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function getError(): string
*/
public function getTables(): array
{
$generator = $this->getPArray("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'", []) ?? [];
$generator = $this->getPArray("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'", []);
$result = [];
foreach ($generator as $row) {
$result[] = ['name' => strtolower($row['table_name'])];
Expand All @@ -159,7 +159,7 @@ public function getTableInformation(string $tableName): Table
$table = new Table($tableName);

// fetch all columns
$columnInfo = $this->getPArray('SELECT * FROM information_schema.columns WHERE table_name = ?', [$tableName]) ?: [];
$columnInfo = $this->getPArray('SELECT * FROM information_schema.columns WHERE table_name = ?', [$tableName]);
foreach ($columnInfo as $column) {
$table->addColumn(
TableColumn::make($column['column_name'])
Expand Down Expand Up @@ -190,7 +190,7 @@ public function getTableInformation(string $tableName): Table
AND t.is_ms_shipped = 0
AND t.name = ?
ORDER BY
t.name, ind.name, ind.index_id, ic.index_column_id;', [$tableName]) ?: [];
t.name, ind.name, ind.index_id, ic.index_column_id;', [$tableName]);
$indexAggr = [];
foreach ($indexes as $indexInfo) {
$indexAggr[$indexInfo['indexname']] = $indexAggr[$indexInfo['indexname']] ?? [];
Expand All @@ -208,7 +208,7 @@ public function getTableInformation(string $tableName): Table
WHERE Col.Constraint_Name = Tab.Constraint_Name
AND Col.Table_Name = Tab.Table_Name
AND Constraint_Type = 'PRIMARY KEY'
AND Col.Table_Name = ?", [$tableName]) ?: [];
AND Col.Table_Name = ?", [$tableName]);
foreach ($keys as $keyInfo) {
$key = new TableKey($keyInfo['column_name']);
$table->addPrimaryKey($key);
Expand Down
10 changes: 2 additions & 8 deletions src/Exception/ChangeColumnException.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ class ChangeColumnException extends \Exception
*/
private $newColumnName;

/**
* @var string
*/
private $newDataType;
private DataType $newDataType;

public function __construct(string $message, string $table, string $oldColumnName, string $newColumnName, DataType $newDataType, ?\Throwable $previous = null)
{
Expand Down Expand Up @@ -68,10 +65,7 @@ public function getNewColumnName(): string
return $this->newColumnName;
}

/**
* @return string
*/
public function getNewDataType(): string
public function getNewDataType(): DataType
{
return $this->newDataType;
}
Expand Down
2 changes: 1 addition & 1 deletion src/MockConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function encloseTableName($tableName): string
public function prettifyQuery($query, $params): string
{
foreach ($params as $param) {
$query = preg_replace('/\?/', isset($param) ? '"' . $param . '"' : 'NULL', $query, 1);
$query = (string) preg_replace('/\?/', isset($param) ? '"' . $param . '"' : 'NULL', $query, 1);
}

return $query;
Expand Down

0 comments on commit 778b20e

Please sign in to comment.