Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 3.9.x into 4.2.x #6695

Merged
merged 5 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ on:
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.3.0"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.1.0"
with:
composer-options: "--ignore-platform-req=php+"
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ on:
jobs:
documentation:
name: "Documentation"
uses: "doctrine/.github/.github/workflows/documentation.yml@5.3.0"
uses: "doctrine/.github/.github/workflows/documentation.yml@7.1.0"
4 changes: 3 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.3"
- "8.4"

steps:
- name: "Checkout code"
Expand All @@ -49,6 +49,8 @@ jobs:

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan --error-format=checkstyle | cs2pr"
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"doctrine/coding-standard": "12.0.0",
"fig/log-test": "^1",
"jetbrains/phpstorm-stubs": "2023.2",
"phpstan/phpstan": "1.12.6",
"phpstan/phpstan-phpunit": "1.4.2",
"phpstan/phpstan-strict-rules": "^1.6",
"phpstan/phpstan": "2.1.1",
"phpstan/phpstan-phpunit": "2.0.3",
"phpstan/phpstan-strict-rules": "^2",
"phpunit/phpunit": "10.5.39",
"psalm/plugin-phpunit": "0.19.0",
"slevomat/coding-standard": "8.13.1",
Expand Down
91 changes: 91 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
parameters:
ignoreErrors:
-
message: '#^Method Doctrine\\DBAL\\Driver\\IBMDB2\\Connection\:\:exec\(\) never returns numeric\-string so it can be removed from the return type\.$#'
identifier: return.unusedType
count: 1
path: src/Driver/IBMDB2/Connection.php

-
message: '#^Method Doctrine\\DBAL\\Driver\\OCI8\\Connection\:\:exec\(\) never returns numeric\-string so it can be removed from the return type\.$#'
identifier: return.unusedType
count: 1
path: src/Driver/OCI8/Connection.php

-
message: '#^Method Doctrine\\DBAL\\Driver\\OCI8\\Result\:\:fetchAllAssociative\(\) should return list\<array\<string, mixed\>\> but returns array\<mixed\>\.$#'
identifier: return.type
count: 1
path: src/Driver/OCI8/Result.php

-
message: '#^Method Doctrine\\DBAL\\Driver\\OCI8\\Result\:\:fetchAllNumeric\(\) should return list\<list\<mixed\>\> but returns array\<mixed\>\.$#'
identifier: return.type
count: 1
path: src/Driver/OCI8/Result.php

-
message: '#^Method Doctrine\\DBAL\\Driver\\PDO\\Result\:\:fetchAll\(\) should return list\<mixed\> but returns array\.$#'
identifier: return.type
count: 1
path: src/Driver/PDO/Result.php

-
message: '#^Method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:fetchAllAssociative\(\) should return list\<array\<string, mixed\>\> but returns array\<int, array\<string, mixed\>\>\.$#'
identifier: return.type
count: 1
path: src/Driver/PgSQL/Result.php

-
message: '#^Method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:fetchAllNumeric\(\) should return list\<list\<mixed\>\> but returns array\<int, list\<mixed\>\>\.$#'
identifier: return.type
count: 1
path: src/Driver/PgSQL/Result.php

-
message: '#^Method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:fetchFirstColumn\(\) should return list\<mixed\> but returns array\<int, bool\|float\|int\|string\|null\>\.$#'
identifier: return.type
count: 1
path: src/Driver/PgSQL/Result.php

-
message: '#^Method Doctrine\\DBAL\\Driver\\SQLite3\\Result\:\:fetchNumeric\(\) should return list\<mixed\>\|false but returns array\|false\.$#'
identifier: return.type
count: 1
path: src/Driver/SQLite3/Result.php

-
message: '#^Template type T is declared as covariant, but occurs in invariant position in property Doctrine\\DBAL\\Schema\\AbstractSchemaManager\:\:\$platform\.$#'
identifier: generics.variance
count: 1
path: src/Schema/AbstractSchemaManager.php

-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
identifier: notEqual.notAllowed
count: 1
path: src/Schema/ColumnDiff.php

-
message: '#^Method Doctrine\\DBAL\\Schema\\SQLiteSchemaManager\:\:addDetailsToTableForeignKeyColumns\(\) should return list\<array\<string, mixed\>\> but returns array\<int\<0, max\>, array\<string, mixed\>\>\.$#'
identifier: return.type
count: 1
path: src/Schema/SQLiteSchemaManager.php

