parameters:
    level: 7
    paths:
        - %currentWorkingDirectory%/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~'

        # changing these would be a BC break, to be done in next major
        - '~^Property Doctrine\\DBAL\\Schema\\Table::\$_primaryKeyName \(string\) does not accept (default value of type )?false\.\z~'
        - '~^Property Doctrine\\DBAL\\Schema\\Schema::\$_schemaConfig \(Doctrine\\DBAL\\Schema\\SchemaConfig\) does not accept default value of type false\.\z~'
        - '~^Return type \(int\|false\) of method Doctrine\\DBAL\\Driver\\OCI8\\OCI8Connection\:\:lastInsertId\(\) should be compatible with return type \(string\) of method Doctrine\\DBAL\\Driver\\Connection::lastInsertId\(\)~'

        # https://github.com/phpstan/phpstan/issues/2857
        - '~^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~'

        # weird class name, represented in stubs as OCI_(Lob|Collection)
        - '~unknown class OCI-(Lob|Collection)~'

        # The ReflectionException in the case when the class does not exist is acceptable and does not need to be handled
        - '~^Parameter #1 \$argument of class ReflectionClass constructor expects class-string<T of object>\|T of object, string given\.$~'

        # https://github.com/phpstan/phpstan/issues/3132
        -
            message: '~^Call to function in_array\(\) with arguments Doctrine\\DBAL\\Schema\\Column, array<string> and true will always evaluate to false\.$~'
            path: %currentWorkingDirectory%/lib/Doctrine/DBAL/Schema/Table.php

        # Needs Generics
        - '~Method Doctrine\\DBAL\\Schema\\SchemaDiff::getNewTablesSortedByDependencies\(\) should return array<Doctrine\\DBAL\\Schema\\Table> but returns array<object>.~'

        # 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:
                - %currentWorkingDirectory%/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:
                - %currentWorkingDirectory%/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:
                - %currentWorkingDirectory%/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:
                - %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php

        # Fixing the issue may cause a BC break.
        # TODO: fix in 3.0.0
        -
            message: '~^Parameter \#2 \$sqlState of class Doctrine\\DBAL\\Driver\\Mysqli\\MysqliException constructor expects string\|null, int given\.$~'
            paths:
                - %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.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:
                - %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php

        # This is poorly typed deprecated code. The issue doesn't have practical implication and can be suppressed.
        # TODO: remove in 3.0.0
        -
            message: '~^Parameter \#1 \$how of method PDOStatement\:\:fetchAll\(\) expects int, array\|int\|null given\.$~'
            paths:
                - %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/PDOStatement.php

        # Caused by phpdoc annotations intended for Psalm
        -
            message: '~Unable to resolve the template type T in call to method static method Doctrine\\DBAL\\DriverManager::getConnection\(\)~'
            paths:
                - %currentWorkingDirectory%/lib/Doctrine/DBAL/Id/TableGenerator.php
                - %currentWorkingDirectory%/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php

        -
            message: '~Method Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Connection\:\:lastInsertId\(\) should return string but returns int\|string\|false\|null\.~'
            paths:
                - %currentWorkingDirectory%/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:
                - %currentWorkingDirectory%/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:
                - %currentWorkingDirectory%/lib/Doctrine/DBAL/DriverManager.php
