diff --git a/extension.neon b/extension.neon index 93102dc0..803ffaed 100644 --- a/extension.neon +++ b/extension.neon @@ -353,6 +353,9 @@ services: - class: PHPStan\Type\Doctrine\Descriptors\DecimalType tags: [phpstan.doctrine.typeDescriptor] + - + class: PHPStan\Type\Doctrine\Descriptors\EnumType + tags: [phpstan.doctrine.typeDescriptor] - class: PHPStan\Type\Doctrine\Descriptors\FloatType tags: [phpstan.doctrine.typeDescriptor] @@ -374,6 +377,9 @@ services: - class: PHPStan\Type\Doctrine\Descriptors\SimpleArrayType tags: [phpstan.doctrine.typeDescriptor] + - + class: PHPStan\Type\Doctrine\Descriptors\SmallFloatType + tags: [phpstan.doctrine.typeDescriptor] - class: PHPStan\Type\Doctrine\Descriptors\SmallIntType tags: [phpstan.doctrine.typeDescriptor] diff --git a/phpstan-baseline-dbal-4.neon b/phpstan-baseline-dbal-4.neon new file mode 100644 index 00000000..24536b91 --- /dev/null +++ b/phpstan-baseline-dbal-4.neon @@ -0,0 +1,33 @@ +parameters: + ignoreErrors: + - + message: '#^Class Doctrine\\DBAL\\Types\\EnumType not found\.$#' + identifier: class.notFound + count: 1 + path: src/Type/Doctrine/Descriptors/EnumType.php + + - + message: '#^Method PHPStan\\Type\\Doctrine\\Descriptors\\EnumType\:\:getType\(\) should return class\-string\ but returns string\.$#' + identifier: return.type + count: 1 + path: src/Type/Doctrine/Descriptors/EnumType.php + + - + message: '#^Class Doctrine\\DBAL\\Types\\SmallFloatType not found\.$#' + identifier: class.notFound + count: 1 + path: src/Type/Doctrine/Descriptors/SmallFloatType.php + + - + message: '#^Method PHPStan\\Type\\Doctrine\\Descriptors\\SmallFloatType\:\:getType\(\) should return class\-string\ but returns string\.$#' + identifier: return.type + count: 1 + path: src/Type/Doctrine/Descriptors/SmallFloatType.php + + - + message: '#^Class Doctrine\\DBAL\\Types\\EnumType not found\.$#' + identifier: class.notFound + count: 1 + path: src/Type/Doctrine/Query/QueryResultTypeWalker.php + + diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 73d72b45..e505390f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -83,3 +83,9 @@ parameters: identifier: phpstanApi.classConstant count: 1 path: tests/Rules/Properties/MissingReadOnlyPropertyAssignRuleTest.php + + - + message: '#^Parameter references internal interface Doctrine\\ORM\\Query\\AST\\Phase2OptimizableConditional in its type\.$#' + identifier: parameter.internalInterface + count: 2 + path: src/Type/Doctrine/Query/QueryResultTypeWalker.php diff --git a/phpstan.neon b/phpstan.neon index efbf455d..ae9f2df6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,6 +4,7 @@ includes: - phpstan-baseline.neon - phpstan-baseline-deprecations.neon - phpstan-baseline-dbal-3.neon + - phpstan-baseline-dbal-4.neon - compatibility/orm-3-baseline.php - vendor/phpstan/phpstan-strict-rules/rules.neon - vendor/phpstan/phpstan-deprecation-rules/rules.neon diff --git a/src/Type/Doctrine/Descriptors/EnumType.php b/src/Type/Doctrine/Descriptors/EnumType.php new file mode 100644 index 00000000..cc10d3f8 --- /dev/null +++ b/src/Type/Doctrine/Descriptors/EnumType.php @@ -0,0 +1,31 @@ +getReturnType() instanceof DbalStringType // StringType is no-op, so using TypedExpression with that does nothing + && !$expr->getReturnType() instanceof DbalEnumType // EnumType is also no-op ) { $dbalTypeName = DbalType::getTypeRegistry()->lookupName($expr->getReturnType()); $type = TypeCombinator::intersect( // e.g. count is typed as int, but we infer int<0, max>