Skip to content

Commit 9d11fdd

Browse files
authored
Fix PHPStan and test errors after DBAL 4.4 and Symfony 7.4 releases (#12301)
* Fix PHPStan errors after DBAL 4.4 and Symfony 7.4 releases * Fix PHPStan and test errors after DBAL 4.4 and Symfony 7.4 releases
1 parent ee70178 commit 9d11fdd

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,12 +1410,6 @@ parameters:
14101410
count: 2
14111411
path: src/Mapping/Driver/DatabaseDriver.php
14121412

1413-
-
1414-
message: '#^Parameter \#1 \$asset of static method Doctrine\\ORM\\Mapping\\Driver\\DatabaseDriver\:\:getAssetName\(\) expects Doctrine\\DBAL\\Schema\\AbstractAsset, Doctrine\\DBAL\\Schema\\Column\|false given\.$#'
1415-
identifier: argument.type
1416-
count: 1
1417-
path: src/Mapping/Driver/DatabaseDriver.php
1418-
14191413
-
14201414
message: '#^Parameter \#2 \$columnName of method Doctrine\\ORM\\Mapping\\Driver\\DatabaseDriver\:\:getFieldNameForColumn\(\) expects string, string\|false given\.$#'
14211415
identifier: argument.type

phpstan-dbal3.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ parameters:
9898
identifier: argument.unresolvableType
9999
path: src/Mapping/Driver/DatabaseDriver.php
100100

101+
-
102+
message: '#^Parameter \#1 \$asset of static method Doctrine\\ORM\\Mapping\\Driver\\DatabaseDriver\:\:getAssetName\(\) expects Doctrine\\DBAL\\Schema\\AbstractAsset, Doctrine\\DBAL\\Schema\\Column\|false given\.$#'
103+
identifier: argument.type
104+
path: src/Mapping/Driver/DatabaseDriver.php
105+
106+
-
107+
message: '#^Instantiated class Doctrine\\DBAL\\Schema\\DefaultExpression\\\w+ not found\.$#'
108+
identifier: class.notFound
109+
path: src/Tools/SchemaTool.php
110+
111+
101112
# To be removed in 4.0
102113
-
103114
message: '#Negated boolean expression is always false\.#'

src/Tools/Console/ApplicationCompatibility.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ trait ApplicationCompatibility
1818
{
1919
private static function addCommandToApplication(Application $application, Command $command): Command|null
2020
{
21+
// @phpstan-ignore function.alreadyNarrowedType (This method does not exist before Symfony 7.4)
2122
if (method_exists(Application::class, 'addCommand')) {
22-
// @phpstan-ignore method.notFound (This method will be added in Symfony 7.4)
2323
return $application->addCommand($command);
2424
}
2525

26+
// @phpstan-ignore method.deprecated
2627
return $application->add($command);
2728
}
2829
}

src/Tools/SchemaTool.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,23 +505,20 @@ private function gatherColumn(
505505
], true)
506506
&& $options['default'] === $this->platform->getCurrentTimestampSQL()
507507
) {
508-
/** @phpstan-ignore class.notFound (if DefaultExpression exists, CurrentTimestamp exists as well) */
509508
$options['default'] = new CurrentTimestamp();
510509
}
511510

512511
if (
513512
in_array($mapping->type, [Types::TIME_MUTABLE, Types::TIME_IMMUTABLE], true)
514513
&& $options['default'] === $this->platform->getCurrentTimeSQL()
515514
) {
516-
/** @phpstan-ignore class.notFound (if DefaultExpression exists, CurrentTime exists as well) */
517515
$options['default'] = new CurrentTime();
518516
}
519517

520518
if (
521519
in_array($mapping->type, [Types::DATE_MUTABLE, Types::DATE_IMMUTABLE], true)
522520
&& $options['default'] === $this->platform->getCurrentDateSQL()
523521
) {
524-
/** @phpstan-ignore class.notFound (if DefaultExpression exists, CurrentDate exists as well) */
525522
$options['default'] = new CurrentDate();
526523
}
527524
}
@@ -1046,7 +1043,7 @@ private function getAssetName(AbstractAsset $asset): string
10461043
{
10471044
return $asset instanceof NamedObject
10481045
? $asset->getObjectName()->toString()
1049-
// DBAL < 4.4
1046+
// @phpstan-ignore method.deprecated (DBAL < 4.4)
10501047
: $asset->getName();
10511048
}
10521049
}

tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ public function testGetCreateSchemaSql3(): void
142142
self::equalTo('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'),
143143
// DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864)
144144
self::equalTo('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'),
145+
// DBAL 4.4 (see https://github.com/doctrine/dbal/pull/7221)
146+
self::equalTo('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'),
145147
));
146148
}
147149

0 commit comments

Comments
 (0)