Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Symfony\Component\Cache\Adapter\PdoAdapter::__construct() 1st param DocBlock Comment type should be Connection|\PDO|string #45956

Closed
@milanmadar

Description

@milanmadar

Symfony version(s) affected

5.4.7

Description

\Symfony\Component\Cache\Adapter\PdoAdapter::__construct() 1st param is $connOrDsn.
The DocBlock Comment currently section says:
@param \PDO|string $connOrDsn, however it can also be of type \Doctrine\DBAL\Connection.

Because of the DocBlock Comment is currently missing the Connection type, some static analyzers (phpstan) fails when we provide a Connection object.

How to reproduce

use Doctrine\DBAL\DriverManager;
use Symfony\Component\Cache\Adapter\PdoAdapter;

$connUrl = 'mysql://user:[email protected]/db_name';
$conn = DriverManager::getConnection( [ 'url' => $connUrl ]);
new PdoAdapter( $conn, 'mycache', 3600 );

Then run phpstan on it

Possible Solution

in vendor/symfony/cache/Adapter/PdoAdapter.php Link to GitHub line change line 59 to this:

* @param \PDO|Connection|string $connOrDsn

Additional Context

static analyzer

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions