Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Psalm v5 #10252

Merged
merged 1 commit into from Nov 26, 2022
Merged

Upgrade to Psalm v5 #10252

merged 1 commit into from Nov 26, 2022

Conversation

greg0ire
Copy link
Member

It is not stable yet, but should be good enough, and this will help taking care of #10118

Let us baseline all the new issues, just because they are new does not mean they are more important than already-baselined errors. Besides, it is more important to have higher standards for new code than to get an increased baseline.

Here are the errors getting baselined:

ERROR: RedundantCondition - lib/Doctrine/ORM/Cache/DefaultQueryCache.php:264:9 - Type Doctrine\ORM\Mapping\ClassMetadata<object> for $cm is always Doctrine\ORM\Mapping\ClassMetadata (see https://psalm.dev/122)
        assert($cm instanceof ClassMetadata);


ERROR: InvalidReturnType - lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php:64:21 - The declared return type 'Doctrine\ORM\Mapping\ClassMetadata<T:fn-doctrine\orm\entitymanagerinterface::getclassmetadata as object>' for Doctrine\ORM\Decorator\EntityManagerDecorator::getClassMetadata is incorrect, got 'Doctrine\ORM\Mapping\ClassMetadata<object>' (see https://psalm.dev/011)
    public function getClassMetadata($className)


ERROR: InvalidReturnStatement - lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php:66:16 - The inferred type 'Doctrine\ORM\Mapping\ClassMetadata<object>' does not match the declared return type 'Doctrine\ORM\Mapping\ClassMetadata<T:fn-doctrine\orm\entitymanagerinterface::getclassmetadata as object>' for Doctrine\ORM\Decorator\EntityManagerDecorator::getClassMetadata (see https://psalm.dev/128)
        return $this->wrapped->getClassMetadata($className);


ERROR: ParamNameMismatch - lib/Doctrine/ORM/EntityManager.php:802:35 - Argument 1 of Doctrine\ORM\EntityManager::getRepository has wrong name $entityName, expecting $className as defined by Doctrine\Persistence\ObjectManager::getRepository (see https://psalm.dev/230)
    public function getRepository($entityName)


ERROR: RedundantCondition - lib/Doctrine/ORM/EntityManager.php:822:15 - Doctrine\Persistence\ObjectRepository<T:fn-doctrine\orm\entitymanager::getrepository as object> cannot be identical to Doctrine\ORM\EntityRepository (see https://psalm.dev/122)
        if (! $repository instanceof EntityRepository) {


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Id/SequenceGenerator.php:97:21 - Method Doctrine\ORM\Id\SequenceGenerator::serialize must have a return type signature! (see https://psalm.dev/282)
    public function serialize()


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Id/SequenceGenerator.php:118:21 - Method Doctrine\ORM\Id\SequenceGenerator::unserialize must have a return type signature! (see https://psalm.dev/282)
    public function unserialize($serialized)


ERROR: ReferenceConstraintViolation - lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php:484:9 - Variable $nonemptyComponents is limited to values of type array<string, bool> because it is passed by reference, array<array-key, bool> type found. Use @param-out to specify a different output type (see https://psalm.dev/086)
        return $rowData;


ERROR: UnsupportedReferenceUsage - lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php:97:21 - This reference cannot be analyzed by Psalm (see https://psalm.dev/312)
                    $baseElement =& $this->_resultPointers[$parent][key($first)];


ERROR: ReferenceReusedFromConfusingScope - lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php:97:21 - $baseElement is possibly a reference defined at lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php:97:21. Reusing this variable may cause the referenced value to change. (see https://psalm.dev/308)
                    $baseElement =& $this->_resultPointers[$parent][key($first)];


ERROR: UnsupportedReferenceUsage - lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php:278:9 - This reference cannot be analyzed by Psalm (see https://psalm.dev/312)
        $this->_resultPointers[$dqlAlias] =& $coll[key($coll)];


ERROR: MissingTemplateParam - lib/Doctrine/ORM/Internal/Hydration/IterableResult.php:16:33 - Doctrine\ORM\Internal\Hydration\IterableResult has missing template params when extending Iterator, expecting 2 (see https://psalm.dev/182)
class IterableResult implements Iterator


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:944:21 - Method Doctrine\ORM\Mapping\ClassMetadataInfo::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: InvalidPropertyAssignmentValue - lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:2995:9 - $this->sqlResultSetMappings with declared type 'array<string, array{columns: array<array-key, mixed>, entities: array<array-key, mixed>, name: string}>' cannot be assigned type 'non-empty-array<array-key, array{entities: array<array-key, mixed>|mixed, name: mixed|string, ...<string, mixed>}>' (see https://psalm.dev/145)
        $this->sqlResultSetMappings[$resultMapping['name']] = $resultMapping;


ERROR: RedundantCondition - lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:80:18 - Type ReflectionClass<T:Doctrine\ORM\Mapping\ClassMetadata as object> for $<tmp coalesce var>2110 is never null (see https://psalm.dev/122)
        $class = $metadata->getReflectionClass()


ERROR: TypeDoesNotContainNull - lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:83:16 - Cannot resolve types for $<tmp coalesce var>2110 - ReflectionClass<T> does not contain null (see https://psalm.dev/090)
            ?? new ReflectionClass($metadata->name);


ERROR: RedundantCondition - lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php:109:28 - Type ReflectionClass<T:Doctrine\ORM\Mapping\ClassMetadata as object> for $<tmp coalesce var>2791 is never null (see https://psalm.dev/122)
        $reflectionClass = $metadata->getReflectionClass()


ERROR: TypeDoesNotContainNull - lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php:112:16 - Cannot resolve types for $<tmp coalesce var>2791 - ReflectionClass<T> does not contain null (see https://psalm.dev/090)
            ?? new ReflectionClass($metadata->name);


ERROR: TypeDoesNotContainType - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php:94:13 - 'entity' cannot be identical to class-string (see https://psalm.dev/056)
        if ($xmlRoot->getName() === 'entity') {


ERROR: TypeDoesNotContainType - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php:102:19 - 'mapped-superclass' cannot be identical to class-string (see https://psalm.dev/056)
        } elseif ($xmlRoot->getName() === 'mapped-superclass') {


ERROR: TypeDoesNotContainType - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php:107:19 - 'embeddable' cannot be identical to class-string (see https://psalm.dev/056)
        } elseif ($xmlRoot->getName() === 'embeddable') {


ERROR: NoInterfaceProperties - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php:205:27 - Interfaces cannot have properties (see https://psalm.dev/028)
                if (isset($xmlRoot->{'discriminator-column'})) {


ERROR: PossiblyInvalidPropertyFetch - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php:205:27 - Cannot fetch property on possible non-object $xmlRoot of type non-empty-array<array-key, mixed> (see https://psalm.dev/114)
                if (isset($xmlRoot->{'discriminator-column'})) {


ERROR: NoInterfaceProperties - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php:220:27 - Interfaces cannot have properties (see https://psalm.dev/028)
                if (isset($xmlRoot->{'discriminator-map'})) {


ERROR: PossiblyInvalidPropertyFetch - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php:220:27 - Cannot fetch property on possible non-object $xmlRoot of type array{'inheritance-type': mixed, ...<array-key, mixed>} (see https://psalm.dev/114)
                if (isset($xmlRoot->{'discriminator-map'})) {


ERROR: InvalidReturnType - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php:848:23 - The declared return type 'array{columnDefinition?: string, columnName?: string, enumType?: string, fieldName: string, length?: int, notInsertable?: bool, notUpdatable?: bool, nullable?: bool, options?: array<array-key, mixed>, precision?: int, scale?: int, type?: string, unique?: bool, version?: bool}' for Doctrine\ORM\Mapping\Driver\XmlDriver::columnToArray is incorrect, got 'array{columnDefinition?: string, columnName?: string, enumType?: string, fieldName: string, generated?: mixed, length?: int, notInsertable?: true, notUpdatable?: true, nullable?: bool, options?: array<int|string, array<int|string, mixed|string>|bool|string>, precision?: int, scale?: int, type?: string, unique?: bool, version?: bool}' (see https://psalm.dev/011)
      * @psalm-return array{
      *                   fieldName: string,
      *                   type?: string,
      *                   columnName?: string,
      *                   length?: int,
      *                   precision?: int,
      *                   scale?: int,
      *                   unique?: bool,
      *                   nullable?: bool,
      *                   notInsertable?: bool,
      *                   notUpdatable?: bool,
      *                   enumType?: string,
      *                   version?: bool,
      *                   columnDefinition?: string,
      *                   options?: array
      *               }


ERROR: InvalidReturnStatement - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php:927:16 - The inferred type 'array{columnDefinition?: string, columnName?: string, enumType?: string, fieldName: string, generated?: mixed, length?: int, notInsertable?: true, notUpdatable?: true, nullable?: bool, options?: array<int|string, array<int|string, mixed|string>|bool|string>, precision?: int, scale?: int, type?: string, unique?: bool, version?: bool}' does not match the declared return type 'array{columnDefinition?: string, columnName?: string, enumType?: string, fieldName: string, length?: int, notInsertable?: bool, notUpdatable?: bool, nullable?: bool, options?: array<array-key, mixed>, precision?: int, scale?: int, type?: string, unique?: bool, version?: bool}' for Doctrine\ORM\Mapping\Driver\XmlDriver::columnToArray (see https://psalm.dev/128)
        return $mapping;


ERROR: PropertyNotSetInConstructor - lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php:20:7 - Property Doctrine\ORM\Mapping\ReflectionEmbeddedProperty::$name is not defined in constructor of Doctrine\ORM\Mapping\ReflectionEmbeddedProperty or in any private or final methods called in the constructor (see https://psalm.dev/074)
class ReflectionEmbeddedProperty extends ReflectionProperty


ERROR: PropertyNotSetInConstructor - lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php:20:7 - Property Doctrine\ORM\Mapping\ReflectionEmbeddedProperty::$class is not defined in constructor of Doctrine\ORM\Mapping\ReflectionEmbeddedProperty or in any private or final methods called in the constructor (see https://psalm.dev/074)
class ReflectionEmbeddedProperty extends ReflectionProperty


ERROR: PropertyNotSetInConstructor - lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php:16:7 - Property Doctrine\ORM\Mapping\ReflectionEnumProperty::$name is not defined in constructor of Doctrine\ORM\Mapping\ReflectionEnumProperty or in any private or final methods called in the constructor (see https://psalm.dev/074)
class ReflectionEnumProperty extends ReflectionProperty


ERROR: PropertyNotSetInConstructor - lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php:16:7 - Property Doctrine\ORM\Mapping\ReflectionEnumProperty::$class is not defined in constructor of Doctrine\ORM\Mapping\ReflectionEnumProperty or in any private or final methods called in the constructor (see https://psalm.dev/074)
class ReflectionEnumProperty extends ReflectionProperty


ERROR: PropertyNotSetInConstructor - lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php:18:13 - Property Doctrine\ORM\Mapping\ReflectionReadonlyProperty::$name is not defined in constructor of Doctrine\ORM\Mapping\ReflectionReadonlyProperty or in any methods called in the constructor (see https://psalm.dev/074)
final class ReflectionReadonlyProperty extends ReflectionProperty


ERROR: PropertyNotSetInConstructor - lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php:18:13 - Property Doctrine\ORM\Mapping\ReflectionReadonlyProperty::$class is not defined in constructor of Doctrine\ORM\Mapping\ReflectionReadonlyProperty or in any methods called in the constructor (see https://psalm.dev/074)
final class ReflectionReadonlyProperty extends ReflectionProperty


ERROR: ParamNameMismatch - lib/Doctrine/ORM/PersistentCollection.php:458:25 - Argument 1 of Doctrine\ORM\PersistentCollection::add has wrong name $value, expecting $element as defined by Doctrine\Common\Collections\AbstractLazyCollection::add (see https://psalm.dev/230)
    public function add($value): bool


ERROR: ImplementedReturnTypeMismatch - lib/Doctrine/ORM/PersistentCollection.php:507:16 - The inherited return type 'null' for Doctrine\Common\Collections\AbstractLazyCollection::offsetUnset is different to the implemented return type for Doctrine\ORM\PersistentCollection::offsetunset 'null|object' (see https://psalm.dev/123)
     * @return object|null


ERROR: PossiblyNullArrayAccess - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php:44:18 - Cannot access array value on possibly null variable $mapping['joinTable'] of type mixed|null (see https://psalm.dev/079)
        foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {


ERROR: PossiblyNullArrayAccess - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php:429:18 - Cannot access array value on possibly null variable $mapping['joinTable'] of type mixed|null (see https://psalm.dev/079)
        foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {


ERROR: PossiblyNullArrayAccess - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php:477:18 - Cannot access array value on possibly null variable $mapping['joinTable'] of type mixed|null (see https://psalm.dev/079)
        foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {


ERROR: PossiblyNullArrayAccess - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php:548:69 - Cannot access array value on possibly null variable $mapping['relationToSourceKeyColumns'] of type mixed|null (see https://psalm.dev/079)
                $params[] = $identifier1[$class1->getFieldForColumn($mapping['relationToSourceKeyColumns'][$joinTableColumn])];


ERROR: PossiblyNullArrayAccess - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php:553:65 - Cannot access array value on possibly null variable $mapping['relationToTargetKeyColumns'] of type mixed|null (see https://psalm.dev/079)
            $params[] = $identifier2[$class2->getFieldForColumn($mapping['relationToTargetKeyColumns'][$joinTableColumn])];


ERROR: PossiblyNullArrayAccess - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php:589:39 - Cannot access array value on possibly null variable $mapping['joinTable'] of type mixed|null (see https://psalm.dev/079)
            $joinColumns            = $mapping['joinTable']['inverseJoinColumns'];


ERROR: InvalidArgument - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:841:75 - Argument 3 of Doctrine\ORM\Internal\Hydration\AbstractHydrator::hydrateAll expects array<string, string>, but array{'doctrine.refresh': true} provided (see https://psalm.dev/004)
        $hydrator->hydrateAll($stmt, $this->currentPersisterContext->rsm, [Query::HINT_REFRESH => true]);


ERROR: InvalidArgument - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:873:82 - Argument 3 of Doctrine\ORM\Internal\Hydration\AbstractHydrator::hydrateAll expects array<string, string>, but array{deferEagerLoad: true} provided (see https://psalm.dev/004)
        return $hydrator->hydrateAll($stmt, $this->currentPersisterContext->rsm, [UnitOfWork::HINT_DEFEREAGERLOAD => true]);


ERROR: InvalidArgument - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:920:82 - Argument 3 of Doctrine\ORM\Internal\Hydration\AbstractHydrator::hydrateAll expects array<string, string>, but array{deferEagerLoad: true} provided (see https://psalm.dev/004)
        return $hydrator->hydrateAll($stmt, $this->currentPersisterContext->rsm, [UnitOfWork::HINT_DEFEREAGERLOAD => true]);


ERROR: InvalidArgument - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:978:87 - Argument 3 of Doctrine\ORM\Internal\Hydration\AbstractHydrator::hydrateAll expects array<string, string>, but array{collection: Doctrine\ORM\PersistentCollection<array-key, mixed>, deferEagerLoad: true} provided (see https://psalm.dev/004)
        return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints);


ERROR: MissingTemplateParam - lib/Doctrine/ORM/Proxy/Proxy.php:12:25 - Doctrine\ORM\Proxy\Proxy has missing template params when extending Doctrine\Common\Proxy\Proxy, expecting 1 (see https://psalm.dev/182)
interface Proxy extends BaseProxy


ERROR: InvalidArgument - lib/Doctrine/ORM/Query.php:320:13 - Argument 2 of Doctrine\ORM\Query::evictResultSetCache expects array<string, mixed>, but list<mixed> provided (see https://psalm.dev/004)
            $sqlParams,


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/AST/Node.php:46:21 - Method Doctrine\ORM\Query\AST\Node::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: PropertyNotSetInConstructor - lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php:25:7 - Property Doctrine\ORM\Query\Exec\MultiTableUpdateExecutor::$queryCacheProfile is not defined in constructor of Doctrine\ORM\Query\Exec\MultiTableUpdateExecutor or in any private or final methods called in the constructor (see https://psalm.dev/074)
class MultiTableUpdateExecutor extends AbstractSqlExecutor


ERROR: UninitializedProperty - lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php:122:17 - Cannot use uninitialized property $this->_sqlStatements (see https://psalm.dev/186)
                $this->_sqlStatements[$i] = $updateSql . ' WHERE (' . $idColumnList . ') IN (' . $idSubselect . ')';


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/Expr/Base.php:95:21 - Method Doctrine\ORM\Query\Expr\Base::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/Expr/Comparison.php:63:21 - Method Doctrine\ORM\Query\Expr\Comparison::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/Expr/Composite.php:19:21 - Method Doctrine\ORM\Query\Expr\Composite::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/Expr/From.php:54:21 - Method Doctrine\ORM\Query\Expr\From::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/Expr/Func.php:48:21 - Method Doctrine\ORM\Query\Expr\Func::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/Expr/Join.php:109:21 - Method Doctrine\ORM\Query\Expr\Join::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/Expr/Math.php:56:21 - Method Doctrine\ORM\Query\Expr\Math::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/Expr/OrderBy.php:71:21 - Method Doctrine\ORM\Query\Expr\OrderBy::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/Filter/SQLFilter.php:176:27 - Method Doctrine\ORM\Query\Filter\SQLFilter::__toString must have a return type signature! (see https://psalm.dev/282)
    final public function __toString()


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:362:32 - Argument 1 of Doctrine\ORM\Query\Parser::syntaxError expects string, but possibly different type int|string provided (see https://psalm.dev/092)
            $this->syntaxError($this->lexer->getLiteral($token));


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:367:32 - Argument 1 of Doctrine\ORM\Query\Parser::syntaxError expects string, but possibly different type int|string provided (see https://psalm.dev/092)
            $this->syntaxError($this->lexer->getLiteral($token));


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:372:32 - Argument 1 of Doctrine\ORM\Query\Parser::syntaxError expects string, but possibly different type int|string provided (see https://psalm.dev/092)
            $this->syntaxError($this->lexer->getLiteral($token));


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:1129:70 - Argument 2 of Doctrine\ORM\Query\AST\JoinAssociationPathExpression::__construct expects string, but possibly different type int|string provided (see https://psalm.dev/092)
        return new AST\JoinAssociationPathExpression($identVariable, $field);


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:1162:76 - Argument 3 of Doctrine\ORM\Query\AST\PathExpression::__construct expects null|string, but possibly different type int|null|string provided (see https://psalm.dev/092)
        $pathExpr = new AST\PathExpression($expectedTypes, $identVariable, $field);


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:1641:43 - Argument 1 of Doctrine\ORM\Query\AST\InputParameter::__construct expects string, but possibly different type int|null|string provided (see https://psalm.dev/092)
            return new AST\InputParameter($this->lexer->token['value']);


ERROR: InvalidPropertyAssignmentValue - lib/Doctrine/ORM/Query/Parser.php:2464:13 - $this->queryComponents with declared type 'array<string, array{map?: null|string, metadata?: Doctrine\ORM\Mapping\ClassMetadata<object>, nestingLevel: int, parent?: null|string, relation?: array<array-key, mixed>|null, resultVariable?: Doctrine\ORM\Query\AST\Node|string, token: array{position: int, type: int|null|string, value: int|string}}>' cannot be assigned type 'non-empty-array<string, array{map?: null|string, metadata?: Doctrine\ORM\Mapping\ClassMetadata<object>, nestingLevel: int, parent?: null|string, relation?: array<array-key, mixed>|null, resultVariable?: Doctrine\ORM\Query\AST\Node|string, resultvariable?: Doctrine\ORM\Query\AST\SimpleSelectExpression, token: array{position: int, type: int|null|string, value: int|string}}>' (see https://psalm.dev/145)
            $this->queryComponents[$resultVariable] = [


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:2811:39 - Argument 1 of Doctrine\ORM\Query\AST\InputParameter::__construct expects string, but possibly different type int|null|string provided (see https://psalm.dev/092)
        return new AST\InputParameter($this->lexer->token['value']);


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:3111:44 - Argument 1 of Doctrine\ORM\Query\AST\AggregateExpression::__construct expects string, but possibly different type int|null|string provided (see https://psalm.dev/092)
        return new AST\AggregateExpression($functionName, $pathExp, $isDistinct);


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:3273:43 - Argument 1 of Doctrine\ORM\Query\AST\InputParameter::__construct expects string, but possibly different type int|null|string provided (see https://psalm.dev/092)
            return new AST\InputParameter($this->lexer->token['value']);


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:3302:53 - Argument 1 of Doctrine\ORM\Query\AST\InputParameter::__construct expects string, but possibly different type int|null|string provided (see https://psalm.dev/092)
            $stringPattern = new AST\InputParameter($this->lexer->token['value']);


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:3333:48 - Argument 1 of Doctrine\ORM\Query\AST\InputParameter::__construct expects string, but possibly different type int|null|string provided (see https://psalm.dev/092)
                $expr = new AST\InputParameter($this->lexer->token['value']);


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:3596:83 - Argument 1 of Doctrine\ORM\Configuration::getCustomDatetimeFunction expects string, but possibly different type int|null|string provided (see https://psalm.dev/092)
        $functionClass = $this->em->getConfiguration()->getCustomDatetimeFunction($functionName);


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/Parser.php:3636:81 - Argument 1 of Doctrine\ORM\Configuration::getCustomStringFunction expects string, but possibly different type int|null|string provided (see https://psalm.dev/092)
        $functionClass = $this->em->getConfiguration()->getCustomStringFunction($functionName);


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php:491:21 - Method Doctrine\ORM\Query\ResultSetMappingBuilder::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/SqlWalker.php:1199:41 - Argument 1 of Doctrine\ORM\Query\SqlWalker::walkResultVariable expects string, but possibly different type int|string provided (see https://psalm.dev/092)
            : $this->walkResultVariable($this->queryComponents[$expr]['token']['value']);


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/SqlWalker.php:2455:45 - Argument 1 of Doctrine\ORM\Query\SqlWalker::walkResultVariable expects string, but possibly different type int|string provided (see https://psalm.dev/092)
                ? $this->walkResultVariable($this->queryComponents[$term]['token']['value'])


ERROR: PossiblyInvalidArgument - lib/Doctrine/ORM/Query/SqlWalker.php:2479:45 - Argument 1 of Doctrine\ORM\Query\SqlWalker::walkResultVariable expects string, but possibly different type int|string provided (see https://psalm.dev/092)
                ? $this->walkResultVariable($this->queryComponents[$factor]['token']['value'])


ERROR: MethodSignatureMustProvideReturnType - lib/Doctrine/ORM/QueryBuilder.php:1536:21 - Method Doctrine\ORM\QueryBuilder::__toString must have a return type signature! (see https://psalm.dev/282)
    public function __toString()


ERROR: MissingTemplateParam - lib/Doctrine/ORM/Tools/Console/MetadataFilter.php:25:7 - Doctrine\ORM\Tools\Console\MetadataFilter has missing template params when extending FilterIterator, expecting 3 (see https://psalm.dev/182)
class MetadataFilter extends FilterIterator implements Countable


ERROR: InvalidArgument - lib/Doctrine/ORM/Tools/Console/MetadataFilter.php:40:41 - Argument 1 of Doctrine\ORM\Tools\Console\MetadataFilter::__construct expects ArrayIterator<array-key, mixed>, but ArrayIterator<array-key, Doctrine\Persistence\Mapping\ClassMetadata<object>> provided (see https://psalm.dev/004)
        $metadatas = new MetadataFilter(new ArrayIterator($metadatas), $filter);


ERROR: InvalidArrayOffset - lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php:207:27 - Cannot access value on variable $field using offset value of 'version', expecting 'type', 'fieldName', 'columnName', 'length', 'id', 'nullable', 'notInsertable', 'notUpdatable', 'generated', 'enumType', 'columnDefinition', 'precision', 'scale', 'unique', 'inherited', 'originalClass', 'originalField', 'quoted', 'requireSQLConversion', 'declared', 'declaredField' or 'options' (see https://psalm.dev/115)
                if (isset($field['version'])) {


ERROR: InvalidArgument - lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php:244:57 - Argument 1 of Doctrine\ORM\Tools\Export\Driver\YamlExporter::processEntityListenerConfig expects array{entityListeners: array<class-string, array<string, list{string}>>}, but array{entityListeners: array<class-string, array<string, list{string}>>, ...<string, mixed>} provided (see https://psalm.dev/004)
            $array = $this->processEntityListenerConfig($array, $entityListenerConfig, $event);


ERROR: InvalidArgument - lib/Doctrine/ORM/UnitOfWork.php:425:94 - Argument 1 of Doctrine\ORM\Persisters\Collection\CollectionPersister::delete expects Doctrine\ORM\PersistentCollection<array-key, mixed>, but Doctrine\ORM\PersistentCollection<array-key, object> provided (see https://psalm.dev/004)
                    $this->getCollectionPersister($collectionToDelete->getMapping())->delete($collectionToDelete);


ERROR: RedundantCondition - lib/Doctrine/ORM/UnitOfWork.php:453:69 - Type non-empty-array<int, object> for $this->entityDeletions is never falsy (see https://psalm.dev/122)
                for ($count = count($commitOrder), $i = $count - 1; $i >= 0 && $this->entityDeletions; --$i) {


ERROR: RedundantCondition - lib/Doctrine/ORM/UnitOfWork.php:453:80 - Operand of type non-empty-array<int, object> is always truthy (see https://psalm.dev/122)
                for ($count = count($commitOrder), $i = $count - 1; $i >= 0 && $this->entityDeletions; --$i) {


ERROR: NoValue - lib/Doctrine/ORM/UnitOfWork.php:1846:21 - This function or method call never returns output (see https://psalm.dev/179)
                    $entityState,


ERROR: NoValue - lib/Doctrine/ORM/UnitOfWork.php:1919:21 - This function or method call never returns output (see https://psalm.dev/179)
                    $entityState,


------------------------------
87 errors found
------------------------------
4432 other issues found.
You can display them with --show-info=true
------------------------------
Psalm can automatically fix 68 of these issues.
Run Psalm again with
--alter --issues=InvalidFalsableReturnType,InvalidNullableReturnType,InvalidReturnType,MissingReturnType,MissingParamType --dry-run
to see what it can fix.

It is not stable yet, but should be good enough, and this will help
taking care of doctrine#10118

Let us baseline all the new issues, just because they are new does not
mean they are more important than already-baselined errors. Besides, it
is more important to have higher standards for new code than to get an
increased baseline.
Copy link
Member

@beberlei beberlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to start this way!

@greg0ire greg0ire merged commit 57ac275 into doctrine:2.13.x Nov 26, 2022
@greg0ire greg0ire deleted the psalm-5 branch November 26, 2022 13:11
@derrabus
Copy link
Member

@greg0ire greg0ire added this to the 2.13.5 milestone Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants