Skip to content
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
128 changes: 1 addition & 127 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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\>, ''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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -930,12 +906,6 @@ parameters:
count: 1
path: src/Mapping/ClassMetadata.php

-
message: '#^Parameter \#1 \$array \(list\<string\>\) 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\<T of object\>\:\:validateAndCompleteTypedAssociationMapping\(\) expects array\{type\: 1\|2\|4\|8, fieldName\: string, targetEntity\?\: class\-string\}, non\-empty\-array\<string, mixed\> given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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\<T of object\> and Doctrine\\ORM\\Mapping\\ClassMetadata will always evaluate to true\.$#'
identifier: instanceof.alwaysTrue
count: 1
path: src/Mapping/Driver/DatabaseDriver.php

Expand Down Expand Up @@ -1477,7 +1429,7 @@ parameters:
path: src/Mapping/LegacyReflectionFields.php

-
message: '#^Strict comparison using \!\=\= between array\<string, string\> 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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\>\|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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions phpstan-dbal3.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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\.$~'
Expand Down
10 changes: 3 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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\.$~'
Expand All @@ -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.#'
Expand Down
1 change: 0 additions & 1 deletion src/Query/Expr/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
whataboutpereira marked this conversation as resolved.
// @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.",
Expand Down
Loading