diff --git a/composer.json b/composer.json index 68b7fe623be..9c16990a4bd 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "doctrine/coding-standard": "^7.0", "jetbrains/phpstorm-stubs": "^2019.1", "nikic/php-parser": "^4.4", - "phpstan/phpstan": "^0.12", + "phpstan/phpstan": "^0.12.30", "phpunit/phpunit": "^8.5.5", "psalm/plugin-phpunit": "^0.10.0", "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", diff --git a/composer.lock b/composer.lock index ab624b240e9..031cc19a8df 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0372454a0ee2de4c2051cc13cbb23b72", + "content-hash": "f636004536741040e603f9f76802dc11", "packages": [ { "name": "doctrine/cache", @@ -299,6 +299,71 @@ ], "time": "2020-04-04T16:56:54+00:00" }, + { + "name": "composer/package-versions-deprecated", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/composer/package-versions-deprecated.git", + "reference": "98df7f1b293c0550bd5b1ce6b60b59bdda23aa47" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/98df7f1b293c0550bd5b1ce6b60b59bdda23aa47", + "reference": "98df7f1b293c0550bd5b1ce6b60b59bdda23aa47", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1.0 || ^2.0", + "php": "^7" + }, + "replace": { + "ocramius/package-versions": "1.2 - 1.8.99" + }, + "require-dev": { + "composer/composer": "^1.9.3 || ^2.0@dev", + "ext-zip": "^1.13", + "phpunit/phpunit": "^6.5 || ^7" + }, + "type": "composer-plugin", + "extra": { + "class": "PackageVersions\\Installer", + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "PackageVersions\\": "src/PackageVersions" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be" + } + ], + "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2020-04-23T11:49:37+00:00" + }, { "name": "composer/semver", "version": "1.5.1", @@ -871,56 +936,6 @@ ], "time": "2020-04-10T16:34:50+00:00" }, - { - "name": "ocramius/package-versions", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "44af6f3a2e2e04f2af46bcb302ad9600cba41c7d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/44af6f3a2e2e04f2af46bcb302ad9600cba41c7d", - "reference": "44af6f3a2e2e04f2af46bcb302ad9600cba41c7d", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0.0", - "php": "^7.1.0" - }, - "require-dev": { - "composer/composer": "^1.6.3", - "doctrine/coding-standard": "^5.0.1", - "ext-zip": "*", - "infection/infection": "^0.7.1", - "phpunit/phpunit": "^7.5.17" - }, - "type": "composer-plugin", - "extra": { - "class": "PackageVersions\\Installer", - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "PackageVersions\\": "src/PackageVersions" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" - } - ], - "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "time": "2019-11-15T16:17:10+00:00" - }, { "name": "openlss/lib-array2xml", "version": "1.0.0", @@ -1334,21 +1349,24 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.18", + "version": "0.12.30", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "1ce27fe29c8660a27926127d350d53d80c4d4286" + "reference": "1f2c16d3fbb5eec6e55fbe2358e32570cefa20e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1ce27fe29c8660a27926127d350d53d80c4d4286", - "reference": "1ce27fe29c8660a27926127d350d53d80c4d4286", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1f2c16d3fbb5eec6e55fbe2358e32570cefa20e5", + "reference": "1f2c16d3fbb5eec6e55fbe2358e32570cefa20e5", "shasum": "" }, "require": { "php": "^7.1" }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, "bin": [ "phpstan", "phpstan.phar" @@ -1369,7 +1387,21 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2020-03-22T16:51:47+00:00" + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2020-06-21T14:08:19+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2660,6 +2692,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-30T11:41:10+00:00" }, { diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index bd3894477b5..92611267d94 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\ParameterType; use PDO; +use function is_string; use function strpos; use function substr; @@ -45,7 +46,7 @@ public function quote($value, $type = ParameterType::STRING) $val = parent::quote($value, $type); // Fix for a driver version terminating all values with null byte - if (strpos($val, "\0") !== false) { + if (is_string($val) && strpos($val, "\0") !== false) { $val = substr($val, 0, -1); } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index d1e9bcdd481..74c2444e63e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,7 +2,7 @@ parameters: level: 7 paths: - %currentWorkingDirectory%/lib - autoload_files: + scanFiles: - %currentWorkingDirectory%/tests/phpstan-polyfill.php reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false @@ -14,31 +14,22 @@ parameters: # removing it would be BC break - '~^Constructor of class Doctrine\\DBAL\\Schema\\Table has an unused parameter \$idGeneratorType\.\z~' - # declaring $tableName in AbstractSchemaManager::_getPortableTableIndexesList() non-optional will be a BC break - - '~^Parameter #2 \$table of class Doctrine\\DBAL\\Event\\SchemaIndexDefinitionEventArgs constructor expects string, string\|null given\.\z~' - # changing these would be a BC break, to be done in next major - - "~^Casting to bool something that's already bool.~" - - "~^Casting to int something that's already int.~" - - '~^Method Doctrine\\DBAL\\Driver\\IBMDB2\\DB2Connection::exec\(\) should return int but returns bool\.\z~' - '~^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~' - - '~^Method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint::onEvent\(\) should return string\|null but returns false\.\z~' - - '~^Method Doctrine\\DBAL\\Schema\\(Oracle|PostgreSql|SQLServer)SchemaManager::_getPortableTableDefinition\(\) should return array but returns string\.\z~' - - '~^Method Doctrine\\DBAL\\Driver\\OCI8\\OCI8Connection::lastInsertId\(\) should return string but returns (int|false)\.\z~' - - '~^Method Doctrine\\DBAL\\Driver\\SQLSrv\\SQLSrvConnection::errorCode\(\) should return string\|null but returns 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://bugs.php.net/bug.php?id=78126 - - '~^Call to an undefined method Doctrine\\DBAL\\Driver\\PDOConnection::sqliteCreateFunction\(\)\.\z~' + # https://github.com/phpstan/phpstan/issues/3527 + - + message: '~^Call to private method sqliteCreateFunction\(\) of parent class PDO\.$~' + path: %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php - # https://github.com/phpstan/phpstan/issues/1847 - - '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::unknownAlias\(\) expects array, array given\.\z~' + # https://github.com/phpstan/phpstan/issues/2857 + # TODO: remove in 4.0.0 - '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array, array given\.\z~' - # PHPStan is too strict about preg_replace(): https://phpstan.org/r/993dc99f-0d43-4b51-868b-d01f982c1463 - - '~^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform::escapeStringForLike\(\) should return string but returns string\|null\.\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... @@ -48,16 +39,10 @@ parameters: - '~^Class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy) not found\.\z~' - '~^.+ on an unknown class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy)\.\z~' - # inheritance variance inference issue - - '~^Method Doctrine\\DBAL\\Driver\\PDOConnection::\w+\(\) should return Doctrine\\DBAL\\Driver\\Statement but returns PDOStatement\.\z~' - - # may not exist when pdo_sqlsrv is not loaded but PDO is - - '~^Access to undefined constant PDO::SQLSRV_ENCODING_BINARY\.\z~' - # weird class name, represented in stubs as OCI_(Lob|Collection) - '~unknown class OCI-(Lob|Collection)~' - # https://github.com/JetBrains/phpstorm-stubs/pull/766 + # https://github.com/phpstan/phpstan-src/pull/255 - '~^Method Doctrine\\DBAL\\Driver\\Mysqli\\MysqliStatement::_fetch\(\) never returns null so it can be removed from the return typehint\.$~' # The ReflectionException in the case when the class does not exist is acceptable and does not need to be handled @@ -73,17 +58,61 @@ parameters: message: '~^Cannot cast array\|bool\|string\|null to int\.$~' path: %currentWorkingDirectory%/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php - # Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/732 - - - message: '~^Access to undefined constant PDO::PGSQL_ATTR_DISABLE_PREPARES\.$~' - path: %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php - # 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 but returns array.~' + # 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\(\)~' @@ -97,6 +126,6 @@ parameters: - %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php - - message: '~Method Doctrine\\DBAL\\Portability\\Connection::prepare\(\) should return Doctrine\\DBAL\\Statement but returns Doctrine\\DBAL\\Portability\\Statement\.~' + 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