From 7d9d2dc22f55fd43333da04d001785269cbf024b Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Mon, 24 Jun 2024 17:12:21 +0200 Subject: [PATCH 1/3] Introduce DoctrineTypeDriverAwareDescriptor --- extension.neon | 6 + phpstan.neon | 5 + src/Doctrine/Driver/DriverType.php | 167 ++++++++++++++++++ src/Type/Doctrine/Descriptors/BooleanType.php | 36 +++- src/Type/Doctrine/Descriptors/DecimalType.php | 37 +++- .../Descriptors/DoctrineTypeDescriptor.php | 13 ++ .../DoctrineTypeDriverAwareDescriptor.php | 29 +++ src/Type/Doctrine/Descriptors/FloatType.php | 40 ++++- .../Doctrine/ORM/EntityColumnRuleTest.php | 2 +- 9 files changed, 331 insertions(+), 4 deletions(-) create mode 100644 src/Doctrine/Driver/DriverType.php create mode 100644 src/Type/Doctrine/Descriptors/DoctrineTypeDriverAwareDescriptor.php diff --git a/extension.neon b/extension.neon index 0c798f8f..6f765baf 100644 --- a/extension.neon +++ b/extension.neon @@ -317,6 +317,8 @@ services: - class: PHPStan\Type\Doctrine\Descriptors\BooleanType tags: [phpstan.doctrine.typeDescriptor] + arguments: + bleedingEdge: %featureToggles.bleedingEdge% - class: PHPStan\Type\Doctrine\Descriptors\DateImmutableType tags: [phpstan.doctrine.typeDescriptor] @@ -341,9 +343,13 @@ services: - class: PHPStan\Type\Doctrine\Descriptors\DecimalType tags: [phpstan.doctrine.typeDescriptor] + arguments: + bleedingEdge: %featureToggles.bleedingEdge% - class: PHPStan\Type\Doctrine\Descriptors\FloatType tags: [phpstan.doctrine.typeDescriptor] + arguments: + bleedingEdge: %featureToggles.bleedingEdge% - class: PHPStan\Type\Doctrine\Descriptors\GuidType tags: [phpstan.doctrine.typeDescriptor] diff --git a/phpstan.neon b/phpstan.neon index 8dfe69fa..4ad634bd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -49,3 +49,8 @@ parameters: - '#^Cannot call method getWrappedResourceHandle\(\) on class\-string\|object\.$#' path: tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php reportUnmatched: false + + - + message: '#^Call to function method_exists\(\) with Doctrine\\DBAL\\Connection and ''getNativeConnection'' will always evaluate to true\.$#' # needed for older DBAL versions + paths: + - src/Doctrine/Driver/DriverType.php diff --git a/src/Doctrine/Driver/DriverType.php b/src/Doctrine/Driver/DriverType.php new file mode 100644 index 00000000..00d97818 --- /dev/null +++ b/src/Doctrine/Driver/DriverType.php @@ -0,0 +1,167 @@ +getDriver(); + + if ($driver instanceof MysqliDriver) { + return self::MYSQLI; + } + + if ($driver instanceof PdoMysqlDriver) { + return self::PDO_MYSQL; + } + + if ($driver instanceof PdoSQLiteDriver) { + return self::PDO_SQLITE; + } + + if ($driver instanceof PdoSqlSrvDriver) { + return self::PDO_SQLSRV; + } + + if ($driver instanceof PdoOciDriver) { + return self::PDO_OCI; + } + + if ($driver instanceof PdoPgSQLDriver) { + return self::PDO_PGSQL; + } + + if ($driver instanceof SQLite3Driver) { + return self::SQLITE3; + } + + if ($driver instanceof PgSQLDriver) { + return self::PGSQL; + } + + if ($driver instanceof SqlSrvDriver) { + return self::SQLSRV; + } + + if ($driver instanceof Oci8Driver) { + return self::OCI8; + } + + if ($driver instanceof IbmDb2Driver) { + return self::IBM_DB2; + } + + // fallback to connection-based detection when driver is wrapped by middleware + + if (!method_exists($connection, 'getNativeConnection')) { + return null; // dbal < 3.3 (released in 2022-01) + } + + try { + $nativeConnection = $connection->getNativeConnection(); + } catch (Throwable $e) { + if ($failOnInvalidConnection) { + throw $e; + } + return null; // connection cannot be established + } + + if ($nativeConnection instanceof mysqli) { + return self::MYSQLI; + } + + if ($nativeConnection instanceof SQLite3) { + return self::SQLITE3; + } + + if ($nativeConnection instanceof \PgSql\Connection) { + return self::PGSQL; + } + + if ($nativeConnection instanceof PDO) { + $driverName = $nativeConnection->getAttribute(PDO::ATTR_DRIVER_NAME); + + if ($driverName === 'mysql') { + return self::PDO_MYSQL; + } + + if ($driverName === 'sqlite') { + return self::PDO_SQLITE; + } + + if ($driverName === 'pgsql') { + return self::PDO_PGSQL; + } + + if ($driverName === 'oci') { // semi-verified (https://stackoverflow.com/questions/10090709/get-current-pdo-driver-from-existing-connection/10090754#comment12923198_10090754) + return self::PDO_OCI; + } + + if ($driverName === 'sqlsrv') { + return self::PDO_SQLSRV; + } + } + + if (is_resource($nativeConnection)) { + $resourceType = get_resource_type($nativeConnection); + + if (strpos($resourceType, 'oci') !== false) { // not verified + return self::OCI8; + } + + if (strpos($resourceType, 'db2') !== false) { // not verified + return self::IBM_DB2; + } + + if (strpos($resourceType, 'SQL Server Connection') !== false) { + return self::SQLSRV; + } + + if (strpos($resourceType, 'pgsql link') !== false) { + return self::PGSQL; + } + } + + return null; + } + +} diff --git a/src/Type/Doctrine/Descriptors/BooleanType.php b/src/Type/Doctrine/Descriptors/BooleanType.php index 955883a8..70b719f6 100644 --- a/src/Type/Doctrine/Descriptors/BooleanType.php +++ b/src/Type/Doctrine/Descriptors/BooleanType.php @@ -2,13 +2,23 @@ namespace PHPStan\Type\Doctrine\Descriptors; +use Doctrine\DBAL\Connection; +use PHPStan\Doctrine\Driver\DriverType; use PHPStan\Type\Constant\ConstantIntegerType; use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; -class BooleanType implements DoctrineTypeDescriptor +class BooleanType implements DoctrineTypeDescriptor, DoctrineTypeDriverAwareDescriptor { + /** @var bool */ + private $bleedingEdge; + + public function __construct(bool $bleedingEdge) + { + $this->bleedingEdge = $bleedingEdge; + } + public function getType(): string { return \Doctrine\DBAL\Types\BooleanType::class; @@ -33,4 +43,28 @@ public function getDatabaseInternalType(): Type ); } + public function getDatabaseInternalTypeForDriver(Connection $connection): Type + { + $driverType = DriverType::detect($connection, $this->bleedingEdge); + + if ($driverType === DriverType::PGSQL || $driverType === DriverType::PDO_PGSQL) { + return new \PHPStan\Type\BooleanType(); + } + + if ( + $driverType === DriverType::SQLITE3 + || $driverType === DriverType::PDO_SQLITE + || $driverType === DriverType::MYSQLI + || $driverType === DriverType::PDO_MYSQL + ) { + return TypeCombinator::union( + new ConstantIntegerType(0), + new ConstantIntegerType(1) + ); + } + + // not yet supported driver, return the old implementation guess + return $this->getDatabaseInternalType(); + } + } diff --git a/src/Type/Doctrine/Descriptors/DecimalType.php b/src/Type/Doctrine/Descriptors/DecimalType.php index b008ffe5..24b85269 100644 --- a/src/Type/Doctrine/Descriptors/DecimalType.php +++ b/src/Type/Doctrine/Descriptors/DecimalType.php @@ -2,16 +2,27 @@ namespace PHPStan\Type\Doctrine\Descriptors; +use Doctrine\DBAL\Connection; +use PHPStan\Doctrine\Driver\DriverType; use PHPStan\Type\Accessory\AccessoryNumericStringType; use PHPStan\Type\FloatType; use PHPStan\Type\IntegerType; +use PHPStan\Type\IntersectionType; use PHPStan\Type\StringType; use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; -class DecimalType implements DoctrineTypeDescriptor +class DecimalType implements DoctrineTypeDescriptor, DoctrineTypeDriverAwareDescriptor { + /** @var bool */ + private $bleedingEdge; + + public function __construct(bool $bleedingEdge) + { + $this->bleedingEdge = $bleedingEdge; + } + public function getType(): string { return \Doctrine\DBAL\Types\DecimalType::class; @@ -32,4 +43,28 @@ public function getDatabaseInternalType(): Type return TypeCombinator::union(new FloatType(), new IntegerType()); } + public function getDatabaseInternalTypeForDriver(Connection $connection): Type + { + $driverType = DriverType::detect($connection, $this->bleedingEdge); + + if ($driverType === DriverType::SQLITE3 || $driverType === DriverType::PDO_SQLITE) { + return TypeCombinator::union(new FloatType(), new IntegerType()); + } + + if ( + $driverType === DriverType::MYSQLI + || $driverType === DriverType::PDO_MYSQL + || $driverType === DriverType::PGSQL + || $driverType === DriverType::PDO_PGSQL + ) { + return new IntersectionType([ + new StringType(), + new AccessoryNumericStringType(), + ]); + } + + // not yet supported driver, return the old implementation guess + return $this->getDatabaseInternalType(); + } + } diff --git a/src/Type/Doctrine/Descriptors/DoctrineTypeDescriptor.php b/src/Type/Doctrine/Descriptors/DoctrineTypeDescriptor.php index 75f56c9b..c0bffd92 100644 --- a/src/Type/Doctrine/Descriptors/DoctrineTypeDescriptor.php +++ b/src/Type/Doctrine/Descriptors/DoctrineTypeDescriptor.php @@ -13,10 +13,23 @@ interface DoctrineTypeDescriptor */ public function getType(): string; + /** + * This is used for inferring direct column results, e.g. SELECT e.field + * It should comply with convertToPHPValue return value + */ public function getWritableToPropertyType(): Type; public function getWritableToDatabaseType(): Type; + /** + * This is used for inferring how database fetches column of such type + * + * This is not used for direct column type inferring, + * but when such column appears in expression like SELECT MAX(e.field) + * + * Sometimes, the type cannot be reliably decided without driver context, + * use DoctrineTypeDriverAwareDescriptor in such cases + */ public function getDatabaseInternalType(): Type; } diff --git a/src/Type/Doctrine/Descriptors/DoctrineTypeDriverAwareDescriptor.php b/src/Type/Doctrine/Descriptors/DoctrineTypeDriverAwareDescriptor.php new file mode 100644 index 00000000..765c8f2e --- /dev/null +++ b/src/Type/Doctrine/Descriptors/DoctrineTypeDriverAwareDescriptor.php @@ -0,0 +1,29 @@ +bleedingEdge = $bleedingEdge; + } + public function getType(): string { return \Doctrine\DBAL\Types\FloatType::class; @@ -29,4 +42,29 @@ public function getDatabaseInternalType(): Type return TypeCombinator::union(new \PHPStan\Type\FloatType(), new IntegerType()); } + public function getDatabaseInternalTypeForDriver(Connection $connection): Type + { + $driverType = DriverType::detect($connection, $this->bleedingEdge); + + if ($driverType === DriverType::PDO_PGSQL) { + return new IntersectionType([ + new StringType(), + new AccessoryNumericStringType(), + ]); + } + + if ( + $driverType === DriverType::SQLITE3 + || $driverType === DriverType::PDO_SQLITE + || $driverType === DriverType::MYSQLI + || $driverType === DriverType::PDO_MYSQL + || $driverType === DriverType::PGSQL + ) { + return new \PHPStan\Type\FloatType(); + } + + // not yet supported driver, return the old implementation guess + return $this->getDatabaseInternalType(); + } + } diff --git a/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php b/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php index 57561ef4..fa679ea7 100644 --- a/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php +++ b/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php @@ -70,7 +70,7 @@ protected function getRule(): Rule new DateTimeImmutableType(), new DateTimeType(), new DateType(), - new DecimalType(), + new DecimalType(true), new JsonType(), new IntegerType(), new StringType(), From de11651eadd0389b1263a1938e414d9c70885365 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Mon, 24 Jun 2024 17:17:47 +0200 Subject: [PATCH 2/3] Ignore missing drivers on old php --- phpstan.neon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpstan.neon b/phpstan.neon index 4ad634bd..0cc599cc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -54,3 +54,9 @@ parameters: message: '#^Call to function method_exists\(\) with Doctrine\\DBAL\\Connection and ''getNativeConnection'' will always evaluate to true\.$#' # needed for older DBAL versions paths: - src/Doctrine/Driver/DriverType.php + + - + messages: # needed for older DBAL versions + - '#^Class PgSql\\Connection not found\.$#' + - '#^Class Doctrine\\DBAL\\Driver\\PgSQL\\Driver not found\.$#' + - '#^Class Doctrine\\DBAL\\Driver\\SQLite3\\Driver not found\.$#' From a02d89a6d00b1fdb5d3dd4d08d10317771363531 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Tue, 25 Jun 2024 12:18:55 +0200 Subject: [PATCH 3/3] DriverDetector is a service --- extension.neon | 10 +++---- phpstan.neon | 2 +- .../{DriverType.php => DriverDetector.php} | 13 +++++++-- src/Type/Doctrine/Descriptors/BooleanType.php | 27 ++++++++--------- src/Type/Doctrine/Descriptors/DecimalType.php | 27 ++++++++--------- src/Type/Doctrine/Descriptors/FloatType.php | 29 ++++++++++--------- .../Doctrine/ORM/EntityColumnRuleTest.php | 3 +- 7 files changed, 60 insertions(+), 51 deletions(-) rename src/Doctrine/Driver/{DriverType.php => DriverDetector.php} (92%) diff --git a/extension.neon b/extension.neon index 6f765baf..2f8daea1 100644 --- a/extension.neon +++ b/extension.neon @@ -89,6 +89,10 @@ services: class: PHPStan\Type\Doctrine\DefaultDescriptorRegistry factory: @PHPStan\Type\Doctrine\DescriptorRegistryFactory::createRegistry + - + class: PHPStan\Doctrine\Driver\DriverDetector + arguments: + failOnInvalidConnection: %featureToggles.bleedingEdge% - class: PHPStan\Reflection\Doctrine\DoctrineSelectableClassReflectionExtension - @@ -317,8 +321,6 @@ services: - class: PHPStan\Type\Doctrine\Descriptors\BooleanType tags: [phpstan.doctrine.typeDescriptor] - arguments: - bleedingEdge: %featureToggles.bleedingEdge% - class: PHPStan\Type\Doctrine\Descriptors\DateImmutableType tags: [phpstan.doctrine.typeDescriptor] @@ -343,13 +345,9 @@ services: - class: PHPStan\Type\Doctrine\Descriptors\DecimalType tags: [phpstan.doctrine.typeDescriptor] - arguments: - bleedingEdge: %featureToggles.bleedingEdge% - class: PHPStan\Type\Doctrine\Descriptors\FloatType tags: [phpstan.doctrine.typeDescriptor] - arguments: - bleedingEdge: %featureToggles.bleedingEdge% - class: PHPStan\Type\Doctrine\Descriptors\GuidType tags: [phpstan.doctrine.typeDescriptor] diff --git a/phpstan.neon b/phpstan.neon index 0cc599cc..c467b761 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -53,7 +53,7 @@ parameters: - message: '#^Call to function method_exists\(\) with Doctrine\\DBAL\\Connection and ''getNativeConnection'' will always evaluate to true\.$#' # needed for older DBAL versions paths: - - src/Doctrine/Driver/DriverType.php + - src/Doctrine/Driver/DriverDetector.php - messages: # needed for older DBAL versions diff --git a/src/Doctrine/Driver/DriverType.php b/src/Doctrine/Driver/DriverDetector.php similarity index 92% rename from src/Doctrine/Driver/DriverType.php rename to src/Doctrine/Driver/DriverDetector.php index 00d97818..0a4371be 100644 --- a/src/Doctrine/Driver/DriverType.php +++ b/src/Doctrine/Driver/DriverDetector.php @@ -23,7 +23,7 @@ use function method_exists; use function strpos; -class DriverType +class DriverDetector { public const IBM_DB2 = 'ibm_db2'; @@ -38,11 +38,18 @@ class DriverType public const SQLITE3 = 'sqlite3'; public const SQLSRV = 'sqlsrv'; + /** @var bool */ + private $failOnInvalidConnection; + + public function __construct(bool $failOnInvalidConnection) + { + $this->failOnInvalidConnection = $failOnInvalidConnection; + } /** * @return self::*|null */ - public static function detect(Connection $connection, bool $failOnInvalidConnection): ?string + public function detect(Connection $connection): ?string { $driver = $connection->getDriver(); @@ -99,7 +106,7 @@ public static function detect(Connection $connection, bool $failOnInvalidConnect try { $nativeConnection = $connection->getNativeConnection(); } catch (Throwable $e) { - if ($failOnInvalidConnection) { + if ($this->failOnInvalidConnection) { throw $e; } return null; // connection cannot be established diff --git a/src/Type/Doctrine/Descriptors/BooleanType.php b/src/Type/Doctrine/Descriptors/BooleanType.php index 70b719f6..b9e59574 100644 --- a/src/Type/Doctrine/Descriptors/BooleanType.php +++ b/src/Type/Doctrine/Descriptors/BooleanType.php @@ -3,20 +3,21 @@ namespace PHPStan\Type\Doctrine\Descriptors; use Doctrine\DBAL\Connection; -use PHPStan\Doctrine\Driver\DriverType; +use PHPStan\Doctrine\Driver\DriverDetector; use PHPStan\Type\Constant\ConstantIntegerType; use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; +use function in_array; class BooleanType implements DoctrineTypeDescriptor, DoctrineTypeDriverAwareDescriptor { - /** @var bool */ - private $bleedingEdge; + /** @var DriverDetector */ + private $driverDetector; - public function __construct(bool $bleedingEdge) + public function __construct(DriverDetector $driverDetector) { - $this->bleedingEdge = $bleedingEdge; + $this->driverDetector = $driverDetector; } public function getType(): string @@ -45,18 +46,18 @@ public function getDatabaseInternalType(): Type public function getDatabaseInternalTypeForDriver(Connection $connection): Type { - $driverType = DriverType::detect($connection, $this->bleedingEdge); + $driverType = $this->driverDetector->detect($connection); - if ($driverType === DriverType::PGSQL || $driverType === DriverType::PDO_PGSQL) { + if ($driverType === DriverDetector::PGSQL || $driverType === DriverDetector::PDO_PGSQL) { return new \PHPStan\Type\BooleanType(); } - if ( - $driverType === DriverType::SQLITE3 - || $driverType === DriverType::PDO_SQLITE - || $driverType === DriverType::MYSQLI - || $driverType === DriverType::PDO_MYSQL - ) { + if (in_array($driverType, [ + DriverDetector::SQLITE3, + DriverDetector::PDO_SQLITE, + DriverDetector::MYSQLI, + DriverDetector::PDO_MYSQL, + ], true)) { return TypeCombinator::union( new ConstantIntegerType(0), new ConstantIntegerType(1) diff --git a/src/Type/Doctrine/Descriptors/DecimalType.php b/src/Type/Doctrine/Descriptors/DecimalType.php index 24b85269..64184c45 100644 --- a/src/Type/Doctrine/Descriptors/DecimalType.php +++ b/src/Type/Doctrine/Descriptors/DecimalType.php @@ -3,7 +3,7 @@ namespace PHPStan\Type\Doctrine\Descriptors; use Doctrine\DBAL\Connection; -use PHPStan\Doctrine\Driver\DriverType; +use PHPStan\Doctrine\Driver\DriverDetector; use PHPStan\Type\Accessory\AccessoryNumericStringType; use PHPStan\Type\FloatType; use PHPStan\Type\IntegerType; @@ -11,16 +11,17 @@ use PHPStan\Type\StringType; use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; +use function in_array; class DecimalType implements DoctrineTypeDescriptor, DoctrineTypeDriverAwareDescriptor { - /** @var bool */ - private $bleedingEdge; + /** @var DriverDetector */ + private $driverDetector; - public function __construct(bool $bleedingEdge) + public function __construct(DriverDetector $driverDetector) { - $this->bleedingEdge = $bleedingEdge; + $this->driverDetector = $driverDetector; } public function getType(): string @@ -45,18 +46,18 @@ public function getDatabaseInternalType(): Type public function getDatabaseInternalTypeForDriver(Connection $connection): Type { - $driverType = DriverType::detect($connection, $this->bleedingEdge); + $driverType = $this->driverDetector->detect($connection); - if ($driverType === DriverType::SQLITE3 || $driverType === DriverType::PDO_SQLITE) { + if ($driverType === DriverDetector::SQLITE3 || $driverType === DriverDetector::PDO_SQLITE) { return TypeCombinator::union(new FloatType(), new IntegerType()); } - if ( - $driverType === DriverType::MYSQLI - || $driverType === DriverType::PDO_MYSQL - || $driverType === DriverType::PGSQL - || $driverType === DriverType::PDO_PGSQL - ) { + if (in_array($driverType, [ + DriverDetector::MYSQLI, + DriverDetector::PDO_MYSQL, + DriverDetector::PGSQL, + DriverDetector::PDO_PGSQL, + ], true)) { return new IntersectionType([ new StringType(), new AccessoryNumericStringType(), diff --git a/src/Type/Doctrine/Descriptors/FloatType.php b/src/Type/Doctrine/Descriptors/FloatType.php index 67e73d47..dea7304b 100644 --- a/src/Type/Doctrine/Descriptors/FloatType.php +++ b/src/Type/Doctrine/Descriptors/FloatType.php @@ -3,23 +3,24 @@ namespace PHPStan\Type\Doctrine\Descriptors; use Doctrine\DBAL\Connection; -use PHPStan\Doctrine\Driver\DriverType; +use PHPStan\Doctrine\Driver\DriverDetector; use PHPStan\Type\Accessory\AccessoryNumericStringType; use PHPStan\Type\IntegerType; use PHPStan\Type\IntersectionType; use PHPStan\Type\StringType; use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; +use function in_array; class FloatType implements DoctrineTypeDescriptor, DoctrineTypeDriverAwareDescriptor { - /** @var bool */ - private $bleedingEdge; + /** @var DriverDetector */ + private $driverDetector; - public function __construct(bool $bleedingEdge) + public function __construct(DriverDetector $driverDetector) { - $this->bleedingEdge = $bleedingEdge; + $this->driverDetector = $driverDetector; } public function getType(): string @@ -44,22 +45,22 @@ public function getDatabaseInternalType(): Type public function getDatabaseInternalTypeForDriver(Connection $connection): Type { - $driverType = DriverType::detect($connection, $this->bleedingEdge); + $driverType = $this->driverDetector->detect($connection); - if ($driverType === DriverType::PDO_PGSQL) { + if ($driverType === DriverDetector::PDO_PGSQL) { return new IntersectionType([ new StringType(), new AccessoryNumericStringType(), ]); } - if ( - $driverType === DriverType::SQLITE3 - || $driverType === DriverType::PDO_SQLITE - || $driverType === DriverType::MYSQLI - || $driverType === DriverType::PDO_MYSQL - || $driverType === DriverType::PGSQL - ) { + if (in_array($driverType, [ + DriverDetector::SQLITE3, + DriverDetector::PDO_SQLITE, + DriverDetector::MYSQLI, + DriverDetector::PDO_MYSQL, + DriverDetector::PGSQL, + ], true)) { return new \PHPStan\Type\FloatType(); } diff --git a/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php b/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php index fa679ea7..76183c49 100644 --- a/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php +++ b/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php @@ -7,6 +7,7 @@ use Composer\InstalledVersions; use Doctrine\DBAL\Types\Type; use Iterator; +use PHPStan\Doctrine\Driver\DriverDetector; use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPStan\Type\Doctrine\DefaultDescriptorRegistry; @@ -70,7 +71,7 @@ protected function getRule(): Rule new DateTimeImmutableType(), new DateTimeType(), new DateType(), - new DecimalType(true), + new DecimalType(new DriverDetector(true)), new JsonType(), new IntegerType(), new StringType(),