<?xml version="1.0"?>
<psalm
    errorLevel="2"
    phpVersion="8.2"
    resolveFromConfigFile="true"
    findUnusedBaselineEntry="true"
    findUnusedCode="false"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="https://getpsalm.org/schema/config"
    xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
    errorBaseline="psalm-baseline.xml"
>
    <projectFiles>
        <directory name="src" />
        <directory name="tests/StaticAnalysis" />
        <ignoreFiles>
            <directory name="vendor" />
            <file name="src/Mapping/Driver/AttributeReader.php" />
        </ignoreFiles>
    </projectFiles>
    <enableExtensions>
        <extension name="simplexml" />
    </enableExtensions>
    <issueHandlers>
        <DeprecatedClass>
            <errorLevel type="suppress">
                <!-- DBAL 2 compatibility -->
                <referencedClass name="Doctrine\DBAL\Tools\Console\Command\ImportCommand"/>
                <referencedClass name="Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper"/>
                <!-- The exception is thrown by a deprecated method. -->
                <referencedClass name="Doctrine\ORM\Cache\Exception\InvalidResultCacheDriver"/>
                <!-- We wire the command as long as DBAL ships it -->
                <referencedClass name="Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand" />
                <!-- Remove on 3.0.x -->
                <referencedClass name="Doctrine\Common\Persistence\PersistentObject"/>
                <referencedClass name="Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets"/>
                <referencedClass name="Doctrine\ORM\Event\LifecycleEventArgs"/>
                <referencedClass name="Doctrine\ORM\Exception\UnknownEntityNamespace"/>
                <referencedClass name="Doctrine\ORM\Mapping\Driver\AnnotationDriver"/>
                <referencedClass name="Doctrine\ORM\Mapping\Driver\YamlDriver"/>
                <referencedClass name="Doctrine\ORM\Mapping\NamedNativeQueries"/>
                <referencedClass name="Doctrine\ORM\Mapping\NamedNativeQuery"/>
                <referencedClass name="Doctrine\ORM\Mapping\NamedQueries"/>
                <referencedClass name="Doctrine\ORM\Mapping\NamedQuery"/>
                <referencedClass name="Doctrine\ORM\Query\AST\InExpression"/>
                <referencedClass name="Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand"/>
                <referencedClass name="Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand"/>
                <referencedClass name="Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand"/>
                <referencedClass name="Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand"/>
                <referencedClass name="Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand"/>
                <referencedClass name="Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper"/>
                <referencedClass name="Doctrine\ORM\Tools\Console\EntityManagerProvider\HelperSetManagerProvider"/>
            </errorLevel>
        </DeprecatedClass>
        <DeprecatedConstant>
            <errorLevel type="suppress">
                <file name="src/Configuration.php"/>
                <file name="src/Query/Lexer.php"/>
                <file name="src/Query/Parser.php"/>
                <file name="src/QueryBuilder.php"/>
                <file name="src/Tools/EntityGenerator.php"/>
                <file name="src/Mapping/ClassMetadataInfo.php" />
                <file name="src/Tools/EntityGenerator.php" />
                <file name="src/Tools/Export/Driver/AbstractExporter.php" />
                <file name="src/Tools/SchemaTool.php" />
            </errorLevel>
        </DeprecatedConstant>
        <DeprecatedInterface>
            <errorLevel type="suppress">
                <!-- Remove on 3.0.x -->
                <referencedClass name="Doctrine\ORM\Cache\MultiGetRegion"/>
                <referencedClass name="Doctrine\ORM\Mapping\Annotation"/>
            </errorLevel>
        </DeprecatedInterface>
        <DeprecatedMethod>
            <errorLevel type="suppress">
                <!-- We're calling the deprecated method for BC here. -->
                <file name="src/Internal/SQLResultCasing.php"/>
                <referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getIdentitySequenceName"/>
                <referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::usesSequenceEmulatedIdentityColumns"/>
                <!-- We need to keep the calls for DBAL 2.13 compatibility. -->
                <referencedMethod name="Doctrine\DBAL\Cache\QueryCacheProfile::getResultCacheDriver"/>
                <referencedMethod name="Doctrine\DBAL\Cache\QueryCacheProfile::setResultCacheDriver"/>
                <referencedMethod name="Doctrine\DBAL\Configuration::getResultCacheImpl"/>
                <referencedMethod name="Doctrine\DBAL\Configuration::setResultCacheImpl"/>
                <referencedMethod name="Doctrine\DBAL\Connection::getSchemaManager"/>
                <referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getGuidExpression"/>
                <referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::supportsForeignKeyConstraints"/>
                <!-- Remove on 3.0.x -->
                <referencedMethod name="Doctrine\DBAL\Connection::getEventManager"/>
                <referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getReadLockSQL"/>
                <referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getWriteLockSQL"/>
                <referencedMethod name="Doctrine\DBAL\Schema\Schema::visit"/>
                <referencedMethod name="Doctrine\DBAL\Schema\SchemaDiff::toSaveSql"/>
                <referencedMethod name="Doctrine\DBAL\Schema\SchemaDiff::toSql"/>
                <referencedMethod name="Doctrine\ORM\Internal\Hydration\AbstractHydrator::hydrateRow"/>
                <referencedMethod name="Doctrine\ORM\Configuration::ensureProductionSettings"/>
                <referencedMethod name="Doctrine\ORM\Configuration::newDefaultAnnotationDriver"/>
                <referencedMethod name="Doctrine\ORM\EntityManager::createConnection"/>
                <referencedMethod name="Doctrine\ORM\EntityManagerInterface::getPartialReference"/>
                <referencedMethod name="Doctrine\ORM\Id\AbstractIdGenerator::generate"/>
                <referencedMethod name="Doctrine\ORM\ORMInvalidArgumentException::invalidEntityName"/>
                <referencedMethod name="Doctrine\ORM\ORMSetup::createDefaultAnnotationDriver"/>
                <referencedMethod name="Doctrine\ORM\Query\SqlWalker::walkInExpression"/>
                <referencedMethod name="Doctrine\ORM\Query\TreeWalkerAdapter::_getQueryComponents"/>
                <referencedMethod name="Doctrine\ORM\Mapping\ClassMetadataInfo::isInheritanceTypeTablePerClass"/>
                <file name="src/Query/TreeWalkerChain.php"/>
            </errorLevel>
        </DeprecatedMethod>
        <DeprecatedProperty>
            <errorLevel type="suppress">
                <referencedProperty name="Doctrine\ORM\Cache\Region\DefaultRegion::$cache"/>
                <referencedProperty name="Doctrine\ORM\Mapping\Driver\AttributeDriver::$entityAnnotationClasses"/>
            </errorLevel>
        </DeprecatedProperty>
        <DocblockTypeContradiction>
            <errorLevel type="suppress">
                <!-- We're catching invalid input here. -->
                <file name="src/Internal/Hydration/AbstractHydrator.php"/>

                <!-- DBAL 3.2 forward compatibility -->
                <file name="src/Tools/Pagination/CountOutputWalker.php"/>
                <file name="src/Tools/Pagination/LimitSubqueryOutputWalker.php"/>
                <!-- https://github.com/vimeo/psalm/issues/8520 -->
                <file name="src/PersistentCollection.php"/>
            </errorLevel>
        </DocblockTypeContradiction>
        <DuplicateClass>
            <errorLevel type="suppress">
                <file name="src/Tools/Console/CommandCompatibility.php"/>
                <file name="src/Tools/Console/Helper/EntityManagerHelper.php"/>
            </errorLevel>
        </DuplicateClass>
        <ForbiddenCode>
            <errorLevel type="suppress">
                <file name="src/Tools/Debug.php"/>
            </errorLevel>
        </ForbiddenCode>
        <InvalidArgument>
            <errorLevel type="suppress">
                <!-- Argument type changes in DBAL 3.2 -->
                <referencedFunction name="Doctrine\DBAL\Cache\QueryCacheProfile::__construct"/>
                <!-- https://github.com/vimeo/psalm/issues/9155 -->
                <referencedFunction name="Doctrine\ORM\Mapping\ClassMetadata::addInheritedAssociationMapping"/>
            </errorLevel>
        </InvalidArgument>
        <InvalidArrayAccess>
            <errorLevel type="suppress">
                <!-- https://github.com/vimeo/psalm/issues/9160 -->
                <file name="src/Mapping/ClassMetadataFactory.php"/>
            </errorLevel>
        </InvalidArrayAccess>
        <InvalidArrayAssignment>
            <errorLevel type="suppress">
                <!-- https://github.com/vimeo/psalm/issues/9160 -->
                <file name="src/Mapping/ClassMetadataFactory.php"/>
            </errorLevel>
        </InvalidArrayAssignment>
        <InvalidClass>
            <errorLevel type="suppress">
                <!-- Class name changes in DBAL 3. -->
                <referencedClass name="Doctrine\DBAL\Platforms\PostgreSQLPlatform" />
                <referencedClass name="Doctrine\DBAL\Platforms\MySQLPlatform" />
            </errorLevel>
        </InvalidClass>
        <InvalidParamDefault>
            <errorLevel type="suppress">
                <!-- Remove on 3.0.x -->
                <file name="src/Query/AST/InstanceOfExpression.php"/>
            </errorLevel>
        </InvalidParamDefault>
        <InvalidPropertyAssignmentValue>
            <errorLevel type="suppress">
                <!-- https://github.com/vimeo/psalm/issues/9155 -->
                <file name="src/Mapping/ClassMetadataFactory.php"/>
            </errorLevel>
        </InvalidPropertyAssignmentValue>
        <MethodSignatureMismatch>
            <errorLevel type="suppress">
                <!-- See https://github.com/vimeo/psalm/issues/7357 -->
                <file name="src/Mapping/ReflectionReadonlyProperty.php"/>
            </errorLevel>
        </MethodSignatureMismatch>
        <MissingDependency>
            <errorLevel type="suppress">
                <!-- DBAL 3.2 forward compatibility -->
                <file name="src/Internal/SQLResultCasing.php"/>
                <file name="src/Mapping/ClassMetadataFactory.php"/>
                <file name="src/Tools/Pagination/LimitSubqueryOutputWalker.php"/>
            </errorLevel>
        </MissingDependency>
        <MissingParamType>
            <errorLevel type="suppress">
                <!-- Persistence 2 compatibility -->
                <file name="src/EntityManager.php"/>
                <file name="src/Mapping/ClassMetadataFactory.php"/>
                <file name="src/Mapping/ClassMetadataInfo.php"/>
            </errorLevel>
        </MissingParamType>
        <NonInvariantDocblockPropertyType>
            <errorLevel type="suppress">
                <!-- Remove on 3.0.x -->
                <file name="src/Query/AST/InListExpression.php"/>
                <file name="src/Query/AST/InSubselectExpression.php"/>
            </errorLevel>
        </NonInvariantDocblockPropertyType>
        <PossiblyInvalidArgument>
            <errorLevel type="suppress">
                <!-- https://github.com/vimeo/psalm/issues/9155 -->
                <file name="src/Mapping/ClassMetadataFactory.php"/>
            </errorLevel>
        </PossiblyInvalidArgument>
        <PropertyNotSetInConstructor>
            <errorLevel type="suppress">
                <!-- Remove on 3.0.x -->
                <referencedProperty name="Doctrine\ORM\Cache\CacheKey::$hash"/>
            </errorLevel>
            <errorLevel type="suppress">
                <directory name="src/Query/AST" />
            </errorLevel>
        </PropertyNotSetInConstructor>
        <PropertyTypeCoercion>
            <errorLevel type="suppress">
                <file name="src/Mapping/ClassMetadataInfo.php"/>
            </errorLevel>
        </PropertyTypeCoercion>
        <RedundantCastGivenDocblockType>
            <errorLevel type="suppress">
                <!-- Can be removed once the "getMaxResults" methods of those classes have native parameter types -->
                <file name="src/Query.php"/>
                <file name="src/QueryBuilder.php"/>
            </errorLevel>
        </RedundantCastGivenDocblockType>
        <RedundantCondition>
            <errorLevel type="suppress">
                <!-- The SQLAnywherePlatform class may or may not exist depending on the DBAL version -->
                <file name="src/Mapping/ClassMetadataFactory.php"/>
            </errorLevel>
        </RedundantCondition>
        <ReferenceConstraintViolation>
            <errorLevel type="suppress">
                <!-- https://github.com/vimeo/psalm/issues/9155 -->
                <file name="src/Mapping/ClassMetadataFactory.php"/>
            </errorLevel>
        </ReferenceConstraintViolation>
        <RiskyTruthyFalsyComparison>
            <!-- TODO: Enable this new rule on higher branches. -->
            <errorLevel type="suppress">
                <directory name="src" />
            </errorLevel>
        </RiskyTruthyFalsyComparison>
        <TooManyArguments>
            <errorLevel type="suppress">
                <!-- Symfony cache supports passing a key prefix to the clear method. -->
                <referencedFunction name="Psr\Cache\CacheItemPoolInterface::clear"/>

                <!-- Persistence 2 compatibility -->
                <referencedFunction name="Doctrine\Persistence\ObjectManager::clear"/>

                <!-- Remove on 3.0.x -->
                <referencedFunction name="Doctrine\Persistence\ObjectManager::refresh"/>
            </errorLevel>
        </TooManyArguments>
        <TypeDoesNotContainType>
            <errorLevel type="suppress">
                <file name="src/Internal/SQLResultCasing.php"/>
                <file name="src/Mapping/ClassMetadataFactory.php"/>
                <file name="src/Utility/LockSqlHelper.php"/>
            </errorLevel>
        </TypeDoesNotContainType>
        <UndefinedClass>
            <errorLevel type="suppress">
                <referencedClass name="Doctrine\Common\Cache\ApcCache"/>
                <referencedClass name="Doctrine\Common\Cache\ArrayCache"/>
                <referencedClass name="Doctrine\Common\Cache\XcacheCache"/>

                <!-- DBAL 2 compatibility -->
                <referencedClass name="Doctrine\DBAL\Driver\ResultStatement"/>
                <referencedClass name="Doctrine\DBAL\ForwardCompatibility\Result"/>
                <referencedClass name="Doctrine\DBAL\Platforms\SQLAnywherePlatform"/>

                <!-- DBAL 3.2 forward compatibility -->
                <referencedClass name="Doctrine\DBAL\Platforms\PostgreSQLPlatform"/>
                <referencedClass name="Doctrine\DBAL\Platforms\SQLServerPlatform"/>

                <!-- Persistence 2 compatibility -->
                <referencedClass name="Doctrine\Persistence\ObjectManagerAware"/>

                <!-- Annotations 1 compatibility -->
                <referencedClass name="Doctrine\Common\Annotations\CachedReader"/>
            </errorLevel>
        </UndefinedClass>
        <UndefinedDocblockClass>
            <errorLevel type="suppress">
                <!-- DBAL 2 compatibility -->
                <referencedClass name="Doctrine\DBAL\Driver\ResultStatement"/>
            </errorLevel>
        </UndefinedDocblockClass>
        <UndefinedMethod>
            <errorLevel type="suppress">
                <!-- See https://github.com/doctrine/orm/issues/8884 -->
                <referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getGuidExpression"/>
            </errorLevel>
        </UndefinedMethod>
        <MissingClosureReturnType>
            <errorLevel type="suppress">
                <file name="src/Tools/Pagination/Paginator.php"/>
            </errorLevel>
        </MissingClosureReturnType>
    </issueHandlers>
</psalm>
