phpstan.neon.dist 7.61 KB
Newer Older
1
parameters:
Sergei Morozov's avatar
Sergei Morozov committed
2
    level: 7
3 4
    paths:
        - %currentWorkingDirectory%/lib
5
    scanFiles:
6 7
        - %currentWorkingDirectory%/tests/phpstan-polyfill.php
    reportUnmatchedIgnoredErrors: false
8 9
    checkMissingIterableValueType: false
    checkGenericClassInNonGenericObjectType: false
10 11 12 13
    earlyTerminatingMethodCalls:
        Doctrine\DBAL\Connection:
            - handleDriverException
            - handleExceptionDuringQuery
14 15 16 17 18 19 20 21 22 23
    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~'
24
        - '~^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\(\)~'
25

26 27
        # https://github.com/phpstan/phpstan/issues/2857
        # TODO: remove in 4.0.0
28
        - '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int\|string> given\.\z~'
Sergei Morozov's avatar
Sergei Morozov committed
29

30
        # legacy variadic-like signature
31
        # TODO: remove in 3.0.0
32
        - '~^Method Doctrine\\DBAL(\\.*)?Connection::query\(\) invoked with \d+ parameters?, 0 required\.\z~'
33 34 35 36 37 38 39 40

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

41
        # weird class name, represented in stubs as OCI_(Lob|Collection)
42
        - '~unknown class OCI-(Lob|Collection)~'
43 44 45 46 47 48 49 50 51 52 53 54 55

        # 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

        # https://github.com/phpstan/phpstan/issues/3133
        -
            message: '~^Cannot cast array<string>\|bool\|string\|null to int\.$~'
            path: %currentWorkingDirectory%/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
56

57 58 59 60 61
        # False Positive
        - '~Strict comparison using === between 1 and 2 will always evaluate to false~'

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

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
        # 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

112 113 114 115 116 117
        # 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
118 119 120 121 122

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

        -
125
            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\(\)~'
126 127
            paths:
                - %currentWorkingDirectory%/lib/Doctrine/DBAL/Portability/Connection.php