parameters:
    level: 8
    paths:
        - lib
    reportUnmatchedIgnoredErrors: false
    checkMissingIterableValueType: false
    checkGenericClassInNonGenericObjectType: false
    earlyTerminatingMethodCalls:
        Doctrine\DBAL\Connection:
            - handleDriverException
            - handleExceptionDuringQuery
    ignoreErrors:
        # extension not available
        - '~^(Used )?(Function|Constant) sasql_\S+ not found\.\z~i'

        # removing it would be BC break
        - '~^Constructor of class Doctrine\\DBAL\\Schema\\Table has an unused parameter \$idGeneratorType\.\z~'

        # https://github.com/doctrine/dbal/pull/3836
        - '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int\|string> given\.\z~'

        # legacy variadic-like signature
        # TODO: remove in 3.0.0
        - '~^Method Doctrine\\DBAL(\\.*)?Connection::query\(\) invoked with \d+ parameters?, 0 required\.\z~'

        # some drivers actually do accept 2nd parameter...
        - '~^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getListTableForeignKeysSQL\(\) invoked with \d+ parameters, 1 required\.\z~'

        # legacy remnants from doctrine/common
        - '~^Class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy) not found\.\z~'
        - '~^.+ on an unknown class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy)\.\z~'

        # This is deprecated code. Fixing the issue may cause a BC break.
        # TODO: remove in 3.0.0
        -
            message: '~^Return type \(Doctrine\\DBAL\\Platforms\\DrizzlePlatform\) of method Doctrine\\DBAL\\Driver\\DrizzlePDOMySql\\Driver::getDatabasePlatform\(\) should be compatible with return type \(Doctrine\\DBAL\\Platforms\\MySqlPlatform\) of method Doctrine\\DBAL\\Driver\\AbstractMySQLDriver::getDatabasePlatform\(\)$~'
            paths:
                - lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php

        # This is deprecated code. Fixing the issue may cause a BC break.
        # TODO: remove in 3.0.0
        -
            message: '~^Return type \(Doctrine\\DBAL\\Schema\\DrizzleSchemaManager\) of method Doctrine\\DBAL\\Driver\\DrizzlePDOMySql\\Driver::getSchemaManager\(\) should be compatible with return type \(Doctrine\\DBAL\\Schema\\MySqlSchemaManager\) of method Doctrine\\DBAL\\Driver\\AbstractMySQLDriver::getSchemaManager\(\)$~'
            paths:
                - lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php

        # This is deprecated code. Fixing the issue may cause a BC break.
        # TODO: remove in 3.0.0
        -
            message: '~^Return type \(int\) of method Doctrine\\DBAL\\Driver\\Mysqli\\MysqliConnection::errorCode\(\) should be compatible with return type \(string\|null\) of method Doctrine\\DBAL\\Driver\\Connection::errorCode\(\)$~'
            paths:
                - lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php

        # This is deprecated code. Fixing the issue may cause a BC break.
        # TODO: remove in 3.0.0
        -
            message: '~^Return type \(string\) of method Doctrine\\DBAL\\Driver\\Mysqli\\MysqliConnection::errorInfo\(\) should be compatible with return type \(array\) of method Doctrine\\DBAL\\Driver\\Connection::errorInfo\(\)$~'
            paths:
                - lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php

        # This is deprecated code. Fixing the issue may cause a BC break.
        # TODO: remove in 3.0.0
        -
            message: '~^Return type \(string\) of method Doctrine\\DBAL\\Driver\\Mysqli\\MysqliStatement::errorInfo\(\) should be compatible with return type \(array\) of method Doctrine\\DBAL\\Driver\\Statement::errorInfo\(\)$~'
            paths:
                - lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php

        -
            message: '~Method Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Connection\:\:lastInsertId\(\) should return int\|string\|false but returns int\|string\|false\|null\.~'
            paths:
                - lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php

        -
            message: '~Return type \(Doctrine\\DBAL\\Portability\\Statement\) of method Doctrine\\DBAL\\Portability\\Connection::prepare\(\) should be compatible with return type \(Doctrine\\DBAL\\Statement\) of method Doctrine\\DBAL\\Connection::prepare\(\)~'
            paths:
                - lib/Doctrine/DBAL/Portability/Connection.php

        # Unlike Psalm, PHPStan doesn't understand the shape of the parse_str() return value
        -
            message: '~^Parameter #1 \$scheme of static method Doctrine\\DBAL\\DriverManager::parseDatabaseUrlScheme\(\) expects string\|null, int\|string\|null given\.$~'
            paths:
                - lib/Doctrine/DBAL/DriverManager.php

        # Until 3.x, $_conn does accept PDO
        -
            message: '~^Property Doctrine\\DBAL\\Connection::\$_conn \(Doctrine\\DBAL\\Driver\\Connection\|null\) does not accept PDO\.$~'
            paths:
                - lib/Doctrine/DBAL/Connection.php

        # PHPStan fails to parse this type alias which is meant for Psalm only.
        -
            message: '~^Invalid type definition detected in type alias (Override)?Params\.$~'
            paths:
                - lib/Doctrine/DBAL/DriverManager.php

        -
            message: '~Template type T of method Doctrine\\DBAL\\DriverManager::getConnection\(\) is not referenced in a parameter\.~'
            paths:
                - lib/Doctrine/DBAL/DriverManager.php

        -
            message: '~Method Doctrine\\DBAL\\DriverManager::createDriver\(\) should return Doctrine\\DBAL\\Driver but returns object\.~'
            paths:
                - lib/Doctrine/DBAL/DriverManager.php

        # TODO: remove in 4.0.0
        -
            message: '~^Parameter #2 \$table of class Doctrine\\DBAL\\Event\\SchemaIndexDefinitionEventArgs constructor expects string, string\|null given\.$~'
            paths:
                - lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php

        # https://github.com/phpstan/phpstan/issues/1901
        -
            message: '~^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform::escapeStringForLike\(\) should return string but returns string\|null\.$~'
            paths:
                - lib/Doctrine/DBAL/Platforms/AbstractPlatform.php

        # https://github.com/phpstan/phpstan/issues/4679
        -
            message: '~^Cannot call method writeTemporary\(\) on OCILob\|null\.$~'
            paths:
                - lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php

        -
            message: '~Method Doctrine\\DBAL\\Driver\\Mysqli\\MysqliStatement::rowCount\(\) should return int but returns int\|string\.~'
            paths:
                - lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
