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 3.10.x #6694

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
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ 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"
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 @@ -43,9 +43,9 @@
"doctrine/coding-standard": "12.0.0",
"fig/log-test": "^1",
"jetbrains/phpstorm-stubs": "2023.1",
"phpstan/phpstan": "1.12.6",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "9.6.20",
"phpstan/phpstan": "2.1.1",
"phpstan/phpstan-strict-rules": "^2",
"phpunit/phpunit": "9.6.22",
"psalm/plugin-phpunit": "0.18.4",
"slevomat/coding-standard": "8.13.1",
"squizlabs/php_codesniffer": "3.10.2",
Expand Down
181 changes: 181 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
parameters:
ignoreErrors:
-
message: '#^@readonly property cannot have a default value\.$#'
identifier: property.readOnlyByPhpDocDefaultValue
count: 1
path: src/Driver/AbstractException.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: '#^@readonly property Doctrine\\DBAL\\Driver\\PDO\\PDOException\:\:\$sqlState is assigned outside of the constructor\.$#'
identifier: property.readOnlyByPhpDocAssignNotInConstructor
count: 1
path: src/Driver/PDO/PDOException.php

-
message: '#^@readonly property cannot have a default value\.$#'
identifier: property.readOnlyByPhpDocDefaultValue
count: 1
path: src/Driver/PDO/PDOException.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: '#^Method Doctrine\\DBAL\\Platforms\\AbstractMySQLPlatform\:\:getAlterTableSQL\(\) should return list\<string\> but returns array\<mixed\>\.$#'
identifier: return.type
count: 1
path: src/Platforms/AbstractMySQLPlatform.php

-
message: '#^Parameter \#1 \$assets of method Doctrine\\DBAL\\Platforms\\AbstractMySQLPlatform\:\:indexAssetsByLowerCaseName\(\) expects list\<Doctrine\\DBAL\\Schema\\Index\>, array\<Doctrine\\DBAL\\Schema\\Index\> given\.$#'
identifier: argument.type
count: 1
path: src/Platforms/AbstractMySQLPlatform.php

-
message: '#^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform\:\:buildCreateTableSQL\(\) should return list\<string\> but returns array\<string\>\.$#'
identifier: return.type
count: 2
path: src/Platforms/AbstractPlatform.php

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

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

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

-
message: '#^Method Doctrine\\DBAL\\Platforms\\SQLServerPlatform\:\:getAlterTableSQL\(\) should return list\<string\> but returns array\<mixed\>\.$#'
identifier: return.type
count: 2
path: src/Platforms/SQLServerPlatform.php

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

-
message: '#^Method Doctrine\\DBAL\\Platforms\\SqlitePlatform\:\:getAlterTableSQL\(\) should return list\<string\> but returns array\<string\>\.$#'
identifier: return.type
count: 1
path: src/Platforms/SqlitePlatform.php

-
message: '#^Parameter &\$knownAliases by\-ref type of method Doctrine\\DBAL\\Query\\QueryBuilder\:\:getSQLForJoins\(\) expects array\<string, true\>, non\-empty\-array\<true\> given\.$#'
identifier: parameterByRef.type
count: 1
path: src/Query/QueryBuilder.php

-
message: '#^Property Doctrine\\DBAL\\Query\\QueryBuilder\:\:\$params \(array\<int\<0, max\>\|string, mixed\>\) does not accept non\-empty\-array\<int\|string, mixed\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Query/QueryBuilder.php

-
message: '#^Parameter \#1 \$sequences of method Doctrine\\DBAL\\SQL\\Builder\\DropSchemaObjectsSQLBuilder\:\:buildSequenceStatements\(\) expects list\<Doctrine\\DBAL\\Schema\\Sequence\>, array\<Doctrine\\DBAL\\Schema\\Sequence\> given\.$#'
identifier: argument.type
count: 1
path: src/SQL/Builder/DropSchemaObjectsSQLBuilder.php

-
message: '#^Parameter \#1 \$tables of method Doctrine\\DBAL\\SQL\\Builder\\DropSchemaObjectsSQLBuilder\:\:buildTableStatements\(\) expects list\<Doctrine\\DBAL\\Schema\\Table\>, array\<Doctrine\\DBAL\\Schema\\Table\> given\.$#'
identifier: argument.type
count: 1
path: src/SQL/Builder/DropSchemaObjectsSQLBuilder.php

