parameters:
    level: 8
    paths:
        - src
    treatPhpDocTypesAsCertain: false
    reportUnmatchedIgnoredErrors: false
    checkMissingIterableValueType: false
    checkGenericClassInNonGenericObjectType: false
    ignoreErrors:
        # https://github.com/doctrine/dbal/pull/3836
        # TODO: remove in 4.0.0
        - '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int\|string> given\.\z~'

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

        # Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/553
        -
            message: '~^Call to function assert\(\) with true will always evaluate to true\.$~'
            path: src/Driver/PDO/Connection.php

        # Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/923
        -
            message: '~^Instanceof between PDOStatement and PDOStatement will always evaluate to true\.$~'
            path: src/Driver/PDO/Connection.php

        # https://github.com/phpstan/phpstan/issues/3134
        -
            message: '~^Call to static method PHPUnit\\Framework\\Assert::assertSame\(\) with Doctrine\\DBAL\\Types\\Type and Doctrine\\DBAL\\Types\\Type will always evaluate to true\.$~'
            path: tests/Types/TypeRegistryTest.php

        # https://github.com/phpstan/phpstan-strict-rules/issues/103
        -
            message: '~^Construct empty\(\) is not allowed. Use more strict comparison\.~'
            paths:
                - src/Driver/*/Driver.php
                - src/Driver/AbstractOracleDriver/EasyConnectString.php
                - src/Platforms/*Platform.php
                - src/Schema/*SchemaManager.php

        # In some namespaces, we use array<string,mixed>, some elements of which are actually boolean
        -
            message: '~^Only booleans are allowed in .*, mixed given~'
            paths:
                - src/Driver/*/Driver.php
                - src/Platforms/*Platform.php
                - src/Query/QueryBuilder.php
                - src/Schema/*SchemaManager.php

        # Some APIs use variable method calls internally
        -
            message: '~^Variable method call on .*~'
            paths:
                - src/Schema/Column.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:
                - src/DriverManager.php

        -
            message: '~^Instanceof between Doctrine\\DBAL\\Platforms\\Keywords\\KeywordList and Doctrine\\DBAL\\Platforms\\Keywords\\KeywordList will always evaluate to true\.~'
            paths:
                - src/Platforms/AbstractPlatform.php

        # TODO: remove this once the support for PHP 7 is dropped
        -
            message: '~^Strict comparison using !== between int and false will always evaluate to true\.$~'
            paths:
                - src/Driver/OCI8/Result.php
        -
            message: '~^Unreachable statement - code above always terminates\.$~'
            paths:
                - src/Driver/OCI8/Result.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:
                - src/DriverManager.php

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

        -
            message: '~Method Doctrine\\DBAL\\DriverManager::createDriver\(\) should return Doctrine\\DBAL\\Driver but returns object\.~'
            paths:
                - src/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:
                - src/Schema/AbstractSchemaManager.php

        # See https://github.com/doctrine/dbal/pull/4707
        # TODO: remove in 4.0.0
        -
            message: '~^Dynamic call to static method Doctrine\\DBAL\\Schema\\Comparator::compareSchemas\(\)\.$~'
            paths:
                - src/Schema/AbstractSchemaManager.php
                - src/Schema/Comparator.php
                - src/Schema/Schema.php

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

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

        # TODO: check for null after calling Connection::getDatabase()
        -
            message: '~Parameter.*\$database of method.*expects string, string\|null given\.~'
            path: src/Schema/AbstractSchemaManager.php
            count: 3

        # TODO: prevent unsafe usage of operator - with null
        -
            message: '~Only numeric types are allowed in \-, float\|null given on the right side\.~'
            path: src/Logging/DebugStack.php

        # https://github.com/phpstan/phpstan-src/pull/731
        -
            message: '~Parameter #1 \$array of function array_column expects array, array\|false given\.~'
            path: src/Driver/Mysqli/Result.php

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

        # Type check for legacy implementations of the Connection interface
        # TODO: remove in 4.0.0
        - "~Call to function method_exists\\(\\) with Doctrine\\\\DBAL\\\\Driver\\\\Connection and 'getNativeConnection' will always evaluate to true\\.~"
includes:
    - vendor/phpstan/phpstan-strict-rules/rules.neon
