Skip to content

Commit

Permalink
Psalm 4.13.1, PHPStan 1.2.0 (#9204)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored Nov 27, 2021
1 parent 146b465 commit cac2aca
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 75 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
"doctrine/annotations": "^1.13",
"doctrine/coding-standard": "^9.0",
"phpbench/phpbench": "^0.16.10 || ^1.0",
"phpstan/phpstan": "1.0.1",
"phpstan/phpstan": "1.2.0",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.4",
"squizlabs/php_codesniffer": "3.6.1",
"symfony/cache": "^4.4 || ^5.2",
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"vimeo/psalm": "4.10.0"
"vimeo/psalm": "4.13.1"
},
"conflict": {
"doctrine/annotations": "<1.13 || >= 2.0"
Expand Down
9 changes: 0 additions & 9 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ parameters:
message: '/^Call to static method ensure\(\) on an unknown class Doctrine\\DBAL\\ForwardCompatibility\\Result\.$/'
path: lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php

# Forward compatibility for DBAL 3.2
- '/^Call to an undefined method Doctrine\\DBAL\\Cache\\QueryCacheProfile::[gs]etResultCache\(\)\.$/'
-
message: '/^Call to an undefined static method Doctrine\\DBAL\\Configuration::[gs]etResultCache\(\)\.$/'
path: lib/Doctrine/ORM/Configuration.php
-
message: '/^Parameter #3 \$resultCache of class Doctrine\\DBAL\\Cache\\QueryCacheProfile constructor/'
path: lib/Doctrine/ORM/AbstractQuery.php

# False positive
-
message: '/^Variable \$offset in isset\(\) always exists and is not nullable\.$/'
Expand Down
139 changes: 75 additions & 64 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.10.0@916b098b008f6de4543892b1e0651c1c3b92cbfa">
<files psalm-version="4.13.1@5cf660f63b548ccd4a56f62d916ee4d6028e01a3">
<file src="lib/Doctrine/ORM/AbstractQuery.php">
<DeprecatedClass occurrences="1">
<code>IterableResult</code>
</DeprecatedClass>
<DeprecatedMethod occurrences="1">
<code>iterate</code>
</DeprecatedMethod>
<DocblockTypeContradiction occurrences="1">
<code>$resultCacheDriver !== null &amp;&amp; ! ($resultCacheDriver instanceof \Doctrine\Common\Cache\Cache)</code>
</DocblockTypeContradiction>
<FalsableReturnStatement occurrences="1">
<code>! $filteredParameters-&gt;isEmpty() ? $filteredParameters-&gt;first() : null</code>
</FalsableReturnStatement>
Expand Down Expand Up @@ -518,15 +515,16 @@
<PropertyTypeCoercion occurrences="1">
<code>new $metadataFactoryClassName()</code>
</PropertyTypeCoercion>
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>is_object($connection)</code>
<code>is_object($connection)</code>
</RedundantCondition>
<RedundantConditionGivenDocblockType occurrences="1">
<code>$this-&gt;filterCollection !== null</code>
</RedundantConditionGivenDocblockType>
<TypeDoesNotContainType occurrences="2">
<code>$connection instanceof Connection</code>
<code>': "' . $connection . '"'</code>
<code>gettype($connection)</code>
</TypeDoesNotContainType>
</file>
<file src="lib/Doctrine/ORM/EntityManagerInterface.php">
Expand Down Expand Up @@ -604,9 +602,6 @@
<PossiblyNullPropertyAssignmentValue occurrences="1">
<code>$sequenceName</code>
</PossiblyNullPropertyAssignmentValue>
<RedundantCastGivenDocblockType occurrences="1">
<code>(string) $em-&gt;getConnection()-&gt;lastInsertId($this-&gt;sequenceName)</code>
</RedundantCastGivenDocblockType>
</file>
<file src="lib/Doctrine/ORM/Id/TableGenerator.php">
<PossiblyFalseOperand occurrences="3">
Expand Down Expand Up @@ -777,8 +772,7 @@
</RedundantCastGivenDocblockType>
</file>
<file src="lib/Doctrine/ORM/Mapping/ClassMetadata.php">
<PropertyNotSetInConstructor occurrences="7">
<code>ClassMetadata</code>
<PropertyNotSetInConstructor occurrences="6">
<code>ClassMetadata</code>
<code>ClassMetadata</code>
<code>ClassMetadata</code>
Expand Down Expand Up @@ -820,11 +814,13 @@
<DeprecatedConstant occurrences="1">
<code>ClassMetadata::GENERATOR_TYPE_UUID</code>
</DeprecatedConstant>
<DeprecatedMethod occurrences="2">
<DeprecatedMethod occurrences="3">
<code>addNamedNativeQuery</code>
<code>addNamedQuery</code>
<code>getName</code>
</DeprecatedMethod>
<DocblockTypeContradiction occurrences="1">
<DocblockTypeContradiction occurrences="2">
<code>! $definition</code>
<code>$definition</code>
</DocblockTypeContradiction>
<InvalidArrayOffset occurrences="1">
Expand Down Expand Up @@ -891,7 +887,8 @@
<PropertyTypeCoercion occurrences="1">
<code>$subClass-&gt;table</code>
</PropertyTypeCoercion>
<RedundantConditionGivenDocblockType occurrences="1">
<RedundantConditionGivenDocblockType occurrences="2">
<code>$parent-&gt;idGenerator</code>
<code>$parent-&gt;idGenerator</code>
</RedundantConditionGivenDocblockType>
<UndefinedInterfaceMethod occurrences="17">
Expand Down Expand Up @@ -922,13 +919,17 @@
<DeprecatedConstant occurrences="1">
<code>self::GENERATOR_TYPE_UUID</code>
</DeprecatedConstant>
<DeprecatedMethod occurrences="1">
<code>canEmulateSchemas</code>
</DeprecatedMethod>
<DeprecatedProperty occurrences="4">
<code>$this-&gt;columnNames</code>
<code>$this-&gt;columnNames</code>
<code>$this-&gt;columnNames</code>
<code>$this-&gt;columnNames</code>
</DeprecatedProperty>
<DocblockTypeContradiction occurrences="1">
<DocblockTypeContradiction occurrences="2">
<code>! $this-&gt;table</code>
<code>$this-&gt;table</code>
</DocblockTypeContradiction>
<InvalidDocblock occurrences="4">
Expand Down Expand Up @@ -1021,8 +1022,7 @@
<code>$this-&gt;fieldMappings[$idProperty]['columnName']</code>
<code>$this-&gt;fieldMappings[$idProperty]['columnName']</code>
</PossiblyUndefinedArrayOffset>
<PropertyNotSetInConstructor occurrences="7">
<code>$discriminatorColumn</code>
<PropertyNotSetInConstructor occurrences="6">
<code>$idGenerator</code>
<code>$isVersioned</code>
<code>$namespace</code>
Expand Down Expand Up @@ -1081,6 +1081,10 @@
</PossiblyFalseOperand>
</file>
<file src="lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php">
<DeprecatedMethod occurrences="2">
<code>canEmulateSchemas</code>
<code>canEmulateSchemas</code>
</DeprecatedMethod>
<MissingClosureParamType occurrences="1">
<code>$joinColumn</code>
</MissingClosureParamType>
Expand All @@ -1101,7 +1105,8 @@
<ArgumentTypeCoercion occurrences="1">
<code>$metadata</code>
</ArgumentTypeCoercion>
<DocblockTypeContradiction occurrences="1">
<DocblockTypeContradiction occurrences="2">
<code>! $class</code>
<code>$class</code>
</DocblockTypeContradiction>
<LessSpecificReturnStatement occurrences="1">
Expand Down Expand Up @@ -1286,11 +1291,7 @@
<code>$indexXml-&gt;options</code>
<code>$uniqueXml-&gt;options</code>
</PossiblyInvalidPropertyFetch>
<RedundantCast occurrences="1">
<code>(string) $attributes-&gt;name</code>
</RedundantCast>
<RedundantCondition occurrences="20">
<code>isset($attributes-&gt;name)</code>
<RedundantCondition occurrences="19">
<code>isset($xmlRoot-&gt;cache)</code>
<code>isset($xmlRoot-&gt;embedded)</code>
<code>isset($xmlRoot-&gt;field)</code>
Expand Down Expand Up @@ -1582,16 +1583,7 @@
<InvalidDocblock occurrences="1">
<code>final class PersistentCollection extends AbstractLazyCollection implements Selectable</code>
</InvalidDocblock>
<InvalidReturnStatement occurrences="5">
<code>$persister-&gt;slice($this, $offset, $length)</code>
<code>$this-&gt;collection</code>
<code>new ArrayCollection($persister-&gt;loadCriteria($this, $criteria))</code>
<code>parent::slice($offset, $length)</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="2">
<code>Collection&lt;TKey, T&gt;</code>
<code>array&lt;TKey,T&gt;</code>
</InvalidReturnType>
<InvalidReturnStatement occurrences="1"/>
<MissingParamType occurrences="2">
<code>$key</code>
<code>$offset</code>
Expand Down Expand Up @@ -1626,7 +1618,9 @@
<PropertyNotSetInConstructor occurrences="1">
<code>$backRefFieldName</code>
</PropertyNotSetInConstructor>
<RedundantConditionGivenDocblockType occurrences="3">
<RedundantConditionGivenDocblockType occurrences="5">
<code>$this-&gt;em</code>
<code>$this-&gt;em</code>
<code>is_object($this-&gt;collection)</code>
<code>is_object($value) &amp;&amp; $this-&gt;em</code>
<code>is_object($value) &amp;&amp; $this-&gt;em</code>
Expand Down Expand Up @@ -1852,9 +1846,6 @@
<PropertyTypeCoercion occurrences="1">
<code>$this-&gt;currentPersisterContext-&gt;sqlTableAliases</code>
</PropertyTypeCoercion>
<RedundantCondition occurrences="1">
<code>($comparison === Comparison::EQ || $comparison === Comparison::IS) &amp;&amp; $value === null</code>
</RedundantCondition>
<RedundantConditionGivenDocblockType occurrences="1">
<code>$this-&gt;insertSql !== null</code>
</RedundantConditionGivenDocblockType>
Expand Down Expand Up @@ -1895,11 +1886,6 @@
<code>$columnList</code>
</PossiblyUndefinedVariable>
</file>
<file src="lib/Doctrine/ORM/Persisters/SqlValueVisitor.php">
<RedundantCondition occurrences="1">
<code>($operator === Comparison::EQ || $operator === Comparison::IS) &amp;&amp; $value === null</code>
</RedundantCondition>
</file>
<file src="lib/Doctrine/ORM/Proxy/ProxyFactory.php">
<ArgumentTypeCoercion occurrences="2">
<code>$classMetadata</code>
Expand Down Expand Up @@ -2195,6 +2181,9 @@
<ArgumentTypeCoercion occurrences="1">
<code>$this-&gt;stringPrimary</code>
</ArgumentTypeCoercion>
<DeprecatedMethod occurrences="1">
<code>getLowerExpression</code>
</DeprecatedMethod>
<PropertyNotSetInConstructor occurrences="1">
<code>$stringPrimary</code>
</PropertyNotSetInConstructor>
Expand Down Expand Up @@ -2224,6 +2213,9 @@
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php">
<DeprecatedMethod occurrences="1">
<code>getSqrtExpression</code>
</DeprecatedMethod>
<PropertyNotSetInConstructor occurrences="1">
<code>$simpleArithmeticExpression</code>
</PropertyNotSetInConstructor>
Expand Down Expand Up @@ -2262,6 +2254,9 @@
<ArgumentTypeCoercion occurrences="1">
<code>$this-&gt;stringPrimary</code>
</ArgumentTypeCoercion>
<DeprecatedMethod occurrences="1">
<code>getUpperExpression</code>
</DeprecatedMethod>
<PropertyNotSetInConstructor occurrences="1">
<code>$stringPrimary</code>
</PropertyNotSetInConstructor>
Expand Down Expand Up @@ -2848,22 +2843,23 @@
</PossiblyUndefinedArrayOffset>
</file>
<file src="lib/Doctrine/ORM/Query/SqlWalker.php">
<DocblockTypeContradiction occurrences="10">
<code>! ($factor instanceof AST\ConditionalFactor)</code>
<code>$condExpr instanceof AST\ConditionalExpression</code>
<code>$condTerm instanceof AST\ConditionalTerm</code>
<code>$simpleArithmeticExpr instanceof AST\SimpleArithmeticExpression</code>
<DocblockTypeContradiction occurrences="8">
<code>$likeExpr-&gt;stringPattern instanceof AST\Functions\FunctionNode</code>
<code>$likeExpr-&gt;stringPattern instanceof AST\PathExpression</code>
<code>$this-&gt;queryComponents[$dqlAlias]['relation'] === null</code>
<code>''</code>
<code>is_numeric($leftExpr) ? $leftExpr : $this-&gt;conn-&gt;quote($leftExpr)</code>
<code>is_numeric($rightExpr) ? $rightExpr : $this-&gt;conn-&gt;quote($rightExpr)</code>
<code>is_numeric($leftExpr)</code>
<code>is_numeric($rightExpr)</code>
<code>is_string($expression)</code>
<code>is_string($stringExpr)</code>
</DocblockTypeContradiction>
<ImplicitToStringCast occurrences="1">
<code>$expr</code>
</ImplicitToStringCast>
<InvalidArgument occurrences="1">
<InvalidArgument occurrences="4">
<code>$condExpr</code>
<code>$condTerm</code>
<code>$factor</code>
<code>$selectedClass['class']-&gt;name</code>
</InvalidArgument>
<InvalidArrayOffset occurrences="1">
Expand Down Expand Up @@ -2934,10 +2930,12 @@
<code>$this-&gt;queryComponents</code>
<code>$this-&gt;selectedClasses</code>
</PropertyTypeCoercion>
<RedundantConditionGivenDocblockType occurrences="5">
<RedundantConditionGivenDocblockType occurrences="7">
<code>$leftExpr instanceof AST\Node</code>
<code>$likeExpr-&gt;stringPattern instanceof AST\InputParameter</code>
<code>$rightExpr instanceof AST\Node</code>
<code>$this-&gt;conn-&gt;quote($leftExpr)</code>
<code>$this-&gt;conn-&gt;quote($rightExpr)</code>
<code>$whereClause !== null</code>
<code>($factor-&gt;not ? 'NOT ' : '') . $this-&gt;walkConditionalPrimary($factor-&gt;conditionalPrimary)</code>
</RedundantConditionGivenDocblockType>
Expand Down Expand Up @@ -3300,13 +3298,9 @@
<MissingReturnType occurrences="1">
<code>configure</code>
</MissingReturnType>
<PossiblyNullArgument occurrences="2">
<code>$cacheDriver</code>
<PossiblyNullArgument occurrences="1">
<code>$cacheDriver</code>
</PossiblyNullArgument>
<PossiblyNullReference occurrences="1">
<code>deleteAll</code>
</PossiblyNullReference>
</file>
<file src="lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php">
<ArgumentTypeCoercion occurrences="1">
Expand Down Expand Up @@ -3507,7 +3501,9 @@
<code>(array) $metadata-&gt;table['options']</code>
<code>(bool) $embeddablesImmutable</code>
</RedundantCastGivenDocblockType>
<RedundantConditionGivenDocblockType occurrences="1">
<RedundantConditionGivenDocblockType occurrences="3">
<code>$metadata-&gt;sequenceGeneratorDefinition</code>
<code>$metadata-&gt;sequenceGeneratorDefinition</code>
<code>isset($metadata-&gt;lifecycleCallbacks)</code>
</RedundantConditionGivenDocblockType>
</file>
Expand Down Expand Up @@ -3582,6 +3578,10 @@
<NonInvariantDocblockPropertyType occurrences="1">
<code>$_extension</code>
</NonInvariantDocblockPropertyType>
<RedundantConditionGivenDocblockType occurrences="2">
<code>$metadata-&gt;table</code>
<code>$metadata-&gt;table</code>
</RedundantConditionGivenDocblockType>
</file>
<file src="lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php">
<ArgumentTypeCoercion occurrences="3">
Expand All @@ -3608,10 +3608,12 @@
<PossiblyNullReference occurrences="1">
<code>addAttribute</code>
</PossiblyNullReference>
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$field['associationKey']</code>
<code>isset($field['associationKey']) &amp;&amp; $field['associationKey']</code>
</RedundantCondition>
<RedundantConditionGivenDocblockType occurrences="1">
<RedundantConditionGivenDocblockType occurrences="2">
<code>$sequenceDefinition</code>
<code>isset($metadata-&gt;lifecycleCallbacks)</code>
</RedundantConditionGivenDocblockType>
</file>
Expand Down Expand Up @@ -3648,6 +3650,10 @@
</RedundantConditionGivenDocblockType>
</file>
<file src="lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php">
<DeprecatedMethod occurrences="2">
<code>getCountExpression</code>
<code>getCountExpression</code>
</DeprecatedMethod>
<MoreSpecificImplementedParamType occurrences="1">
<code>$query</code>
</MoreSpecificImplementedParamType>
Expand Down Expand Up @@ -3701,7 +3707,8 @@
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php">
<DocblockTypeContradiction occurrences="2">
<DocblockTypeContradiction occurrences="3">
<code>$AST-&gt;whereClause-&gt;conditionalExpression instanceof ConditionalFactor</code>
<code>$AST-&gt;whereClause-&gt;conditionalExpression instanceof ConditionalPrimary</code>
</DocblockTypeContradiction>
<ImplementedReturnTypeMismatch occurrences="1">
Expand All @@ -3713,12 +3720,16 @@
<PossiblyInvalidPropertyAssignmentValue occurrences="1">
<code>$AST-&gt;whereClause-&gt;conditionalExpression</code>
</PossiblyInvalidPropertyAssignmentValue>
<RedundantConditionGivenDocblockType occurrences="1">
<code>$AST-&gt;whereClause-&gt;conditionalExpression instanceof ConditionalExpression</code>
</RedundantConditionGivenDocblockType>
<RedundantConditionGivenDocblockType occurrences="1"/>
</file>
<file src="lib/Doctrine/ORM/Tools/SchemaTool.php">
<DocblockTypeContradiction occurrences="1">
<DeprecatedMethod occurrences="3">
<code>canEmulateSchemas</code>
<code>compare</code>
<code>setExplicitForeignKeyIndexes</code>
</DeprecatedMethod>
<DocblockTypeContradiction occurrences="2">
<code>! $definingClass</code>
<code>$definingClass</code>
</DocblockTypeContradiction>
<MissingClosureParamType occurrences="1">
Expand Down
Loading

0 comments on commit cac2aca

Please sign in to comment.