Describe return type accurately

This return type is conditional to $params['wrapperClass']. Luckily,
recent versions of Psalm allow documenting it properly.
See https://github.com/vimeo/psalm/issues/3277

Note that phpstan is not able to understand this yet, but still attempts
to, hence the extra ignore rules.
parent 9d730848
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
"phpunit/phpunit": "^8.5.5", "phpunit/phpunit": "^8.5.5",
"psalm/plugin-phpunit": "^0.10.0", "psalm/plugin-phpunit": "^0.10.0",
"symfony/console": "^2.0.5|^3.0|^4.0|^5.0", "symfony/console": "^2.0.5|^3.0|^4.0|^5.0",
"vimeo/psalm": "^3.11" "vimeo/psalm": "^3.11.4"
}, },
"suggest": { "suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files." "symfony/console": "For helpful console commands such as SQL execution and import of files."
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "9157c6d35dd39f5399592fd91126fa07", "content-hash": "0372454a0ee2de4c2051cc13cbb23b72",
"packages": [ "packages": [
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
...@@ -2995,16 +2995,16 @@ ...@@ -2995,16 +2995,16 @@
}, },
{ {
"name": "vimeo/psalm", "name": "vimeo/psalm",
"version": "3.11.2", "version": "3.11.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/vimeo/psalm.git", "url": "https://github.com/vimeo/psalm.git",
"reference": "d470903722cfcbc1cd04744c5491d3e6d13ec3d9" "reference": "58e1d8e68e5098bf4fbfdfb420c38d563f882549"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/d470903722cfcbc1cd04744c5491d3e6d13ec3d9", "url": "https://api.github.com/repos/vimeo/psalm/zipball/58e1d8e68e5098bf4fbfdfb420c38d563f882549",
"reference": "d470903722cfcbc1cd04744c5491d3e6d13ec3d9", "reference": "58e1d8e68e5098bf4fbfdfb420c38d563f882549",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -3089,7 +3089,7 @@ ...@@ -3089,7 +3089,7 @@
"inspection", "inspection",
"php" "php"
], ],
"time": "2020-04-13T12:47:11+00:00" "time": "2020-05-11T13:39:25+00:00"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",
......
...@@ -115,11 +115,15 @@ final class DriverManager ...@@ -115,11 +115,15 @@ final class DriverManager
* <b>driverClass</b>: * <b>driverClass</b>:
* The driver class to use. * The driver class to use.
* *
* @param mixed[] $params The parameters. * @param array{wrapperClass?: class-string<T>} $params
* @param Configuration|null $config The configuration to use. * @param Configuration|null $config The configuration to use.
* @param EventManager|null $eventManager The event manager to use. * @param EventManager|null $eventManager The event manager to use.
* *
* @throws DBALException * @throws DBALException
*
* @phpstan-param mixed[] $params
* @psalm-return ($params is array{wrapperClass:mixed} ? T : Connection)
* @template T of Connection
*/ */
public static function getConnection( public static function getConnection(
array $params, array $params,
......
...@@ -83,3 +83,10 @@ parameters: ...@@ -83,3 +83,10 @@ parameters:
# Needs Generics # Needs Generics
- '~Method Doctrine\\DBAL\\Schema\\SchemaDiff::getNewTablesSortedByDependencies\(\) should return array<Doctrine\\DBAL\\Schema\\Table> but returns array<object>.~' - '~Method Doctrine\\DBAL\\Schema\\SchemaDiff::getNewTablesSortedByDependencies\(\) should return array<Doctrine\\DBAL\\Schema\\Table> but returns array<object>.~'
# 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment