parameters:
    level: 7
    paths:
        - %currentWorkingDirectory%/src
    treatPhpDocTypesAsCertain: false
    reportUnmatchedIgnoredErrors: false
    checkMissingIterableValueType: false
    checkGenericClassInNonGenericObjectType: false
    ignoreErrors:
        # 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
        - "~^Casting to bool something that's already bool.~"
        - '~^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\\Connection\:\:lastInsertId\(\) should be compatible with return type \(string\) of method Doctrine\\DBAL\\Driver\\Connection::lastInsertId\(\)~'
        - '~^Method Doctrine\\DBAL\\Driver\\Mysqli\\Connection::lastInsertId\(\) should return string but returns int\|string\.$~'

        # 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~'

        # 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)~'
        - '~^Call to method writeTemporary\(\) on an unknown class OCILob\.~'

        # 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: %currentWorkingDirectory%/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: %currentWorkingDirectory%/src/Driver/PDO/Connection.php

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

        # 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: %currentWorkingDirectory%/tests/Types/TypeRegistryTest.php

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

        # Fixing the issue may cause a BC break.
        -
            message: '~^Method Doctrine\\DBAL\\Driver\\Mysqli\\MysqliConnection::lastInsertId\(\) should return string but returns int\|string\.$~'
            paths:
                - %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.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:
                - %currentWorkingDirectory%/src/Driver/*/Driver.php
                - %currentWorkingDirectory%/src/Platforms/*Platform.php
                - %currentWorkingDirectory%/src/Query/QueryBuilder.php
                - %currentWorkingDirectory%/src/Schema/*SchemaManager.php

        # Some APIs use variable method calls internally
        -
            message: '~^Variable method call on .*~'
            paths:
                - %currentWorkingDirectory%/src/Schema/Column.php

        # https://github.com/phpstan/phpstan/issues/3146
        -
            message: '~^Only numeric types are allowed in -, int<1, max>\|false given on the left side\.~'
            paths:
                - %currentWorkingDirectory%/src/Platforms/SQLServer2012Platform.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%/src/DriverManager.php

        # Unlike Psalm, PHPStan doesn't understand that $matchesCount cannot be false
        -
            message: '~^Only numeric types are allowed in pre\-decrement, int\<1, max\>\|false given\.$~'
            paths:
                - %currentWorkingDirectory%/src/Platforms/SQLServer2012Platform.php

        # https://github.com/phpstan/phpstan-phpunit/issues/83
        -
            message: '~^Only iterables can be unpacked, array<int, mixed>\|false given in argument #1\.$~'
            paths:
                - %currentWorkingDirectory%/tests/Functional/Platform/DefaultExpressionTest.php

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

        # We're checking for invalid invalid input
        -
            message: "#^Strict comparison using \\!\\=\\= between null and null will always evaluate to false\\.$#"
            count: 1
            path: src/Cache/QueryCacheProfile.php
includes:
    - vendor/phpstan/phpstan-strict-rules/rules.neon
