diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2357b32532b..36cbe8cb4fc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -132,12 +132,6 @@ parameters: count: 1 path: src/Cache/DefaultEntityHydrator.php - - - message: '#^Call to method Doctrine\\ORM\\Mapping\\AssociationMapping\:\:isToOneOwningSide\(\) will always evaluate to true\.$#' - identifier: method.alreadyNarrowedType - count: 1 - path: src/Cache/DefaultEntityHydrator.php - - message: '#^Method Doctrine\\ORM\\Cache\\DefaultEntityHydrator\:\:buildCacheEntry\(\) has parameter \$metadata with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#' identifier: missingType.generics @@ -486,12 +480,6 @@ parameters: count: 1 path: src/Cache/TimestampQueryCacheValidator.php - - - message: '#^Call to function is_a\(\) with arguments class\-string\, ''Doctrine\\\\ORM\\\\EntityRepository'' and true will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: src/Configuration.php - - message: '#^Method Doctrine\\ORM\\Configuration\:\:getDefaultRepositoryClassName\(\) return type with generic class Doctrine\\ORM\\EntityRepository does not specify its types\: T$#' identifier: missingType.generics @@ -864,18 +852,6 @@ parameters: count: 1 path: src/Mapping/AssociationMapping.php - - - message: '#^Instanceof between Doctrine\\ORM\\Mapping\\AssociationOverride and Doctrine\\ORM\\Mapping\\AssociationOverride will always evaluate to true\.$#' - identifier: instanceof.alwaysTrue - count: 1 - path: src/Mapping/AssociationOverrides.php - - - - message: '#^Instanceof between Doctrine\\ORM\\Mapping\\AttributeOverride and Doctrine\\ORM\\Mapping\\AttributeOverride will always evaluate to true\.$#' - identifier: instanceof.alwaysTrue - count: 1 - path: src/Mapping/AttributeOverrides.php - - message: '#^Method Doctrine\\ORM\\Mapping\\Builder\\ClassMetadataBuilder\:\:__construct\(\) has parameter \$cm with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#' identifier: missingType.generics @@ -930,12 +906,6 @@ parameters: count: 1 path: src/Mapping/ClassMetadata.php - - - message: '#^Parameter \#1 \$array \(list\\) of array_values is already a list, call has no effect\.$#' - identifier: arrayValues.list - count: 1 - path: src/Mapping/ClassMetadata.php - - message: '#^Parameter \#1 \$mapping of method Doctrine\\ORM\\Mapping\\ClassMetadata\\:\:validateAndCompleteTypedAssociationMapping\(\) expects array\{type\: 1\|2\|4\|8, fieldName\: string, targetEntity\?\: class\-string\}, non\-empty\-array\ given\.$#' identifier: argument.type @@ -1038,12 +1008,6 @@ parameters: count: 1 path: src/Mapping/ClassMetadata.php - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 1 - path: src/Mapping/ClassMetadataFactory.php - - message: '#^Method Doctrine\\ORM\\Mapping\\ClassMetadataFactory\:\:addDefaultDiscriminatorMap\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#' identifier: missingType.generics @@ -1308,21 +1272,9 @@ parameters: count: 1 path: src/Mapping/Driver/DatabaseDriver.php - - - message: '#^Call to function method_exists\(\) with Doctrine\\DBAL\\Schema\\Index and ''getType'' will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: src/Mapping/Driver/DatabaseDriver.php - - message: '#^Call to function method_exists\(\) with Doctrine\\DBAL\\Schema\\Table and ''getPrimaryKeyConstr…'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType - count: 2 - path: src/Mapping/Driver/DatabaseDriver.php - - - - message: '#^Instanceof between Doctrine\\ORM\\Mapping\\ClassMetadata\ and Doctrine\\ORM\\Mapping\\ClassMetadata will always evaluate to true\.$#' - identifier: instanceof.alwaysTrue count: 1 path: src/Mapping/Driver/DatabaseDriver.php @@ -1477,7 +1429,7 @@ parameters: path: src/Mapping/LegacyReflectionFields.php - - message: '#^Strict comparison using \!\=\= between array\ and null will always evaluate to true\.$#' + message: '#^Strict comparison using \!\=\= between array and null will always evaluate to true\.$#' identifier: notIdentical.alwaysTrue count: 1 path: src/Mapping/ManyToManyOwningSideMapping.php @@ -1578,12 +1530,6 @@ parameters: count: 1 path: src/Mapping/ToOneOwningSideMapping.php - - - message: '#^Call to function is_int\(\) with string will always evaluate to false\.$#' - identifier: function.impossibleType - count: 1 - path: src/NativeQuery.php - - message: '#^Method Doctrine\\ORM\\NativeQuery\:\:_doExecute\(\) never returns int so it can be removed from the return type\.$#' identifier: return.unusedType @@ -1926,12 +1872,6 @@ parameters: count: 1 path: src/Persisters/Entity/BasicEntityPersister.php - - - message: '#^Call to method Doctrine\\ORM\\Mapping\\AssociationMapping\:\:isToOneOwningSide\(\) will always evaluate to true\.$#' - identifier: method.alreadyNarrowedType - count: 1 - path: src/Persisters/Entity/BasicEntityPersister.php - - message: '#^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:__construct\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#' identifier: missingType.generics @@ -2142,18 +2082,6 @@ parameters: count: 1 path: src/Proxy/ProxyFactory.php - - - message: '#^Comparison operation "\<" between 0\|1\|2\|3\|4 and 0 is always false\.$#' - identifier: smaller.alwaysFalse - count: 1 - path: src/Proxy/ProxyFactory.php - - - - message: '#^Comparison operation "\>" between 0\|1\|2\|3\|4 and 4 is always false\.$#' - identifier: greater.alwaysFalse - count: 1 - path: src/Proxy/ProxyFactory.php - - message: '#^Method Doctrine\\ORM\\Proxy\\ProxyFactory\:\:createLazyInitializer\(\) has Doctrine\\ORM\\EntityNotFoundException in PHPDoc @throws tag but it''s not thrown\.$#' identifier: throws.unusedType @@ -2238,12 +2166,6 @@ parameters: count: 1 path: src/Proxy/ProxyFactory.php - - - message: '#^Result of \|\| is always false\.$#' - identifier: booleanOr.alwaysFalse - count: 1 - path: src/Proxy/ProxyFactory.php - - message: '#^Method Doctrine\\ORM\\Query\:\:processParameterMappings\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -2496,12 +2418,6 @@ parameters: count: 1 path: src/Query/Parser.php - - - message: '#^Strict comparison using \=\=\= between 102 and 102 will always evaluate to true\.$#' - identifier: identical.alwaysTrue - count: 1 - path: src/Query/Parser.php - - message: '#^Unreachable statement \- code above always terminates\.$#' identifier: deadCode.unreachable @@ -2526,30 +2442,12 @@ parameters: count: 1 path: src/Query/SqlOutputWalker.php - - - message: '#^Call to method Doctrine\\ORM\\Mapping\\AssociationMapping\:\:isManyToMany\(\) will always evaluate to true\.$#' - identifier: method.alreadyNarrowedType - count: 1 - path: src/Query/SqlWalker.php - - - - message: '#^Call to method Doctrine\\ORM\\Mapping\\AssociationMapping\:\:isToOneOwningSide\(\) will always evaluate to true\.$#' - identifier: method.alreadyNarrowedType - count: 1 - path: src/Query/SqlWalker.php - - message: '#^Cannot assign new offset to list\\|string\.$#' identifier: offsetAssign.dimType count: 2 path: src/Query/SqlWalker.php - - - message: '#^Match arm comparison between 4 and 4 is always true\.$#' - identifier: match.alwaysTrue - count: 1 - path: src/Query/SqlWalker.php - - message: '#^Method Doctrine\\ORM\\Query\\SqlWalker\:\:generateClassTableInheritanceJoins\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#' identifier: missingType.generics @@ -2829,12 +2727,6 @@ parameters: count: 1 path: src/Tools/SchemaTool.php - - - message: '#^Call to function method_exists\(\) with Doctrine\\DBAL\\Schema\\Table and ''getPrimaryKeyConstr…'' will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: src/Tools/SchemaTool.php - - message: '#^Method Doctrine\\ORM\\Tools\\SchemaTool\:\:addDiscriminatorColumnDefinition\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#' identifier: missingType.generics @@ -3045,18 +2937,6 @@ parameters: count: 1 path: src/UnitOfWork.php - - - message: '#^Call to method Doctrine\\ORM\\Mapping\\AssociationMapping\:\:isToMany\(\) will always evaluate to true\.$#' - identifier: method.alreadyNarrowedType - count: 1 - path: src/UnitOfWork.php - - - - message: '#^Call to method Doctrine\\ORM\\Mapping\\AssociationMapping\:\:isToOneOwningSide\(\) will always evaluate to true\.$#' - identifier: method.alreadyNarrowedType - count: 1 - path: src/UnitOfWork.php - - message: '#^Method Doctrine\\ORM\\UnitOfWork\:\:convertSingleFieldIdentifierToPHPValue\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#' identifier: missingType.generics @@ -3171,12 +3051,6 @@ parameters: count: 1 path: src/Utility/IdentifierFlattener.php - - - message: '#^Call to method Doctrine\\ORM\\Mapping\\AssociationMapping\:\:isToOneOwningSide\(\) will always evaluate to true\.$#' - identifier: method.alreadyNarrowedType - count: 1 - path: src/Utility/PersisterHelper.php - - message: '#^Method Doctrine\\ORM\\Utility\\PersisterHelper\:\:getTypeOfColumn\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#' identifier: missingType.generics diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon index 9f4a82c7e5f..1732fc7e240 100644 --- a/phpstan-dbal3.neon +++ b/phpstan-dbal3.neon @@ -3,6 +3,7 @@ includes: - phpstan-params.neon parameters: + treatPhpDocTypesAsCertain: false reportUnmatchedIgnoredErrors: false # Some errors in the baseline only apply to DBAL 4 excludePaths: # Compatibility shims for Collections 2 vs Collections 3 @@ -31,6 +32,11 @@ parameters: message: '~^Match expression does not handle remaining values:~' path: src/Utility/PersisterHelper.php + # DBAL 3 compatibility + - + message: '~^Class Doctrine\\DBAL\\Platforms\\SqlitePlatform referenced with incorrect case: Doctrine\\DBAL\\Platforms\\SQLitePlatform\.$~' + path: src/Utility/LockSqlHelper.php + # DBAL 4 compatibility - message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' diff --git a/phpstan.neon b/phpstan.neon index 7c7b699994c..5a1096a8fe4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,6 +3,8 @@ includes: - phpstan-params.neon parameters: + treatPhpDocTypesAsCertain: false + excludePaths: # Compatibility shims for Collections 2 vs Collections 3 # These have intentional signature mismatches that cannot be resolved @@ -45,7 +47,7 @@ parameters: message: '~^Result of method Doctrine\\DBAL\\Connection::commit\(\) \(void\) is used\.$~' path: src/UnitOfWork.php - - message: '~^Strict comparison using === between null and false will always evaluate to false\.$~' + message: '~^Strict comparison using === between void and false will always evaluate to false\.$~' path: src/UnitOfWork.php - message: '~^Variable \$e on left side of \?\? always exists and is not nullable\.$~' @@ -59,12 +61,6 @@ parameters: message: '~Strict comparison using \=\=\= between callable\(\)\: mixed and null will always evaluate to false\.~' path: src/Tools/SchemaTool.php - # To be removed in 4.0 - - - message: '#Negated boolean expression is always false\.#' - paths: - - src/Mapping/Driver/AttributeDriver.php - # Compatibility with Persistence 3 - message: '#Expression on left side of \?\? is not nullable.#' diff --git a/src/Query/Expr/Base.php b/src/Query/Expr/Base.php index 0cd533adad5..1d43870df34 100644 --- a/src/Query/Expr/Base.php +++ b/src/Query/Expr/Base.php @@ -69,7 +69,6 @@ public function add(mixed $arg): static { if ($arg !== null && (! $arg instanceof self || $arg->count() > 0)) { // If we decide to keep Expr\Base instances, we can use this check - // @phpstan-ignore function.alreadyNarrowedType (input validation) if (! is_string($arg) && ! (is_object($arg) && in_array($arg::class, $this->allowedClasses, true))) { throw new InvalidArgumentException(sprintf( "Expression of type '%s' not allowed in this context.",