Skip to content

Commit

Permalink
Merge branch '4.2.x' into 4.3.x
Browse files Browse the repository at this point in the history
* 4.2.x:
  Cleanup obsolete PHPStan ignore rules (doctrine#6697)
  PHPStan 2.1.1 (doctrine#6690)
  PHPUnit 10.5.39 (doctrine#6692)
  PHPUnit 9.6.22 (doctrine#6691)
  Bump doctrine/.github from 6.0.0 to 7.1.0 (doctrine#6649)
  Bump doctrine/.github from 5.3.0 to 6.0.0 (doctrine#6642)
  • Loading branch information
derrabus committed Jan 6, 2025
2 parents eea8aaf + 8725a81 commit fc9c98d
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 40 deletions.
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"
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"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.0",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "10.5.30",
"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",
"squizlabs/php_codesniffer": "3.10.2",
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
44 changes: 13 additions & 31 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 @@ -67,12 +67,6 @@ parameters:
message: '~^Parameter #1 \$params of method Doctrine\\DBAL\\Driver\:\:connect\(\) expects array~'
path: tests/Driver/PDO/*/DriverTest.php

# DriverManagerTest::testDatabaseUrl() should be refactored as it's too dynamic.
-
message: '~^Offset string does not exist on array{.+}\.$~'
paths:
- tests/DriverManagerTest.php

# There is no way to make this assertion in the code,
# and the API doesn't support parametrization of returned column types.
-
Expand All @@ -85,41 +79,29 @@ 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\.$~'

# https://github.com/phpstan/phpstan-src/pull/2224
-
message: '~^Method Doctrine\\DBAL\\Driver\\Mysqli\\Connection\:\:exec\(\) should return int\|numeric\-string but returns int\|string\.$~'
count: 1
path: src/Driver/Mysqli/Connection.php

# https://github.com/phpstan/phpstan/issues/9429
-
message: '~^Strict comparison using === between int<0, max> and false will always evaluate to false.$~'
paths:
- src/Driver/IBMDB2/Connection.php
- src/Driver/IBMDB2/Result.php

# Ignore the possible false return value of db2_num_rows().
- '~^Method Doctrine\\DBAL\\Driver\\IBMDB2\\Connection\:\:exec\(\) should return int but returns int<0, max>\|false\.$~'
- '~^Method Doctrine\\DBAL\\Driver\\IBMDB2\\Result\:\:rowCount\(\) should return int but returns int<0, max>\|false\.$~'
- '~^Parameter #1 \$row of method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:mapNumericRow\(\) expects list<string\|null>, .* given\.$~'

# Required for Psalm compatibility
- '~^Property Doctrine\\DBAL\\Tests\\Types\\BaseDateTypeTestCase\:\:\$currentTimezone \(non-empty-string\) does not accept string\.$~'

# This is a rather complicated closure setup. We understand this, so PHPStan doesn't have to.
# The @throws annotations are part of a contract. Even if the default implementation doen't throw those
# exceptions, the child implementations might do so.
-
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
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

0 comments on commit fc9c98d

Please sign in to comment.