<?xml version="1.0"?>
<psalm
    totallyTyped="false"
    errorLevel="4"
    resolveFromConfigFile="true"
    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"
>
    <projectFiles>
        <directory name="lib/Doctrine/DBAL" />
        <directory name="tests/Doctrine/Tests" />
        <ignoreFiles>
            <directory name="vendor" />
        </ignoreFiles>
    </projectFiles>
    <stubs>
        <file name="vendor/jetbrains/phpstorm-stubs/PDO/PDO.php" />
        <file name="vendor/jetbrains/phpstorm-stubs/ibm_db2/ibm_db2.php" />
        <file name="vendor/jetbrains/phpstorm-stubs/mysqli/mysqli.php" />
        <file name="vendor/jetbrains/phpstorm-stubs/oci8/oci8.php" />
        <file name="vendor/jetbrains/phpstorm-stubs/pgsql/pgsql.php" />
        <file name="vendor/jetbrains/phpstorm-stubs/sqlsrv/sqlsrv.php" />
    </stubs>
    <issueHandlers>
        <ConflictingReferenceConstraint>
            <errorLevel type="suppress">
                <!--
                    This one is just too convoluted for Psalm to figure out, by
                    its author's own admission
                -->
                <file name="lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php"/>
            </errorLevel>
        </ConflictingReferenceConstraint>
        <FalsableReturnStatement>
            <errorLevel type="suppress">
                <!--
                    Fixing these issues requires an API change
                -->
                <file name="lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php"/>
                <file name="lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php"/>
                <file name="lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php"/>
            </errorLevel>
        </FalsableReturnStatement>
        <ForbiddenCode>
            <errorLevel type="suppress">
                <!-- See https://github.com/doctrine/dbal/pull/3934 -->
                <file name="lib/Doctrine/DBAL/Logging/EchoSQLLogger.php"/>

                <!-- The call to var_dump() here is by design -->
                <file name="lib/Doctrine/DBAL/Tools/Dumper.php"/>
            </errorLevel>
        </ForbiddenCode>
        <ImplicitToStringCast>
            <errorLevel type="suppress">
                <!-- See https://github.com/doctrine/dbal/pull/4082 -->
                <file name="lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php"/>
            </errorLevel>
        </ImplicitToStringCast>
        <ImplementedReturnTypeMismatch>
            <errorLevel type="suppress">
                <!-- See https://github.com/doctrine/dbal/pull/3906 -->
                <file name="lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php"/>

                <!-- See https://github.com/doctrine/dbal/pull/4030 -->
                <file name="lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php"/>
                <file name="lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php"/>

                <!-- See https://github.com/doctrine/dbal/pull/3080 -->
                <file name="lib/Doctrine/DBAL/Driver/PDOConnection.php"/>

                <!-- See https://github.com/doctrine/dbal/issues/4156 -->
                <file name="lib/Doctrine/DBAL/Portability/Connection.php"/>

                <!-- Fixing this issue requires an API change -->
                <file name="lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php"/>
            </errorLevel>
        </ImplementedReturnTypeMismatch>
        <MethodSignatureMismatch>
            <errorLevel type="suppress">
                <!--
                    This one is clearly deliberate; it's a hack to adapt \PDO to
                    Doctrine\DBAL\Driver\Connection
                -->
                <file name="lib/Doctrine/DBAL/Driver/PDOConnection.php"/>
            </errorLevel>
        </MethodSignatureMismatch>
        <NullableReturnStatement>
            <errorLevel type="suppress">
                <!--
                    Fixing this issue requires an API change
                -->
                <file name="lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php"/>
            </errorLevel>
        </NullableReturnStatement>
        <TooFewArguments>
            <errorLevel type="suppress">
                <!--
                    Requires a release of
                    https://github.com/JetBrains/phpstorm-stubs/pull/727
                -->
                <file name="lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php"/>
            </errorLevel>
        </TooFewArguments>
        <TooManyArguments>
            <errorLevel type="suppress">
                <!-- See https://github.com/doctrine/dbal/pull/3080 -->
                <file name="lib/Doctrine/DBAL/Connection.php"/>
                <file name="tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php"/>

                <!-- See https://github.com/doctrine/dbal/pull/3562 -->
                <file name="lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php"/>
                <file name="lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php"/>
            </errorLevel>
        </TooManyArguments>
        <TypeDoesNotContainType>
            <errorLevel type="suppress">
                <!-- See https://github.com/vimeo/psalm/issues/4274 -->
                <file name="lib/Doctrine/DBAL/Schema/Index.php"/>
            </errorLevel>
        </TypeDoesNotContainType>
        <UndefinedConstant>
            <errorLevel type="suppress">
                <directory name="lib/Doctrine/DBAL/Driver/SQLAnywhere"/>
                <!--
                    Requires a release of
                    https://github.com/JetBrains/phpstorm-stubs/pull/732
                -->
                <file name="tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php" />
            </errorLevel>
        </UndefinedConstant>
        <UndefinedFunction>
            <errorLevel type="suppress">
                <directory name="lib/Doctrine/DBAL/Driver/SQLAnywhere"/>
            </errorLevel>
        </UndefinedFunction>
        <UndefinedClass>
            <errorLevel type="suppress">
                <!-- Contains references to optional dependencies -->
                <file name="lib/Doctrine/DBAL/Tools/Dumper.php"/>
            </errorLevel>
        </UndefinedClass>
        <InvalidReturnType>
            <errorLevel type="suppress">
                <!-- lastInsertId has a return type that does not match the one defined in the interface-->
                <file name="lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php"/>
            </errorLevel>
        </InvalidReturnType>
        <InvalidScalarArgument>
            <errorLevel type="suppress">
                <!-- See https://github.com/doctrine/dbal/pull/3498 -->
                <file name="tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php"/>
                <file name="tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php"/>
                <file name="tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php"/>
                <file name="tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php"/>
                <file name="tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php"/>
                <file name="tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php"/>

                <!-- See https://github.com/doctrine/dbal/pull/3574 -->
                <file name="tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php"/>

                <!-- See https://github.com/doctrine/dbal/pull/4007 -->
                <file name="lib/Doctrine/DBAL/Driver/PDOStatement.php"/>

                <!-- See https://github.com/doctrine/dbal/pull/3906 -->
                <file name="tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php"/>
                <file name="tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php"/>
                <file name="tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php"/>

                <!-- See https://github.com/doctrine/dbal/pull/3241 -->
                <file name="lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php"/>

                <!-- See https://github.com/doctrine/dbal/issues/4318 -->
                <file name="lib/Doctrine/DBAL/Types/ConversionException.php"/>
            </errorLevel>
        </InvalidScalarArgument>
        <InvalidReturnStatement>
            <errorLevel type="suppress">
                <!-- lastInsertId has a return type that does not match the one defined in the interface-->
                <file name="lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php"/>
            </errorLevel>
        </InvalidReturnStatement>
    </issueHandlers>
</psalm>