-
message: '#^Method Doctrine\\DBAL\\Schema\\AbstractSchemaManager\:\:doListTableNames\(\) should return list\<string\> but returns array\<mixed\>\.$#'
identifier: return.type
count: 1
path: src/Schema/AbstractSchemaManager.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: '#^Parameter \#1 \$tables of method Doctrine\\DBAL\\Platforms\\AbstractPlatform\:\:getDropTablesSQL\(\) expects list\<Doctrine\\DBAL\\Schema\\Table\>, array\<Doctrine\\DBAL\\Schema\\Table\> given\.$#'
identifier: argument.type
count: 1
path: src/Schema/SchemaDiff.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: '#^Method Doctrine\\DBAL\\Schema\\TableDiff\:\:getAddedForeignKeys\(\) should return list\<Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\> but returns array\<Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\>\.$#'
identifier: return.type
count: 1
path: src/Schema/TableDiff.php

-
message: '#^Method Doctrine\\DBAL\\Schema\\TableDiff\:\:getDroppedForeignKeys\(\) should return list\<Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\|string\> but returns array\<Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\|string\>\.$#'
identifier: return.type
count: 1
path: src/Schema/TableDiff.php

-
message: '#^Method Doctrine\\DBAL\\Schema\\TableDiff\:\:getModifiedForeignKeys\(\) should return list\<Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\> but returns array\<Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\>\.$#'
identifier: return.type
count: 1
path: src/Schema/TableDiff.php
22 changes: 16 additions & 6 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 All @@ -9,10 +9,6 @@ parameters:
ignoreErrors:
- identifier: missingType.generics

# https://github.com/doctrine/dbal/pull/3836
# TODO: remove in 4.0.0
- '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int\|string> given\.\z~'

# some drivers actually do accept 2nd parameter...
- '~^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getListTableForeignKeysSQL\(\) invoked with \d+ parameters, 1 required\.\z~'

Expand Down Expand Up @@ -131,7 +127,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\.$~'

# Ignore isset() checks in destructors.
- '~^Property Doctrine\\DBAL\\Driver\\PgSQL\\Connection\:\:\$connection \(PgSql\\Connection\|resource\) in isset\(\) is not nullable\.$~'
Expand All @@ -152,5 +148,19 @@ 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\.$/'

# Unnecessarily strict type narrowing
- '~^Method Doctrine\\DBAL\\Driver\\PDO\\ParameterTypeMap\:\:convertParamType\(\) never returns \d+ so it can be removed from the return type\.$~'

includes:
- phpstan-baseline.neon
- phar://phpstan.phar/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
4 changes: 2 additions & 2 deletions src/Driver/API/OCI/ExceptionConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ final class ExceptionConverter implements ExceptionConverterInterface
/** @link http://www.dba-oracle.com/t_error_code_list.htm */
public function convert(Exception $exception, ?Query $query): DriverException
{
/** @psalm-var int|'HY000' $code */
/** @psalm-var int|'HY000' $code */ // @phpstan-ignore varTag.type
$code = $exception->getCode();
/** @psalm-suppress NoInterfaceProperties */
/** @psalm-suppress NoInterfaceProperties */ // @phpstan-ignore property.notFound, property.notFound
if ($code === 'HY000' && isset($exception->errorInfo[1], $exception->errorInfo[2])) {
$errorInfo = $exception->errorInfo;
$exception = new PDOException($errorInfo[2], $errorInfo[1]);
Expand Down
7 changes: 1 addition & 6 deletions src/Event/SchemaDropTableEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Table;
use InvalidArgumentException;

/**
* Event Arguments used when the SQL query for dropping tables are generated inside {@see AbstractPlatform}.
Expand All @@ -21,11 +20,7 @@ class SchemaDropTableEventArgs extends SchemaEventArgs
/** @var string|null */
private $sql;

/**
* @param string|Table $table
*
* @throws InvalidArgumentException
*/
/** @param string|Table $table */
public function __construct($table, AbstractPlatform $platform)
{
$this->table = $table;
Expand Down
2 changes: 1 addition & 1 deletion src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,7 @@ private function buildCreateTableSQL(Table $table, bool $createIndexes, bool $cr
}

/**
* @param list<Table> $tables
* @param Table[] $tables
*
* @return list<string>
*
Expand Down
6 changes: 3 additions & 3 deletions src/SQL/Builder/CreateSchemaObjectsSQLBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function buildSQL(Schema $schema): array
}

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

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

/**
* @param list<Sequence> $sequences
* @param Sequence[] $sequences
*
* @return list<string>
*
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ public function diffColumn(Column $column1, Column $column2)
// null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
if (
($properties1['default'] === null) !== ($properties2['default'] === null)
|| $properties1['default'] != $properties2['default']
|| $properties1['default'] != $properties2['default'] // @phpstan-ignore notEqual.notAllowed
) {
$changedProperties[] = 'default';
}
Expand Down