-
message: '#^Offset string might not exist on array\{application_name\?\: string, charset\?\: string, dbname\?\: string, defaultTableOptions\?\: array\<string, mixed\>, driver\?\: ''ibm_db2''\|''mysqli''\|''oci8''\|''pdo_mysql''\|''pdo_oci''\|''pdo_pgsql''\|''pdo_sqlite''\|''pdo_sqlsrv''\|''pgsql''\|''sqlite3''\|''sqlsrv'', driverClass\?\: class\-string\<Doctrine\\DBAL\\Driver\>, driverOptions\?\: array\<mixed\>, host\?\: string, \.\.\.\}\.$#'
identifier: offsetAccess.notFound
count: 1
path: tests/DriverManagerTest.php

-
message: '#^Call to new Doctrine\\DBAL\\Driver\\PgSQL\\Result\(\) on a separate line has no effect\.$#'
identifier: new.resultUnused
count: 1
path: tests/Functional/Driver/PgSQL/ResultTest.php

-
message: '#^Call to function array_filter\(\) requires parameter \#2 to be passed to avoid loose comparison semantics\.$#'
identifier: arrayFilter.strict
count: 1
path: tests/Functional/Schema/MySQL/JsonCollationTest.php
18 changes: 16 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parameters:
level: 8
phpVersion: 80300
phpVersion: 80402
paths:
- src
- static-analysis
Expand Down Expand Up @@ -85,7 +85,7 @@ parameters:

# PHPStan does not understand the array shapes returned by pg_fetch_*() methods.
- '~^Parameter #1 \$row of method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:mapAssociativeRow\(\) expects array<string, string\|null>, array<int\|string, string\|null> given\.$~'
- '~^Parameter #1 \$row of method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:mapNumericRow\(\) expects array<int, string\|null>, array<int\|string, string\|null> given\.$~'
- '~^Parameter #1 \$row of method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:mapNumericRow\(\) expects list<string\|null>, .* given\.$~'

# https://github.com/phpstan/phpstan-src/pull/2224
-
Expand All @@ -112,14 +112,28 @@ parameters:
message: '#^Parameter \#2 \$callback of function array_reduce expects callable\(\(callable&TIn\)\|Closure\(mixed \$value\)\: mixed\|null, callable\(T\)\: T\)\: \(\(callable&TIn\)\|Closure\(mixed \$value\)\: mixed\|null\), Closure\(callable\|null, callable\)\: \(callable\(T\)\: T\) given\.$#'
path: src/Portability/Converter.php

# The @throws annotations are part of a contract. Even if the default implementation doen't throw those
# exceptions, the child implementations might do so.
-
identifier: throws.unusedType
path: src/Types/Type.php

# We don't narrow the return type of lastInsertId() yet.
- '/^Method Doctrine\\DBAL\\Driver\\.+\\Connection\:\:lastInsertId\(\) never returns (int|false) so it can be removed from the return type\.$/'

# Type check for legacy implementations of the Result interface
# TODO: remove in 5.0.0
- '~^Call to function method_exists\(\) with Doctrine\\DBAL\\Driver\\Result and ''getColumnName'' will always evaluate to true\.$~'

# PHPStan does not know the new PDO classes yet.
- '~^Class Pdo\\\w+ not found\.$~'
- '~^Call to an undefined static method PDO\:\:connect\(\)\.$~'

# TODO: Review these errors and fix them.
- identifier: phpunit.assertEquals
includes:
- phpstan-baseline.neon
- phar://phpstan.phar/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
6 changes: 3 additions & 3 deletions src/SQL/Builder/CreateSchemaObjectsSQLBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function buildSQL(Schema $schema): array
}

/**
* @param list<string> $namespaces
* @param string[] $namespaces
*
* @return list<string>
*/
Expand All @@ -46,7 +46,7 @@ private function buildNamespaceStatements(array $namespaces): array
}

/**
* @param list<Table> $tables
* @param Table[] $tables
*
* @return list<string>
*/
Expand All @@ -56,7 +56,7 @@ private function buildTableStatements(array $tables): array
}

/**
* @param list<Sequence> $sequences
* @param Sequence[] $sequences
*
* @return list<string>
*/
Expand Down